This webservice coding returns you all roles for a certain user:
package getRolesForUser; import javax.ejb.SessionBean; import javax.ejb.SessionContext; import javax.ejb.CreateException; import com.sap.security.api.IRole; import com.sap.security.api.IRoleFactory; import com.sap.security.api.IUser; import com.sap.security.api.UMFactory; import java.util.ArrayList; import java.util.Iterator; /** * @ejbHome <{getRolesForUser.GetRolesForUserHome}> * @ejbLocal <{getRolesForUser.GetRolesForUserLocal}> * @ejbLocalHome <{getRolesForUser.GetRolesForUserLocalHome}> * @ejbRemote <{getRolesForUser.GetRolesForUser}> * @stateless * @transactionType Container */ public class GetRolesForUserBean implements SessionBean { public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { } public void setSessionContext(SessionContext context) { myContext = context; } private SessionContext myContext; /** * Business Method. */ public String[] getPortalRolesForUser(String userGID) throws Exception{ // create array list ArrayList RoleList = new ArrayList(); String UniqueID = new String(); try { // get roles of user Iterator rit = null; IUser user = UMFactory.getUserFactory().getUserByLogonID(userGID); rit = user.getRoles(true); IRoleFactory rfact = UMFactory.getRoleFactory(); //adding roles of user to the array list while (rit.hasNext()) { String roleName = (String) rit.next(); IRole role = rfact.getRole(roleName); UniqueID = role.getUniqueID(); RoleList.add(UniqueID); } // create new array of data type string with the corresponding size String[] returnList = new String[RoleList.size()]; // move ArrayList into the created array RoleList.toArray(returnList); // return the portal roles of the user return returnList; } // throw exception if an error occurs catch (Exception e) { throw new Exception(e); } } /** * Create Method. */ public void ejbCreate() throws CreateException { // TODO : Implement } }