|
|
CDS API - GET ROLE MEMBERS
|
|
|
|
|
|
|
|
This sample Java code provides an example of how to extract user names from a role that contains both user and group members by using the Common Directory Services API.
Submitted by: Software AG, September 2011
Applicable Versions: 7.1 to 8.2.1
|
IDirectorySystem ds = DirectorySystemFactory.getDirectorySystem();
IDirectorySession session = ds.createSession();
IDirectoryRole role = (IDirectoryRole) session.lookupPrincipalByName("roleName", IDirectoryPrincipal.TYPE_ROLE);
List<IDirectoryPrincipal> members = session.getMembers(role.getID());
for (IDirectoryPrincipal member: members) {
if (member.getType() == IDirectoryPrincipal.TYPE_USER) {
// user is member of a role
String userName = member.getName();
}
else if (member.getType() == IDirectoryPrincipal.TYPE_GROUP) {
// group is member of a role
List<IDirectoryPrincipal> groupMembers = session.getMembers(member.getID());
// iterate over group members...
}
}
DirectorySystemFactory.getDirectorySystem().destroySession(s);
|
|
Description :
My webMethods Server enables you to create a role and populate it with both users and groups. In some cases, you may want to query the role to obtain all user members, including iterating through the members of an included group. You can accomplish this with the Common Directory Service (CDS) API.
For example, suppose a manager wants to search for a role and then assign a collaboration task to each member of that role. If the role consists of 3 users and 1 group of 5 users, a total of 8 collaboration tasks would be created. This sample code can be used to obtain the individual user names for each task assignment, using both the individual user names and the user names in the group.
For general information about the Common Directory Services API, see the wiki article Managing Users with the Common Directory Service API. To see the Javadocs for Common Directory Services API, go to the Software AG documentation web site.
|
|
Disclaimer :
|
|
Utilities and samples shown here are not official parts of the Software AG products. These utilities and
samples are not eligible for technical support through Software AG Customer Care.
Software AG makes no guarantees pertaining to the functionality, scalability, robustness, or degree of
testing of these utilities and samples. Customers are strongly advised to consider these utilities and samples as "working examples" from which
they should build and test their own solutions
|
|
|
|
|
|
|