Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to determine the User Group/Role of the logged user in jsp

85 views
Skip to first unread message

ash...@pscindia.com

unread,
Jul 9, 2004, 3:32:20 AM7/9/04
to
I have successfully installed the websphere portal server 5.0 and also created user group, users successfully.Now, i want to display some images in the JSP on the basis of usergroup of logged in user.For e.g if the user is wpsadmin the image should show up and if it belongs to my created group it must not.
Can anyone help ? Thanks in advance

paul_...@uk.ibm.com

unread,
Jul 9, 2004, 5:20:29 AM7/9/04
to

You shouldn't use groups in the application level code.  Instead you look at the J2EE Roles.  (They are mapped to security groups at deployment time, so the result is the same).
The call you want is "isUserInRole("role name")".  I can't remember where it is, probably HTTPSession,  but it might be on the request object.

sanjayagrey

unread,
Jul 9, 2004, 8:14:11 AM7/9/04
to
Import following in your jsp.
<%@ page import='com.ibm.portal.puma.User'%>
<%@ page import='com.ibm.portal.puma.Group'%>
<%@ page import='org.apache.jetspeed.portlet.*' %>

& then

PortletRequest req = (PortletRequest)pageContext.getRequest();
com.ibm.portal.puma.User usr = (com.ibm.portal.puma.User)req.getUser();
String test = usr.getFullName();
out.println(test+"<br>");
UserManager um = UserManager.instance();
List groups = usr.getNestedGroups();
for (int i=0; i<groups.size() ; i++){
Group grp = (Group)groups.get(i);
out.println(grp.getName()+"<br>");
}

to determine the groups

Thanks
Sanjay

sanjayagrey

unread,
Jul 9, 2004, 8:16:40 AM7/9/04
to
page import='com.ibm.portal.puma.User
page import='com.ibm.portal.puma.Group
page import='com.ibm.wps.puma.UserManager
page import='org.apache.jetspeed.portlet.*'

Justin Rosenberg

unread,
Jul 9, 2004, 11:34:14 AM7/9/04
to
Thise solution works, however it does use the Depricated Puma API.
Just be aware.

The full API can be found at
http://www-1.ibm.com/support/docview.wss?rs=688&context=SSHRKX&q1=puma&uid=swg27003745&loc=en_US&cs=utf-8&lang=en+en
IBM Login ID is required.

Good coding,

Justin

0 new messages