How to get the user logged in first name and last name fromcom.wps.puma ? - Websphere

This is a discussion on How to get the user logged in first name and last name fromcom.wps.puma ? - Websphere ; Hi, I need to get the first name and last name to be fields to be filled in automatically depending on the user logged in the portal(websphere portal 6.0). I am using the puma library. I can get the full ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: How to get the user logged in first name and last name fromcom.wps.puma ?

  1. How to get the user logged in first name and last name fromcom.wps.puma ?

    Hi,



    I need to get the first name and last name to be fields to be filled in automatically depending on the user logged in the portal(websphere portal 6.0). I am using the puma library. I can get the full name by using the user.getFullname().

    How to get the first name and last name? is there any direct methods in the library? please suggest me.



    Thanks in advance.

  2. Re: How to get the user logged in first name and last name fromcom.wps.puma ?

    you should not be using the com.wps.puma.User object, you should use the getAttributes method of the PumaProfile






    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  3. Re: How to get the user logged in first name and last name fromcom.wps.puma ?

    com.ibm.wps.puma.User user = (com.ibm.wps.puma.User)request.getAttribute("com.ibm.portal.puma.request-user");

    UserLogin = user.getFullName();



    By this, i can get the fullname. How to get the first and lastnames?

  4. Re: How to get the user logged in first name and last name fromcom.wps.puma ?

    what you are doing is internal api and SHOULD NOT be used.



    to get the attributes do the following



    you should use this

    com.ibm.portal.um.portletservice

    Interface PumaHome



    All Superinterfaces:

    com.ibm.portal.portlet.service.PortletService



    public interface PumaHome

    extends com.ibm.portal.portlet.service.PortletService



    This Interface can be used to access the UserManagement component of WebSphere Portal

    from a JSR 168 portlet. An instance can be retrieved using a JNDI lookup for the following JNDI name portletservice/com.ibm.portal.um.portletservice.PumaHome The returned instance provides a way to access the three views to the user repository

    com.ibm.portal.um.PumaProfile

    com.ibm.portal.um.PumaController

    com.ibm.portal.um.PumaLocator

    The following sample shows you how to perform the JNDI lookup



    PortletServiceHome psh;

    javax.naming.Context ctx = new javax.naming.InitialContext();

    try {

    psh = (PortletServiceHome)

    ctx.lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome");

    } catch(javax.naming.NameNotFoundException ex) {

    ... error handling ...

    }

    ...

    // use the service

    PumaHome service = (PumaHome) psh.getPortletService(PumaHome.class);


    Once you have the PumaHome you can get the pumaProfile like this



    PumaProfile pp = myHome.getProfile(request);



    then from there you can use PumaHome to get the PumaProfile, and then get the attributes you want for the current user.

    if you want to get a list of attributes you create a map like this



    USER_ATTRS = new ArrayList();

    USER_ATTRS.add("givenName");

    USER_ATTRS.add("sn");

    USER_ATTRS.add("uid");



    then you use get them via the following

    Map userMap = pp.getAttributes(pp.getCurrentUser(), USER_ATTRS);



    then you have a map of user attributes and you can do the following

    Object attrObj = userMap.get("givenName");

    if (attrObj instanceof java.util.List) {

    attrArray = (ArrayList)attrObj;

    newUser.setGivenName((String)attrArray.get(0));

    } else {

    newUser.setGivenName((String) attrObj);

    }

    attrObj = userMap.get("sn");

    if (attrObj instanceof java.util.List) {

    attrArray = (ArrayList)attrObj;

    newUser.setSn((String)attrArray.get(0));

    } else {

    newUser.setSn((String) attrObj);

    }

    attrObj = userMap.get("uid");

    if (attrObj instanceof java.util.List) {

    attrArray = (ArrayList)attrObj;

    newUser.setUid((String)attrArray.get(0));

    } else {

    newUser.setUid((String) attrObj);

    }



    and display what you want





    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0

    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0



    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

  5. Re: How to get the user logged in first name and last name fromcom.wps.puma ?

    I know this is an older post, but my question is relevant to the subject....

    How would this be different if I wanted to access a user's information via username when they are not signed in? This means that I am accessing PUMA anonymously. Would there be any extra configuration in the Websphere Portal?

    Thanks,
    Sean

  6. Re: How to get the user logged in first name and last name fromcom.wps.puma ?

    have a look at my recent blog entry at

    [http://ExtremePortal.blogspot.com]


    thanks..
    **
    *[http://ExtremePortal.blogspot.com]*

+ Reply to Thread