Hi,
We have a requirement as below.
- Find members from AD Application in entitlement catalogue
- Check the owner field for each entitlement .
- If there is a workgroup in owner field - we have to add all the members in that entitlement to that workgroup dynamically.
Initially, I created a custom rule to fetch all memebers from AD application
Filter filterEntitlement = Filter.and(Filter.and(Filter.eq(“application.name”,“MRC Active Directory Direct”),
Filter.eq(“name”, “memberOf”),
Filter filter = Filter.collectionCondition("identityEntitlements", filterEntitlement);
QueryOptions qo = new QueryOptions();
qo.addFilter(filter);
List ids = context.getObjects(Identity.class, qo);
List memberName = new ArrayList();
for (Identity identity : ids) {
memberName.add(identity.getName());
System.out.println("Found identity: " + identity.getName());
}
Secondly, I gave the sample workgroup name directly in querry options and I am able to add all these memebers in that static workgroup.
List userNames=new ArrayList();
// Make Sure you add the list of users to the above list of userNames
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.in(“name”, memberName));
int recordCounter=0;
IncrementalObjectIterator it = new IncrementalObjectIterator(context, Identity.class, qo);
Identity workGroupObject=context.getObjectByName(Identity.class,“XYZ Owners Workgroup”);
while ( (it != null) && (it.hasNext()) ) {
recordCounter++;
Identity identity = (Identity) it.next();
identity.add(workGroupObject);
context.saveObject(identity);
if (0 == (recordCounter % 10)) {
context.commitTransaction();
context.decache();
}
}
context.commitTransaction();
context.decache();
Util.flushIterator(it);
return “Success”;
But , I should not pass the workgroup directly. Instead I have to iterate each entitlement and find the owner field and memebers . If it is a workgroup I have to add all the memebers to that workgroup.
I tried in other ways > But I am stuck how to retrieve workgroup name for each entitlement. Can someone help on this step.