Forum Stats

  • 3,782,440 Users
  • 2,254,645 Discussions
  • 7,880,078 Comments

Discussions

How can I get users or groups from one role

668596
668596 Member Posts: 48
edited Jan 2, 2009 12:07PM in WebLogic Portal
I resolve get roles by API(Authorization.getRoles),but I want to get users or groups from one role!
maybe business need one method get this result.
if you know please tell me information,thank you very much!

Edited by: Fish yu on 2008-12-29 下午10:12
Tagged:

Answers

  • 667822
    667822 Member Posts: 36
    Fish,

    If I understand correctly, you want to enumerate the members (Users and Groups) of a Role and you cannot find the API to do that.

    What you are trying to do is not supported by the API. The reason is that Role membership is intended to be dynamic. It can change at any moment - it can be based on the time of day, a value in the user's profile, etc. Therefore, to enumerate the list of users in a Role at a given point in time, the server would need to iterate across the entire list of users and determine if each was a member of the Role. This would be horribly inefficient.

    If your role is based on static membership lists, the best approach is to create a Group and assign all of the users to that Group. Then, create a Role that simply includes that Group. Enumerating the members of a Group is supported.

    If you still feel you need to to enumerate the users in a Role, you could build a persistent cache of users in that Role. Whenever a user logs in, check to see if the current user is in that Role. If so, add them to a database table you have created. Then you can use that list to enumerate the users. This list would not be in sync with the actual role mapper, but perhaps that's good enough for your case.

    Peter
This discussion has been closed.