Question

I wanted to get the list which includes the all group and roles of a user in Oracle Universal Content management.

ex: If user is weblogic, Group :Administrtor Role :manager,Admin ,etc

I tried as :

Subject subject = Security.getCurrentSubject();

Set prin=subject.getPrincipals();

But got only group with this .Please provide a code snippet to do this.

Was it helpful?

Solution 2

UserData userData = (UserData)context.getCachedObject("TargetUserData"); Vector roleList = SecurityUtils.getRoleList(userData);

OTHER TIPS

Listing the members of a group is possible because a group has a defined membership list

A role is different - a role defines a set of rules that can be evaluated to determine if a user is a member. A role's membership may change on something like the day of the week.

Therefore, to get see what roles a certain user is in, you have to do a check against each role. Something like what is described here:

http://blog.watashii.com/2010/06/weblogic-portal-authorization-get-and-check-users-roles/

If you already know all of the roles (and have them in a list) you can simply iterate over the list and do:

request.isUserInRole("xxxxx")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top