cancel
Showing results for 
Search instead for 
Did you mean: 

Authorization in Webdynpro applications?

Former Member
0 Kudos

Hi,

I read about How to manage authorization in Webdynpros. It talks about the hasPermission method, which is linked to actions, which is further linked to Roles.

Is there any direct method which can be used to access the Role of the current user which can later be used to restrict the Visibility of certain UI Elements in the Webdynpro application.

Can the method "isMemberOfRole" be of any significant use?

Regards

Meesum

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Meesum

If you want the authorization for the individual UI elements , You need to go with Java permissions.

For getting all the Roles of the logged in user, Use

UMFactory.getRoleFactory()..

Regards

NagaKishore V

Former Member
0 Kudos

Hi Meesum,

You can make use of following

user.getSAPUser().isMemberOfGroup();

Example :

IWDClientUser user = WDClientUser.getCurrentUser();

IUser userID = user.getSAPUser();

String Userrole=new String();

for (Iterator iter = userID.getRoles(true); iter.hasNext();) {

IRole role = UMFactory.getRoleFactory().getRole((String) iter.next());

Userrole=role.getUniqueName();

}

if(Userrole.equalsIgnoreCase("Administrator"))

// TO DO

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Former Member
0 Kudos

Hi,

I am also trying to get some unique userid from the logged in user.

'IWDClientUser user = WDClientUser.getCurrentUser();' works, but IUser, IRole and UMFactory can not be resolved.

Even 'Organize Imports' does not help.

And when I try to import com.sap.security.api.IUser manually, I get an error message during build which tells me that the classes could not be found and that I should fix my build path.

Can anyone tell me what to import etc. to get Developer Studio to resolve IUser, IRole and UMFactory?

Former Member
0 Kudos

I found the solution myself:

The only thing I had to do was to add 'C:\Program Files\SAP\JDT\eclipse\plugins\com.sap.security\lib\com.sap.security.api.jar' to my build path.

Former Member
0 Kudos

hi

you can get the userid of the logged in user and his role from webdynpro using the following code

IUser user = request.getUser();

Iterator roles = user.getRoles(true);

while (roles.hasNext()) {

try {

String uniqueID = roles.next().toString();

IRole userRole = UMFactory.getRoleFactory().getRole(uniqueID);

if(userRole.getDisplayName().equalsIgnoreCase("elearningclient"))

response.write("Role is :"+userRole.getDisplayName());

} catch (Exception e) {

response.write(""+e);

}