BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Get user attribute from LDAP by mail

    Posted 05/12/23 06:31 PM

    Hi!
    I would like to ask, how can I retrieve, for example, a user's name and surname from LDAP using an email address? I use the VMMUtil.jar class, but this class is able to retrieve any attribute provided that I enter userName.And I don't have a username. I only have his email address. Will you help? I am attaching the class I am using. Maybe I have an outdated version.



    ------------------------------
    Lukas Davis
    ------------------------------


  • 2.  RE: Get user attribute from LDAP by mail

    Posted 05/12/23 06:38 PM
      |   view attached

    Attached class



    ------------------------------
    Lukas Davis
    ------------------------------

    Attachment(s)

    jar
    VMMUtil.jar   11 KB 1 version


  • 3.  RE: Get user attribute from LDAP by mail

    Posted 05/15/23 01:55 AM

    Hi Lukas,

    where did you get this .jar file from?
    Right now, it does not support your use case, but you can enhance the Java code to do so. 



    ------------------------------
    Jens Engelke
    ------------------------------



  • 4.  RE: Get user attribute from LDAP by mail

    Posted 11 days ago

    Hi @Jens Engelke - that VMMUtil.jar has the same name, structure, and classes as the VMMUtil.jar that former IBMer Ryan Cox built his VMM_LDAP_Toolkit on top of.

    Sadly, Ryan's code has not been maintained .. and not even accessible. I do have a copy (for posterity's sake), but it's not something I feel comfortable releasing into the wild.
    Fortunately, the 2 most commonly requested attributes (phone and email) are now retrievable by the BAW 22.0.1 "users_sync" Swagger/Ops REST resource:

    image
    I also wonder where @Lukas Davis got his copy from 🤔


    ------------------------------
    Brad Konopik
    ------------------------------



  • 5.  RE: Get user attribute from LDAP by mail

    Posted 10 days ago
    Edited by Sebastian Tylko 10 days ago

    If you are on traditional WAS  - WIM/VMM  API is still available but specific attributes might depend on your configuration. You don't need any jars – as you can use this API directly from server side script  like below:

    -------------------

    if (tw.local.email  && tw.local.email.length > 0)
    {
    var service =  new com.ibm.websphere.wim.client.LocalServiceProvider();
    var root = service.createRootDataObject();
    var sc = root.createDataObject("controls",  "http://www.ibm.com/websphere/wim", "SearchControl" );
        sc.set("expression",  "@xsi:type='PersonAccount' and mail='"+tw.local.email+"'" );
        sc.set( "countLimit",  new java.lang.Integer(1) );
        sc.getList("properties").add("uid");
        sc.getList("properties").add("mail");
        sc.getList("properties").add("displayName");
    var result = service.search(root);
    var entities = result.getList("entities");
     if (entities.size()==1) {
         var entity = entities.get(0);
         if (entity)
              tw.local.login= entity.get("uid");
              var displayNameList = entity.get("displayName");
              tw.local.fullName= displayNameList.isEmpty() ? null : displayNameList.get(0);
     }   
    }

    -------------------

    Please note that  IBM is discouraging us from using Java from JavaScript (status: deprecated) -  but on tWAS it is  the simplest way to achieve what you want.



    ------------------------------
    Sebastian Tylko
    ------------------------------