cancel
Showing results for 
Search instead for 
Did you mean: 

getting all the users assinged to a Group using WDJAVA

Former Member
0 Kudos


Hi Exeperts ,

     I have a requirement in my project

1) I need to get all the users assgined to a particular Group . The Group name will be enterd from the UI Screen . We have  find out all the users present in that Group.

2) from this userlist , again I have to find out the users are that are locked by some "X" userId .

for example there is a group with name - "demogroup"  and 500 users are assinged to this group then

1) I have to find out all the 500 users assinged to this - "demogroup"

2) from this 500 user list , Again I have to find out the users that are locked by some user eg: anusha

Can anybody help me with code for this requirement .

Many Thanks

Anusha .

Accepted Solutions (0)

Answers (1)

Answers (1)

govardan_raj
Contributor
0 Kudos

first check fi the grp exist using the below method

--

boolean groupExist = false;

try

   {

 

    IGroupFactory grpFactory = UMFactory.getGroupFactory();

    IGroupSearchFilter grpfilter = grpFactory.getGroupSearchFilter();

    

    grpfilter.setSearchAttribute(IPrincipal.DEFAULT_NAMESPACE,IPrincipal.UNIQUE_NAME,groupUniqueName,ISearchAttribute.LIKE_OPERATOR, false);

    ISearchResult search = grpFactory.searchGroups(grpfilter);

//     if(search.size()==0)

//     {

//   grpfilter.setSearchAttribute(IPrincipal.DEFAULT_NAMESPACE,IPrincipal.DESCRIPTION, description,ISearchAttribute.LIKE_OPERATOR, false);

//      search = grpFactory.searchGroups(grpfilter);

//     }

    

    

    

   while (search.hasNext())

   {

    groupExist  = true;

    break;

   }

    }catch(Exception e)

   {

    handleException(e, " ");

   }finally

   {

    return groupExist;

   }

if(groupExist)
   {
  IGroupFactory grpFactory = UMFactory.getGroupFactory();

  IUserFactory usrFactory = UMFactory.getUserFactory();

  IGroupSearchFilter grpSearchFilter = grpFactory.getGroupSearchFilter();

  grpSearchFilter.setDisplayName("grpname",1,false);

  ISearchResult grpResult = grpFactory.searchGroups(grpSearchFilter);

  

  IGroup grpInd = grpFactory.getGroup("");

  Iterator iterUsers = grpInd.getUserMembers(false);

        

  //ISearchResult userList = (ISearchResult)grpInd.getUserMembers(false);

  wdContext.nodeUserList().invalidate();

  I***********************.IUserListElement userElement = wdContext.nodeUserList().createUserListElement();

  userElement.setUserId("");

  userElement.setUserDisplayName("Please select a user");

  wdContext.nodeUserList().addElement(userElement);
        
        IUser objUser = null;
        String strUserId = "";
        
  while(iterUsers.hasNext()){

  strUserId = (String) iterUsers.next();

  objUser = usrFactory.getUser(strUserId);

  userElement = wdContext.nodeUserList().createUserListElement();

  userElement.setUserId(objUser.getName());

  //userElement.setUserDisplayName(objUser.getName()"-"objUser.getDisplayName());

  wdContext.nodeUserList().addElement(userElement);

      }

   }

Regard

Govardan

Former Member
0 Kudos

Hi Govardan ,

                   

     Many Many Many thanks for your help .

Thanks

Anusha ..