cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Portal Role checking

Former Member
0 Kudos

Hi,

I have a portal role to TEST to some of my portal users.

I want to check whether the current user has the role or not using webdynpro.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vinod..

I have used the code u given...But i have specified role name instead of ID....ID is different from Role? Where can i get this unique id of the role

Former Member
0 Kudos

Prasanthi,

A role is identified using its unique id. you can see this in the User Administration of portal where select the search criteria as Role and type the role name and on enter you will find its details.

Here you can find the role name, role unique id ( starts with pcd:) and role unique name ( starts with * ROLE.PCD_ROLE_PERSISTENCE.xxxxxxxx*).

Hope you understand and My Ans is right!.

Regards

Vinod

Answers (3)

Answers (3)

Former Member
0 Kudos

Use this code

This one finds all the users assigned to a role. Specify the unique role id and that will find the current user has the role or not.

try {

com.sap.security.api.IRoleFactory factory = UMFactory.getRoleFactory();

com.sap.security.api.IRole role = factory.getRole( "<Role unique id>");

java.util.Iterator itr = role.getMembers( true);

while( itr.hasNext())

{

if( UMFactory.getUserFactory().getUser( itr.next().toString()).getUniqueName()

.equals( WDClientUser.getCurrentUser().getSAPUser().getUniqueName()))

{

wdComponentAPI.getMessageManager().reportSuccess( "Current user is assigned with role");

}else{ wdComponentAPI.getMessageManager().reportSuccess( "Current user is not assigned with role");

}

}

} catch (UMException e) {

// TODO Auto-generated catch block wdComponentAPI.getMessageManager().reportException( e.getMessage(), true);

e.printStackTrace();

} catch (WDUMException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

regards

Vinod

Former Member
0 Kudos

chk these related links:

I am sure these will help you.

Regards,

Arun.

Former Member
0 Kudos

Hi,

Did you mean that, you have a role assigned to some of the portal users and you want to list those users?

Regards

Vinod V