This content has been marked as final.
Show 5 replies
-
1. Re: Add group with ES2 Java API
Jasmin Charbonneau Mar 19, 2010 5:05 AM (in response to Paul_Kuhn)Can you put the code?
The link just goes to the main documentation page.
Jasmin
-
2. Re: Add group with ES2 Java API
Chetan Mehrotra Mar 19, 2010 5:15 AM (in response to Jasmin Charbonneau)Following code snippet should work for you
public String createSampleGroup() throws UMException{
String groupOid = checkGroupExist(groupName);
if(groupOid != null){
return groupOid;
}
String groupCanonicalName = groupName;
GroupImpl group = new GroupImpl();
group.setCanonicalName(groupCanonicalName);
group.setDomainName(domainName);
group.setGroupType(Group.GROUPTYPE_PRINCIPALS);
group.setLocal(true);
group.setPrincipalType(Principal.PRINCIPALTYPE_GROUP);
groupOid = directoryManager.createLocalGroup(group);
log("Sample group created with name %s",groupName);
return groupOid;
}
/**
* Search the groupwith the given name in the sample domain
*/
private String checkGroupExist(String groupName) throws UMException{
PrincipalSearchFilter psf = new PrincipalSearchFilter();
psf.setCommonName(groupName);
psf.setSpecificDomainName(domainName);
//By default the filter causes like search unless you are using the absolute version
//Setting this ensures that search is exact
psf.setMatchExactCriteria(true);
//By default search returns obsolete users also. Set this to ensure that
//only active users are returned
psf.setRetrieveOnlyActive();
//PrincipalReference are lightweight user objects and searching for them would be more performant
//compared to the User search. If you do not require any other user attribute then prefer this
//mode of search
List<PrincipalReference> result = directoryManager.findPrincipalReferences(psf);
if(result.isEmpty()){
log("Sample group with name [%s] does not exist",groupName);
return null;
}else{
String oid = result.get(0).getOid();
log("Sample group with name [%s] already exist",groupName);
return oid;
}
} -
3. Re: Add group with ES2 Java API
Paul_Kuhn Mar 19, 2010 6:26 AM (in response to Chetan Mehrotra)Thanks a lot for the code, Chetan. It works great!
In my initial post I meant the Java class provided here:
http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=002477.html#157 6978
This code does not work, so it should be replaced by your working code ;-)
Thanks again.
Paul
-
4. Re: Add group with ES2 Java API
Chetan Mehrotra Mar 19, 2010 6:39 AM (in response to Paul_Kuhn)I would be following up with the doc team to get that corrected
-
5. Re: Add group with ES2 Java API
smacdonald2008 Apr 29, 2010 1:09 PM (in response to Paul_Kuhn)The Quick Start in Programming with LiveCycle ES2 has been updated to use this application logic



