Is it possible to create a LC user group and batch add users to the group?
Example: I have ~120,000 users in my domain but I want only 950 of those users to have access to a new form we will be going live with soon. To do this I want to create a group for this form but I don't want to have to manually add the 950 users to the group.
~Josh
Views
Replies
Total Likes
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);
}
Views
Replies
Total Likes
Hi Amit,
I would like to do samething in this post but my environment is running on WebSphere 6.1. Can you please assist with one for Websphere with more details as well.
Thanks,
Han Dao
Views
Replies
Total Likes
Hi Han,
In this post all that is variable is the creation of a ServiceClientFactory instance, which varies as per the Application Server.
Please go through the following link,
Hope this helps.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies