Skip to Content
0
Former Member
Dec 05, 2006 at 02:23 PM

Obtaining the roles for a user

146 Views

I am trying to obtain the roles for a user OTHER than the one that is currently logged in and display them in drop down list box. Some example code where I have hard-coded the user name is as follows:

final IWDClientUser wdUser = WDClientUser.getClientUser("Purissimus");

final IUser user = wdUser.getSAPUser();

final IRoleFactory roleFactory = UMFactory.getRoleFactory();

// set up the drop attribute for the drop down list box

IWDAttributeInfo attributeInfo_Distributors = wdContext.getNodeInfo().getAttribute(IPrivateEditCountries.IContextElement.CUR_SAP_USER);

ISimpleTypeModifiable DistributorType = attributeInfo_Distributors.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet_Distributors = DistributorType.getSVServices().getModifiableSimpleValueSet();

// retrieve roles

try {

final AttributeList attrs = new AttributeList();

attrs.addAttribute( IPrincipal.DEFAULT_NAMESPACE, IPrincipal.UNIQUE_NAME );

final IRole[] roles = roleFactory.getRoles(roleFactory.getRolesOfUser(user.getUniqueID(), true ),attrs);

wdContext.currentContextElement().setSAPUserName(user.getUniqueName());

// copy roles to the listbox

for (int i = roles.length - 1; i >= 0; i-- ) {

IRole role = roles[ i ];

valueSet_Distributors.put(role.toString(),role.toString());

}

}

catch (final UMException exOnGetRoles)

{

wdComponentAPI.getMessageManager().reportException( new WDNonFatalException(exOnGetRoles), false );

}

As you can see in this example, I am trying to obtain the roles of the user "Purissimus". For some reason though, the .getRolesOfUser method always seems to return my own roles rather than those of the user I specified.

Thanks for any advice you might be able to offer

-Sheldon

Message was edited by:

Sheldon Lyttle