AEM Permissions Fixer Probe Action

Microsoft.SystemCenter.CM.AEM.UITasks.PermissionsFixerPA (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
PA ProbeAction System.Secure.CommandExecuterProbe Default

Source Code:

<ProbeActionModuleType ID="Microsoft.SystemCenter.CM.AEM.UITasks.PermissionsFixerPA" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration/>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PA" TypeID="System!System.Secure.CommandExecuterProbe">
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>
//nologo $file/AemFixPermissions.js$ $RunAs[Name="AEMLib!Microsoft.SystemCenter.CM.ActionAccount"]/Domain$ $RunAs[Name="AEMLib!Microsoft.SystemCenter.CM.ActionAccount"]/UserName$ $Target/Property[Type="AEMLib!Microsoft.SystemCenter.CM.AEM.CrashListener"]/SharePath$
</CommandLine>
<TimeoutSeconds>120</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>AemFixPermissions.js</Name>
<Contents><Script>
/*********************************************************************************
* AemFixPermissions.js
* - Input: domain name, user account, share path
* - Output: none
* - This function adds given user account to AEMAgent group in share server.
*********************************************************************************/
var objArgs = WScript.Arguments;
var ADSName = GetADSIAccount(objArgs(0), objArgs(1));
WScript.Echo("User Account: " + ADSName);
var server = GetShareServerName(objArgs(2));
WScript.Echo("Target Machine: " + server);
var group = GetObject("WinNT://" + server + "/AEMAgent");
group.Add("WinNT://" + ADSName + "");
WScript.Echo("Task Completed");

// Below function is needed due to the useraccount being passed in two formats: 'userAccount' or 'domain\userAccount'
function GetADSIAccount(domainName, userAccount)
{
var index = userAccount.indexOf("\\", 0);
// "/\\g" is a reg. exp. to replace "\" with "/" in the second argument to the function
var adsiAccount = (index &gt; 0) ? userAccount.replace(/\\/g, "/") : domainName + "/" + userAccount;
return adsiAccount;
}

function GetShareServerName(sharePath)
{
var server;

if (isUNCPath(sharePath))
{
upToPtr = sharePath.lastIndexOf("\\", sharePath.length - 2); //disregard the last '\'
server = sharePath.substr(2, upToPtr - 2);
}
else
{
// If the given path is not a UNC path, it is local path
server = "localhost";
}

return server;
}

function isUNCPath(sharePath)
{
var result = (sharePath.substr(0, 2) == "\\\\");
return result;
}
</Script></Contents>
<Unicode>1</Unicode>
</File>
</Files>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.BaseData</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>