WebSphere Portal Server - How can I take info of the user which Loged to the Portal?

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > May 2006 > How can I take info of the user which Loged to the Portal?





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 How can I take info of the user which Loged to the Portal?
Ramazan Pekin

2006-05-01, 2:17 pm

I want to take the info of the user which loged to portal. How can I make
this?


Charles Le Gallic

2006-05-02, 7:19 am

Hi,

Depends on your WPS version, you can use :

<b>- WPS 5.0.x : PUMA API (undocumented and deprecated in WPS 5.1.x)</b>
<pre>import com.ibm.portal.puma.User;
User user = request.getUser();
String name = user.getUserName();</pre>
See also this <a href="http://www-128.ibm.com/developerworks/forums/dw_thread.jsp?message=13722715&cat=9&thread=83099&treeDisplayType=threadmode1&forum=168#13722715">thread</a>

<b>- WPS 5.1.X : PUMA SPI (documented)</b>
http://publib.boulder.ibm.com/infoc...ps/wpspuma.html
I don't know if you can use it inside a Theme

Regards,

Charles Le Gallic
SQLI Toulouse
Ramazan Pekin

2006-05-02, 7:19 am

Hi, I have forgotten to specify I am developing jsr168 portlet. Because of
that I cant use Portal Server API, I have tried like that:

public void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException {
response.setContentType(request.getResponseContentType());
PrintWriter printWriter = response.getWriter();
Map userInfo = (Map)request.getAttribute(RenderRequest.USER_INFO);
printWriter.println(userInfo.isEmpty());

PortletRequestDispatcher rd =
getPortletContext(). getRequestDispatcher(getJspFilePath(requ
est, VIEW_JSP));
rd.include(request,response);
}

bu this time userInfo coming as empty. Why it can be? Do I have to change
any thing in web.xml? I am using rad6, and Websphere Portal 5.1

"Charles Le Gallic" <clegallic@sqli.com> wrote in message
news:1534489546.1146559762277.JavaMail.wassrvr@ltsgwas007.sby.ibm.com...
> Hi,
>
> Depends on your WPS version, you can use :
>
> <b>- WPS 5.0.x : PUMA API (undocumented and deprecated in WPS 5.1.x)</b>
> <pre>import com.ibm.portal.puma.User;
> User user = request.getUser();
> String name = user.getUserName();</pre>
> See also this <a
> href="http://www-128.ibm.com/developerworks/forums/dw_thread.jsp?message=13722715&cat=9&thread=83099&treeDisplayType=threadmode1&forum=168#13722715">thread</a>
>
> <b>- WPS 5.1.X : PUMA SPI (documented)</b>
> http://publib.boulder.ibm.com/infoc...ps/wpspuma.html
> I don't know if you can use it inside a Theme
>
> Regards,
>
> Charles Le Gallic
> SQLI Toulouse



Charles Le Gallic

2006-05-02, 7:19 am

Try the PUMA SPI (see the link above, there is a sample code).
It's JSR168 compliant (even if the SPI is specific to WPS).

Regards,

Charles Le Gallic
SQLI Toulouse
Erik Pronk

2006-05-02, 7:19 am

Try this:

Retrieve PUMA Profile, like this.

PortletServiceHome psh = null;
PumaProfile pumaProfile = null;

try {
Context ctx = new javax.naming.InitialContext();
psh = (PortletServiceHome) ctx.lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome");

if (psh != null) {
PumaHome service = (PumaHome) psh.getPortletService(PumaHome.class);
pumaProfile = service.getProfile(PortletRequest);
}
} catch (javax.naming.NameNotFoundException ex) {
logger.error("Error loading PUMA profile ", ex);

return null;
} catch (javax.naming.NamingException ex) {
logger.error("Error loading PUMA profile ", ex);

return null;
} catch (PortletServiceUnavailableException ex) {
logger.error("Error loading PUMA profile ", ex);

return null;
}

return pumaProfile;


Get user from pumaprofile, like this:

try {

com.ibm.portal.puma.User user = (com.ibm.portal.puma.User) pumaProfile.getCurrentUser();
user.getCommonName();


Goodluck
Ramazan Pekin

2006-05-02, 1:22 pm

Thanks for your help,
Is there any other way getting user information? I cant use ibm specific
classes. I am using jsr 168 api and the code have to work on any other
portal server.
Thanks again.


Charles Le Gallic

2006-05-02, 1:22 pm

Check this <a href="http://www-1.ibm.com/support/docview.wss?rs=688&context=SSHRKX&dc=DB520&uid=swg21214772&loc=en_US&cs=UTF-8&lang=en">technote </a>.

It seems that the USER_INFO is supported, but you have to check several things before.

Regards,

Charles Le Gallic
SQLI Toulouse
Ramazan Pekin

2006-05-03, 7:16 am

I can take the user information only this way:
PrintWriter printWriter = response.getWriter();
com.ibm.portal.puma.User user =
(com.ibm.portal.puma.User)request.getAttribute("com.ibm.portal.puma.request-user");
String UserLogin = user.getFullName();
printWriter.println(UserLogin);

I cant configure for USER_INFO
Map userInfo = (Map)request.getAttribute(RenderRequest.USER_INFO);
printWriter.println(userInfo.isEmpty());
it is still returning as empty.

For now, we will use first one. If I can configure it, I will use
USER_INFO. Thanks for your helps.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com