I want to show all users who are in groups and what role they have.
Now I can list all the users with "//account", all the groups with "//group" or all roles with "//role".
This is how I get all users/groups/roles:
propEnum[] props = new propEnum[] {
propEnum.searchPath, propEnum.defaultName,};
sort[] s = new sort[] { new sort() };
s[0].order = orderEnum.ascending;
s[0].propName = propEnum.defaultName;
queryOptions queryOptions = new queryOptions();
StringBuilder output = new StringBuilder();
// Look for all the users.
output.AppendFormat("\nUsers:\n");
searchPathMultipleObject userPath = new searchPathMultipleObject();
userPath.Value = "//account";
baseClass[] bc = cBICMS.query(userPath, props, s, queryOptions);
if (bc.Length > 0)
{
foreach (baseClass report_item in bc)
{
output.AppendFormat("DefaultName: {0}\n", report_item.defaultName.value);
output.AppendFormat("SearchPath: {0}\n", report_item.searchPath.value);
}
}
If I want to show groups instead of users I need just to change userPath.Value = "//group";
or .."//role";
for roles.
Has anyone an idea?
I've figured it out how to show the users in the group.
http://www-01.ibm.com/support/docview.wss?uid=swg21335459 here is a good description with an example in C# and Java.
I have added "propEnum.members, propEnum.objectClass" to "propEnum[] props" because in ".members" are the user names of the group.
propEnum[] props = new propEnum[] {
propEnum.searchPath, propEnum.defaultName, propEnum.members, propEnum.objectClass};
I have changed the userPath.Value to "//group" to search for groups.
searchPathMultipleObject userPath = new searchPathMultipleObject();
userPath.Value = "//group";
Then I have changed my function a little bit:
if (bc.Length > 0)
{
for(int i = 0; i < bc.Length; i++)
{
string x = bc[i].objectClass.value.ToString();
if (bc[i].objectClass.value.ToString().Equals("group"))
{
group gp = (group)bc[i];
baseClass[] members = gp.members.value;
if(members != null && members.Length > 0)
{
for(int j = 0; j < members.Length; j++)
{
output.AppendFormat("Members: {0}\n", gp.members.value[j].searchPath.value);
output.AppendFormat("DefaultName: {0}\n\n", gp.defaultName.value);
}
}
}
}
}