Skip to Content
avatar image
Former Member

check group of the login user using IGroup

try{
	Iterator rit = null;
IWDClientUser clientUser = WDClientUser.getCurrentUser();

IUser user = clientUser.getSAPUser();
rit = user.getRoles(true);
String post=new String();

IRoleFactory rfact = UMFactory.getRoleFactory();
while (rit.hasNext()) {
String roleName = (String) rit.next();
IRole role = rfact.getRole(roleName);
post=role.getDisplayName();


//this method is wrong and not dynamic
//TODO:  check the login user from which group he/she belong
if(user.isMemberOfGroup("super_admin_role",true)==true){
	 //do something
}
if(post.equalsIgnoreCase("Administrator") || post.equalsIgnoreCase("super_admin_role")){
           //do something
	}

}
	}catch(WDUMException wd){
	wd.printStackTrace();
	}catch(UMException e){
	e.printStackTrace();
	}

this code iterate the members within the Everyone group which i only what to check the specific login user group

try{
	IUserFactory myUF=UMFactory.getUserFactory();
	IGroup grp=UMFactory.getGroupFactory().getGroupByUniqueName("Everyone");
	Iterator userMembers=grp.getUserMembers(true);
	ArrayList aUser=new ArrayList();
	
	while(userMembers.hasNext()){
		String userID=(String)userMembers.next();
		IUser myUser=myUF.getUser(userID);
		aUser.add(myUser.getDisplayName());
		}
		
	}catch(Exception ex){
		ex.printStackTrace();
		}

Message was edited by:

yzme yzme

Message was edited by:

yzme yzme

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jan 18, 2007 at 06:00 AM

    ANYONE KNOW HOW TO RETRIEVE THE USER GROUP IT BELONGS TO BASED ON THE PARTICULAR LOGIN USER

    Add comment
    10|10000 characters needed characters exceeded

    • This code returns the iterator containing the user groups. Once you have called it, you have to loop this iterator while hasnext = false.

      <b> try{

      IWDClientUser clientuser = WDClientUser.getCurrentUser();

      IUser user = clientuser.getSAPUser();

      Iterator userGroups = null;

      userGroups = user.getParentGroups(true);

      }

      catch(Exception ex){

      wdThis.wdGetAPI().getComponent().getMessageManager().raiseMessage( IMessageYSP_CRM_CP_COCKPIT.USER_E , null,true);

      }</b>

      userGroups has the groups.

      Don't forget to loop the iterator in try statement.

      I Hope it can work

      Grites!