Add currently logged in user to another group using PUMA SPI - Websphere

This is a discussion on Add currently logged in user to another group using PUMA SPI - Websphere ; I want to add my currently logged in user to another group using PUMA SPI. I am able to do this using "addToGroup()" method of puma controller if my user is an administrator. My code is as follows : PumaHome ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Add currently logged in user to another group using PUMA SPI

  1. Add currently logged in user to another group using PUMA SPI

    I want to add my currently logged in user to another group using PUMA SPI. I am able to do this using "addToGroup()" method of puma controller if my user is an administrator.



    My code is as follows :

    PumaHome psh = null ;

    javax.naming.Context ctx;
    try
    {
    ctx = new javax.naming.InitialContext();
    PortletServiceHome pumahome = (PortletServiceHome)ctx.lookup( "portletservice/com.ibm.portal.um.portletservice.PumaHome" );
    if (pumahome != null )
    {
    psh = (PumaHome) pumahome.getPortletService(PumaHome.class);
    }

    PumaProfile pp = psh.getProfile();
    PumaLocator pLocator=psh.getLocator();
    PumaController pumaController = psh.getController();

    List newUser = pLocator.findUsersByAttribute( "uid" , user);

    User strUser = (User) newUser.get(0);

    List groupList = (List) pLocator.findGroupsByAttribute( "cn" , "Creditor" );

     
    Group group = (Group)groupList.get(0);

    System.out.println( "group identified" + group);

    List list = new ArrayList();
     
    list.add(strUser);

    pumaController.addToGroup(group, list);




    (here user is the value which passed from my screen to the method)



    But I want to do it through an authenticated portal user. Is it possible??



    Also if my user group changes, I want to reload my portal page with newly added group access rights?



    Thanks in advance !!!!!

  2. Re: Add currently logged in user to another group using PUMA SPI

    you can set it up so that just regular users can modify the groups



    either give all authenticated users, access rights to the Virtual Resource user_groups OR instead of calling pumahome call pumaadminhome which does not do a portal access control check.



    (Virtual resources are just a type of resource that you can assign in resource permissions, you can see this on the second page of it, )



    Now that all being said, the Portal Access Control for a user is only loaded at login time, and to get the page to reload you will have to log out and log back in so it builds the acl again



    Jim





    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: Add currently logged in user to another group using PUMA SPI

    Hi Jim,


    I am getting similar issue and I tried your solution of using PumaAdminHome.

    But if I use following code I get following exception. Any idea?

    Error:
    javax.faces.el.EvaluationException: java.lang.IllegalStateException: *PortalAdminHome* is not enabled
    at com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:79)
    ------------------
    calling addToGroup:


    PumaController pumaController = getPumaAdminHomeService().getController();
    pumaController.addToGroup(aGroup, aPrincipal);
    --------------
    Function that I am calling for addToGroup:


    private PumaAdminHome getPumaAdminHomeService() throws AppException {
    try {
    javax.naming.Context ctx = new javax.naming.InitialContext();
    PumaAdminHome pumaAdminHome = (PumaAdminHome) ctx
    .lookup(PumaAdminHome.JNDI_NAME);
    return pumaAdminHome;
    } catch (NamingException e) {
    AppConfigurationException configException = new AppConfigurationException(
    "Unable to reach service" + PumaAdminHome.JNDI_NAME, e);
    throw configException;
    }
    }
    -------------------

  4. Re: Add currently logged in user to another group using PUMA SPI

    WP PumaService

    Add following custom properties

    Name: *enablePumaAdminHome* Value: *true*

    PumaAdminHome works after enabling above settings in Puma service!

    Regards,
    Mahendra Shelar

  5. Re: Add currently logged in user to another group using PUMA SPI

    Hi mahendra,
    I am getting the same issue as "PortalAdminHome is not enabled" in the following code


    if(Log.isDebugEnabled()) Log.debug(className + "getInstance(): Entered");
    Context ctx = new InitialContext();
    if(Log.isDebugEnabled()) Log.debug(className + "getInstance(): Created Initial Context"+ctx);
    PumaAdminHome adminHome = (PumaAdminHome) ctx.lookup(PumaAdminHome.JNDI_NAME);
    if(Log.isDebugEnabled()) Log.debug(className + "getInstance(): Created PumaAdminHome"+adminHome);
    if(Log.isDebugEnabled()) Log.debug(className + "getInstance(): Created PumaAdminHome"+adminHome.getController());
    if(Log.isDebugEnabled()) Log.debug(className + "getInstance(): Created PumaAdminHome"+adminHome.getLocator());
    return new PumaServices(adminHome);


    I tried your solution, but still not able to resolve it. I am using wps 6.1 server. In appserver console i did the following change
    Resource->ResourceEnvironmentProviders, I created a new resource provider as WP PumaService with custom property
    Name: *enablePumaAdminHome* Value: *true*

    Is what i did is correct? What else should i do to resolve this problem. Is there any other changes\settings needed to be done? Please guide me.

+ Reply to Thread