IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Getting user roles in portal

    Posted Thu March 08, 2007 06:25 AM

    Hi,
    We can get the current user’s name by using principalData.getUserName().
    In the same way, can we get the current user’s role? We are storing the users roles in database. The portlet content is shown according to these roles.

    So I assume, portal must be carrying the user role detail somewhere. Can we retreive that in anyway?

    Thanks and Regards,
    Ninad


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS


  • 2.  RE: Getting user roles in portal

    Posted Sat March 10, 2007 02:53 PM

    If you are customizing content based on roles then you should probably be writing skin and shell rules as well as leveraging acl’s based on role membership. Also, if you are using MWS 7.0, then you can use the Security Roles and binding expressions to show/hide controls based on role membership.

    My point is, ideally you shouldn’t have to directly query for all the user’s current roles. Maybe you could further illustrate your precise use-case and we can pursue the options.

    Regards,
    –mark


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 3.  RE: Getting user roles in portal

    Posted Sun March 11, 2007 04:00 PM

    We want a cutsom message to appear for users who dont have access to certain links. If a user who is not having rights to access a particular portal page, a message should say that ‘please contact this this for rights’.
    This is possible if we can get the current roles for the users. Is it possible to get the current role?
    Thanks and Regards,
    Ninad


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 4.  RE: Getting user roles in portal

    Posted Mon March 12, 2007 10:01 AM

    Sounds good. Part of the issue would be that if you are using MWS Permissions to decide who has access to links, then you won’t even know that those links don’t exist. So i think we might need to rethink this scenario.

    Do you want to send me an email to discuss further?
    –mark

    mark.imel@webmethods.com


    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 5.  RE: Getting user roles in portal

    Posted Tue May 01, 2007 12:06 PM

    Using 7.0, the easiest way to get Role information about a user is to use the UserModel and RoleModel classes.

    For instance, if you want the roles of the current user you would use:
    UserModel user = new UserModel();
    List roles = user.getRoleMembership();
    for (Iterator it = roles.iterator(); it.hasNext()) {
    RoleModel role = (RoleModel)it.next();
    //Do what you want with a role model
    }

    If you want to lookup a differen’t users role information, then you can set the id/alias/dn of the UserModel prior to looking up its roles.

    Note the Javadocs for these are available at: $PORTAL/doc/javaapi/wm-caf-jsf-impl/index.html

    Regards,
    –mark


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 6.  RE: Getting user roles in portal

    Posted Wed June 20, 2007 01:15 AM

    We have a requirement of giving access to particular\e users through portal code. We’r looking for a method which can set users to particalar groups in order to give the access. Can anyone help us on this topic?


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 7.  RE: Getting user roles in portal

    Posted Wed June 20, 2007 09:01 AM

    You could achieve this using following code:

    import com.webMethods.portal.bizPolicy.impl.ContextFactory;
    import com.webMethods.portal.bizPolicy.IContext;
    import com.webMethods.portal.bizPolicy.biz.IBizPolicyManager;
    import com.webMethods.portal.bizPolicy.biz.IBizPolicyNames;
    import com.webMethods.portal.bizPolicy.biz.dir.IDirServiceBizPolicy;
    import com.webMethods.portal.bizPolicy.biz.dir.IDirSystemBizPolicy;
    import com.webMethods.portal.service.dir.IDirPrincipal;
    import com.webMethods.portal.service.dir.IDirSystem;
    import com.webMethods.portal.system.PortalSystem;

    IContext context = ContextFactory.acquireContext(true);
    IBizPolicyManager bpm = (IBizPolicyManager) PortalSystem.getPortalSystem().getBizPolicyProvider();
    IDirServiceBizPolicy dirServicePolicy = (IDirServiceBizPolicy) bpm.getBizPolicy(IBizPolicyNames.DIRECTORY_SERVICE);
    IDirSystemBizPolicy dirSystemPolicy = (IDirSystemBizPolicy) bpm.getBizPolicy(IBizPolicyNames.DIRECTORY_SYSTEM);

    IDirPrincipal user = dirSystemPolicy.lookupPrincipalByID(context, “user UID”, IDirSystem.TYPE_USER);
    IDirPrincipal group = dirSystemPolicy.lookupPrincipalByID(context, “group UID”, IDirSystem.TYPE_GROUP);
    IDirPrincipal role = dirSystemPolicy.lookupPrincipalByID(context, “role name”, IDirSystem.TYPE_ROLE);

    dirServicePolicy.addPrincipalToRole(context, user.getDirectoryURI(), role.getDirectoryURI());;
    dirServicePolicy.addPrincipalToGroup(context, user.getDirectoryURI(), group.getDirectoryURI());;


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods