WebSphere Portal Server - Retrieving the user group the portal user belongs too

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > December 2005 > Retrieving the user group the portal user belongs too





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Retrieving the user group the portal user belongs too

2005-12-07, 8:02 am

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.

2005-12-07, 5:59 pm

> 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

2005-12-14, 7:50 am

How have you retrieved the userid? I'm still having problems getting hold of the portal user.

2005-12-14, 5:59 pm

Hi Kibla

Try this wps tag
&lt;wps:user attribute="userID"/&gt;
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

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com