on 06-17-2005 3:46 PM
Hi,
Can I access user roles by using the following code and if so, then how do I retrieve the role information from the iterator.
//This is code for getting Username and role.
IWDClientUser user1 = WDClientUser.forceLoggedInClientUser();
IUser user2 = user1.getSAPUser();
try{
if (user2 != null) { IUserAccount[] acct = user2.getUserAccounts();
if(acct[0] != null)
{
String strUserid = acct[0].getLogonUid();
wdComponentAPI.getMessageManager().reportSuccess("name"+strUserid);
Iterator it = acct[0].getRoles(true);
}
}
}
catch (UMException e) {
wdComponentAPI.getMessageManager().reportSuccess(e.toString());
}
Thanks,
Jay
Hi
This should help you.
//Get Role Information
if (it.hasNext()) {
IRoleFactory rfact = UMFactory.getRoleFactory();
while (it.hasNext()) {
String roleName = (String) it.next();
IRole role = null;
try {
role = rfact.getRole(roleName);
wdComponentAPI.getMessageManager().reportSuccess("Role:" + roleName
+ "Display Name:" + role.getDisplayName()
+ "ID: " + role.getUniqueID()
+ "Uniquename: " + role.getUniqueName()
+ "Description: " + role.getDescription());
} catch (UMException e) {
wdComponentAPI.getMessageManager.reportException("error: " + e.getLocalizedMessage(),true);
}
}
}
regards
ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Ravi's code gives all the details.
Thanks
Jay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi AnilKumar,
Your code gives me the roles assigned, but not the description. I get the result as :
ROLE.PCD_ROLE_PERSISTENCE.VvlvkEGjiW9zPFaxR/4pd2/bX5Q=
How can i get the description for the roles
Thanks
Jay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this
Iterator it=user.getSAPUser().getRoles(true);
while(it.hasNext())
{
String role=it.next().toString();
}
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Santhosh,
I did not get the list of roles assigned. I program execution did not enter the while loop.
Is the call to getRoles() function incorrect?
Iterator it = acct[0].getRoles(true);
The UserID is displayed fine and I have six roles assigned to my userID
Thanks,
Jay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jay,
Write the following piece of code below the "Iterator it" statement
while(it.hasNext()){
IRole role = (IRole)it.next();
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("role::"+role);
}
Regards,
Santhosh.C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.