cancel
Showing results for 
Search instead for 
Did you mean: 

All Groups in Portal

former_member187444
Participant
0 Kudos

Hi Friends;

I want to get all groups in portal using security api. how can i handle this?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Eray,

please check the below code, you will get groups in drop down.

model = new DefaultListModel();

IGroupFactory groupFactory = UMFactory.getGroupFactory();

IGroupSearchFilter filter = groupFactory.getGroupSearchFilter();

ISearchResult result = groupFactory.searchGroups(filter);

IGroup group=null;

model.addItem("", "Select a Group");

model.setSingleSelection(true);

while (result.hasNext()) {

group = groupFactory.getGroup(result.next().toString());

model.addItem(""+group.getUniqueID(), group.getDescription());

}

model.setSelection(group.getDescription());

regards

Anil Dichpally

former_member187444
Participant
0 Kudos

Hi Anil;

Thanks For your reply, I found another but yours is nice than mine...

I write secondary code

String AllGroups = "";
		try {
			com.sap.security.api.IGroupFactory grpFact =
				UMFactory.getGroupFactory();
			IGroupSearchFilter grpFilt = grpFact.getGroupSearchFilter();
			grpFilt.setDisplayName("*", ISearchAttribute.LIKE_OPERATOR, false);

			ISearchResult result = grpFact.searchGroups(grpFilt);
			if (result.getState() == ISearchResult.SEARCH_RESULT_OK) {
				while (result.hasNext()) {
					String guniqId = (String) result.next();
					IGroup thisGroup = grpFact.getGroup(guniqId);
					IGroup grp = UMFactory.getGroupFactory().getGroup(guniqId);
					String name = thisGroup.getDisplayName();
					if(!AllGroups.equals("")){
						AllGroups = AllGroups+","+name;
					}
					else{
						AllGroups = name;
					}
				}
			}
			return (AllGroups.split(","));
		} catch (Exception ex) {
			ex.printStackTrace();
			
		}
		return null;

Answers (0)