Avatar

Not applicable

1. Create a DirectoryManagerServiceClient Instance as follows,

    Properties connectionProps = new Properties();
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, userName);
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, password);

 

    //Create a ServiceClientFactory object
   ServiceClientFactory scf = ServiceClientFactory.createInstance(connectionProps);
 

   //Create a DirectoryManagerServiceClient object
   DirectoryManagerServiceClient directoryManager = new DirectoryManagerServiceClient(scf);

2. Create a local group as follows,


   Group group = UMBaseLibrary.createGroup(groupCanonicalName, domainName, PrincipalTypes.PRINCIPALTYPE_GROUP);
   String groupOid = directoryManager.createLocalGroup(group);

 

   You can also create the above group by going to User Manager AdminUI. i.e. Home  > Settings > User Management > Users and Groups

3. Once done with creating a group, now we want to make the 950 users members of this group
   The API to be used is directoryManager.addPrincipalToLocalGroup(String userOid, String groupOid);


4. You'll have to run the above API for all the 950 users.
   So, fetch the userOid through PrincipalSearchFilter based on some matching critera as follows, let say emailAddress


       PrincipalSearchFilter filter = new PrincipalSearchFilter();
       filter.setPrincipalType(User.PRINCIPALTYPE_USER);
       filter.setRetrieveOnlyActive(true);
       filter.setEmail(Email_address_OfUser_To_be_Searched);
       List principals = (ArrayList)directoryManager.findPrincipals(filter);
       for(Principal principal:principals){
          User user = (User)principal;
          directoryManager.addPrincipalToLocalGroup(user.getOid(), groupOid);
       }