Wednesday, June 10, 2009

How to get WCM/WP User Info in WCM

Create a JSP component with the following code:

<%@page import="java.util.*, java.security.*,
java.io.*, java.net.*,
java.text.*, javax.servlet.http.*"%>

<%
Principal userPrincipal = (Principal) request.getSession().getAttribute("wcm_session_user");
com.ibm.portal.puma.User pumauser = (com.ibm.portal.puma.User) userPrincipal;
String givenName = (String) pumauser.getGivenName();
String familyName = (String) pumauser.getFamilyName();
if (givenName == null) givenName = "";
if (familyName == null) familyName = "";
out.print(givenName + " " + familyName);
%>

Source: http://www.ibmportal.com/viewtopic.php?id=420

1 comment:

rifaccio said...

is it possible to use Puma API and an jsp page to execute a login in a site?
I 've a need to create a login for a site in WCM in order to show some content on registered user and some other to nono logged.

thanks