Which IIQ version are you inquiring about?
8.3
Hello All the requirement was i wanted to create a policy violation like whenever a user requests a business role, there should be a policy violation if that this user is not in the respective AD group named (Testing), like whoever requests the access he should be in Testing AD group or else policy violation occurs. Can anyone please enlighten.
I have written one rule as :
<Rule language="beanshell" name="CheckADGroupPolicy" type="Policy">
<Description>Checks if the identity has the required AD group membership. If not, raises a PolicyViolation.</Description>
<Signature returnType="PolicyViolation">
<Inputs>
<Argument name="log"/>
<Argument name="context"/>
<Argument name="identity"/>
<Argument name="policy"/>
<Argument name="constraint"/>
</Inputs>
<Returns>
<Argument name="violation"/>
</Returns>
</Signature>
<Source><![CDATA[
import sailpoint.object.Identity;
import sailpoint.object.IdentityEntitlement;
import sailpoint.object.PolicyViolation;
import sailpoint.tools.Filter;
import sailpoint.tools.QueryOptions;
String requiredGroup = "CN=AdminStaff,CN=Users,DC=IIQAD,DC=com";
String identityName = identity.getName();
boolean foundGroup = false;
log.error("=== Checking AD group for identity: " + identityName);
Filter filter = Filter.eq("identity.name", identityName);
QueryOptions qo = new QueryOptions();
qo.addFilter(filter);
Iterator it = context.search(IdentityEntitlement.class, qo);
while (it.hasNext()) {
IdentityEntitlement entitlement = (IdentityEntitlement) it.next();
if ("memberOf".equalsIgnoreCase(entitlement.getName())) {
Object value = entitlement.getValue();
log.error("Found entitlement: " + value);
if (value != null && value.toString().equalsIgnoreCase(requiredGroup)) {
foundGroup = true;
break;
}
}
}
if (!foundGroup) {
log.error(">>> User is NOT in required AD group. Creating policy violation.");
PolicyViolation violation = new PolicyViolation();
violation.setDescription("User is not a member of required AD group: " + requiredGroup);
violation.setIdentity(identity);
violation.setStatus(PolicyViolation.Status.Open);
violation.setPolicy(policy);
violation.setConstraint(constraint);
violation.setActive(true);
if (identity.getManager() != null) {
violation.setOwner(identity.getManager());
} else {
violation.setOwner(context.getObjectByName(Identity.class, "spadmin"));
}
Date now = new Date();
violation.setName("Missing AD Group - " + now.toString());
violation.setId(now.toString());
return violation;
}
log.error(">>> User is compliant. No violation.");
return null;
]]></Source>
</Rule>
````Preformatted text`
can anyone help this is giving errors as Policy Impact Analysis task failed with exception. </EventMessage>
<Stacktrace>sailpoint.tools.GeneralException: BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: ``import sailpoint.object.Identity; import sailpoint.object.IdentityEntitlement; . . . '' : Typed variable declaration : Class: Filter not found in namespace : at Line: 16 : in file: inline evaluation of: ``import sailpoint.object.Identity; import sailpoint.object.IdentityEntitlement; . . . '' : Filter
BSF info: rulepolicy at line: 0 column: columnNo