cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch all the users belonging to a particular portal group

Former Member
0 Kudos

Hello Experts,

Can anyone tell me how to fetch all the users belonging to a particular portal group. I managed to fetch all the groups assigned to a user by using following code

IUser uid = UMFactory.getUserFactory().getUserByLogonID(Userid);
		
			Iterator groups =  uid.getParentGroups(false);
		
			while (groups.hasNext())	
			{    
				String str_grpname = (String)groups.next();
				IGroup Group = UMFactory.getGroupFactory().getGroup(str_grpname);
				if(Group.getUniqueName().startsWith("CPC"))
				{
					ary_groups.add(Group.getUniqueName());
				}
			}

But i am not able to fetch all users in a particular group. any help is appreciated.

Thanks,

Virag

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Virag,

Below is the code snippet to fetch all the users belonging to a portal group,


try {
IGroupFactory iGroupFactory = UMFactory.getGroupFactory();
IGroupSearchFilter groupFilter = iGroupFactory .getGroupSearchFilter();
groupFilter.setDisplayName("Group display name", ISearchAttribute.LIKE_OPERATOR, false);
ISearchResult result = iGroupFactory.searchGroups(groupFilter);
IGroup group = null;
while(result.hasNext()){
group = iGroupFactory.getGroup(result.next().toString());
}
if(group != null){
Iterator userSet = group.getUserMembers(true);
while(userSet.hasNext()){
String userId = userSet.next().toString();
IUser user = UMFactory.getUserFactory().getUser(userId);			
}
}		
}
catch (UMException umException) {
wdComponentAPI.getMessageManager().reportException("Exception Details: "+umException.toString());		
}

Using IUser you can fetch user details.

Regards,

Vishweshwara P.K.M.

Former Member
0 Kudos

Hi Virag,

Please see if the following code satisfies your requirement:

IGroup userGroup = UMFactory.getGroupFactory().getGroup("<Unique ID of Group>");
Iterator itGrpUsers = userGroup.getUserMembers(true);

You can refer to the following link on IGroup API for more details:

[http://help.sap.com/javadocs/NW04S/SPS09/se/com/sap/security/api/IGroup.html#getUserMembers(boolean)]

Regards,

Pavithra

Former Member
0 Kudos

Hi,

I came across this [article|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b09cc7ef-8185-2b10-4aaa-96ffc93d237c] for searching the user availablitiy in a selected group.

Think this can help you to some extent..

In UME, you can perform a search based on User / Role / Group.

So, I think you can achieve this...

Regards,

Vijay.