| Author |
Retrieving the user group the portal user belongs too
|
|
|
| I have used request.getRemoteUser to determine the portal username, but I also want to find out what usergroup the portal user belongs too. I have create two portal user groups Farmer and FarmerAdmin, besides the standard ones. How do I retrieve this in
formation.
| |
|
| > I have used request.getRemoteUser to determine the
> portal username, but I also want to find out what
> usergroup the portal user belongs too. I have create
> two portal user groups Farmer and FarmerAdmin,
> besides the standard ones. How do I retrieve this
> information.
I dont know where are you trying to get this user name but I have done a similar thing in a custom themes default.jsp. I used the com.ibm.wps.puma.UserManager and com.ibm.wps.puma.Group for that.
Here is my code snippet.
UserManager userMngr = UserManager.instance();
//System.out.println("got userMngr " + userMngr);
try {
com.ibm.wps.puma.User u = userMngr.findById("uid="+userId+",o=Default Organization");
System.out.println("got user " + u.getId());
java.util.List groups = u.getGroups();
//System.out.println("got groups " + groups);
for (int i=0; i<groups.size(); i++) {
com.ibm.wps.puma.Group group = (com.ibm.wps.puma.Group)groups.get(i);
//System.out.println("found group = " + group.getName());
if ("webmasters".equals(group.getName())) isWebMaster = true;
if ("wpsadmins".equals(group.getName())) isAdmin = true;
}
Hope this helps.
Sachin
| |
|
| How have you retrieved the userid? I'm still having problems getting hold of the portal user.
| |
|
| Hi Kibla
Try this wps tag
<wps:user attribute="userID"/>
I have used this and the code I posted above and it works perfectly for me.
And if this doesnt help....explain your problem in detail.
Sachin
|
|
|
|