Which IIQ version are you inquiring about?
8.3p3
Share all details about your problem, including any error messages you may have received.
Hello everyone.
Could someone please help me with the following problem.
We have a need to add a Joiner user to a group based on one-time access only. We have a group in AD to which any new account should be added, so as soon as the user completes the IT security test, they’ll be automatically removed from this group by the testing software.
The main problem for us is that when we use the IIQ to provision the groups, the entitlement is linked to the user and after the account aggregation and identity refresh tasks, the user is added back to the group.
I’m currently trying to use the execution of a powershell script for this operation, using the AfterProvisioning rule, so the entitlement would be detected and not assigned. But after the user is created he is still not added to the group and I don’t see any errors.
Here is the After Provisioning Rule code:
for ( AccountRequest accountRequest : plan.getAccountRequests() ) {
if ( accountRequest.getOp() != null && accountRequest.getOp().equals(ProvisioningPlan.ObjectOperation.Create) ) {
Identity identity = plan.getIdentity();
if (identity == null)
{
throw new Exception("Identity is null");
}
else
{
Map data = new HashMap();
Rule yourPowershellRuleObject = context.getObjectByName(Rule.class, "yourPowershellRuleObject");
Application ad = context.getObjectByName(Application.class, "Active Directory");
data.put("Request", accountRequest);
data.put("Application", ad.getAttributes());
data.put("postScript", yourPowershellRuleObject);
String iqServiceHost = myHost;
int iqServicePort = 6060;
RPCService service = new RPCService(iqServiceHost, iqServicePort, false, true);
service.setConnectorServices(new sailpoint.connector.DefaultConnectorServices());
RpcRequest request = new RpcRequest("ScriptExecutor", "runAfterScript", data);
RpcResponse response = service.execute(request);
}
}
}
And here is the powershell script:
Add-type -Path C:\IdentityIQ\IQService\Utils.dll
$sReader = New-Object System.IO.StringReader([System.String]$env:Request);
$xmlReader = [System.xml.XmlTextReader]([sailpoint.Utils.xml.XmlUtil]::getReader($sReader));
$requestObject = New-Object Sailpoint.Utils.objects.AccountRequest($xmlReader);
$resultObject = New-Object Sailpoint.Utils.objects.ServiceResult;
Start-Sleep -Seconds 30
foreach ($attribute in $requestObject.AttributeRequests){
if($attribute.Name -eq "sAMAccountName"){
# User Name
$Username = $attribute.Value
# Active Directory Group Name
$GroupName = "CN=SAILPOINT-TEST-MOODLE,OU=Enterprise Groups,OU=DEV,OU=Sailpoint,OU=test,OU=KBP,DC=test,DC=intra"
if (Get-ADGroup -Filter { Name -eq $GroupName }) {
try {
Add-ADGroupMember -Identity $GroupName -Members $Username
Write-Output "User $Username added to group $GroupName successfully."
} catch {
Write-Output "Error adding user to group: $_"
}
} else {
Write-Output "Group $GroupName does not exist."
}
}
}
If anyone can help me with the code issues, or any other ideas on how to solve this problem, I would be happy to hear from you.
Best Regards,
Danylo.