IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
Topic
  • 9 replies
  • Latest Post - ‏2018-07-24T09:33:38Z by Bhushan1
dgowda01
dgowda01
32 Posts

Pinned topic Return attributes from custom RMI adapter

‏2013-08-26T21:39:45Z | adapter custom rmi tdi

ITIM: 5.1 TDI 7.1

We are writing a custom RMI adapter for an application. For each account created, the target returns a unique number (which obviously ITIM is not aware of during create time). This is also a required field for account modification. The adapter works fine if there was a recon between the account creation and the next modify request. But fails when we try to modify a newly created account. The target is a webservice with 1000s of accounts and running frequent recons  during business hours is not an option.

We explored the option of sending the value back to ITIM upon account creation, but if the return object contains a attribute/value ITIM just ignores that attibute/value and never picks up the 'replacement value' sent by the RMI adapter (so sending a blank string to the adapter and getting the value from adapter during account add didn't work).

Is there a way to address this issue?

  • dgowda01
    dgowda01
    32 Posts
    ACCEPTED ANSWER

    Re: Return attributes from custom RMI adapter

    ‏2013-09-16T16:05:38Z  

    I finally got this adapter to work as required. Here's an excerpt from the adapter developer's guide:

    // Setting Lookup Entry that will be passed to Lookup Connector
    var lookupEntry = system.newEntry();
    lookupEntry.newAttribute("erLdapServiceGroup");
    lookupEntry.setAttribute("erLdapServiceGroup",groupName);
    lookupEntry.newAttribute("objectclass");
    lookupEntry.setAttribute("objectclass","erLdapGroupAccount");
    // Calling Group connector in lookup mode
    conLDAPGroupLookup.lookup(lookupEntry);
    // Copying all the attributes from lookup entry to retrun entry
    var retWorkAttribute = "";
    var returnAttributes = lookupEntry.getAttributeNames();
    for (i=0; i<returnAttributes.length; i++) {
    var retLookupAttr = lookupEntry.getAttribute(returnAttributes[i]);
    var lookupAttrName = retLookupAttr.getName();
    work.newAttribute(lookupAttrName);
    var name = work.getAttributeNames();
    retWorkAttribute = work.getAttribute(lookupAttrName);
    for (j=0;j<retLookupAttr.size();j++ ) {
    retWorkAttribute.addValue(retLookupAttr.getValue(j));
    retWorkAttribute.setOper(Packages.com.ibm.di.entry.Attribute.ATTRIBUTE_ADD);
    retWorkAttribute.setValueOper(j,Packages.com.ibm.di.entry.AttributeValue.AV_ADD);
    }
    }
    // Setting status in work entry
    work.setProperty( Packages.com.ibm.di.dispatcher.Defs.STATUSCODE,
    new Packages.java.lang.Integer(Packages.com.ibm.itim.remoteservices.provider.Status.SUCCESSFUL));

    The key here is the whole of lookupEntry is being written back to work (with operation). What I was doing, wrong, was adding only the 'target generated attribute' to the return work object. This works fine during modify. But during add, we must return the whole work object.

     

    Thanks to all for pitching in with help.

  • franzw
    franzw
    519 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-08-27T06:06:48Z  

    I think you are on the right track - and yes this is absolutely possible.

    Of course the attribute must exist in the profile - but I assume that this is ok. Your problem is probably that you did not set the ValueOp - see the TDI API doc http://www.stephen-swann.co.uk/javadoc/tdi7.0/com/ibm/di/entry/Attribute.html

    HTH

    Regards

    Franz Wolfhagen

  • dgowda01
    dgowda01
    32 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-08-28T14:30:01Z  
    • franzw
    • ‏2013-08-27T06:06:48Z

    I think you are on the right track - and yes this is absolutely possible.

    Of course the attribute must exist in the profile - but I assume that this is ok. Your problem is probably that you did not set the ValueOp - see the TDI API doc http://www.stephen-swann.co.uk/javadoc/tdi7.0/com/ibm/di/entry/Attribute.html

    HTH

    Regards

    Franz Wolfhagen

    I put the below code snippet before setting work properties to success:

    var uidNumber = work.newAttribute("uidNumber");
    uidNumber.setOperation("add");
    uidNumber.addValue(spmlResponse.getString("uidNumber"),com.ibm.di.entry.AttributeValue.AV_ADD);

    The good news is ITIM is getting the object, but throwing a LDAP error 32. If I omit the second line, the operation completes successfully, but the uidNumber is not picked up. What am I doing wrong? Can you pls post an example code snippet for the right way of doing it?

  • franzw
    franzw
    519 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-08-28T20:47:46Z  
    • dgowda01
    • ‏2013-08-28T14:30:01Z

    I put the below code snippet before setting work properties to success:

    var uidNumber = work.newAttribute("uidNumber");
    uidNumber.setOperation("add");
    uidNumber.addValue(spmlResponse.getString("uidNumber"),com.ibm.di.entry.AttributeValue.AV_ADD);

    The good news is ITIM is getting the object, but throwing a LDAP error 32. If I omit the second line, the operation completes successfully, but the uidNumber is not picked up. What am I doing wrong? Can you pls post an example code snippet for the right way of doing it?

    What does the ldap log tell you (ibmslapd.log if TDS ?

    You may consider getting some help from support - unless you have setup your schema wrong the code looks right to me...

    HTH

    Regards

    Franz Wolfhagen

  • dgowda01
    dgowda01
    32 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-08-28T21:22:54Z  
    • franzw
    • ‏2013-08-28T20:47:46Z

    What does the ldap log tell you (ibmslapd.log if TDS ?

    You may consider getting some help from support - unless you have setup your schema wrong the code looks right to me...

    HTH

    Regards

    Franz Wolfhagen

    I have raised a PMR with IBM and waiting for an official answer.

    In the meanwhile, I bumped logging in ITIM for component 'com.ibm.itim.dataservices.ldap' to DEBUG_MAX and did some testing (this time with group add). What I observed was interesting: ITIM receives the 'replaced value' from TDI along with the returned object, ITIM tries to modify the group object to add the returned attribute (which is still only in the ITIM memory) and LDAP is, rightly so, throwing a not found exception (LDAP error 32).

    I'll update the thread when I hear back from IBM. Any inputs/thoughts in the interim are welcome.
    Updated on 2013-08-28T21:24:16Z at 2013-08-28T21:24:16Z by dgowda01
  • franzw
    franzw
    519 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-08-29T05:48:29Z  
    • dgowda01
    • ‏2013-08-28T21:22:54Z

    I have raised a PMR with IBM and waiting for an official answer.

    In the meanwhile, I bumped logging in ITIM for component 'com.ibm.itim.dataservices.ldap' to DEBUG_MAX and did some testing (this time with group add). What I observed was interesting: ITIM receives the 'replaced value' from TDI along with the returned object, ITIM tries to modify the group object to add the returned attribute (which is still only in the ITIM memory) and LDAP is, rightly so, throwing a not found exception (LDAP error 32).

    I'll update the thread when I hear back from IBM. Any inputs/thoughts in the interim are welcome.

    It is really difficult to debug without having access to your data system :-)

    But this sounds like the OP codes are not set correctly - be aware that there are opcodes on both the attribute level and attribute value level.

    So if you attribute is modified (a new attribute value added)  this is different from the attribute being replaced by a set of values.

    This is a little difficult to explain - but if you look at the ldif format http://www.zytrax.com/books/ldap/ch8/ or dsmlv2 protocol you should hopefully be able to understand what I mean...

    HTH

    Regards

    Franz Wolfhagen

  • TiborB
    TiborB
    20 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-08-29T09:41:34Z  
    • franzw
    • ‏2013-08-29T05:48:29Z

    It is really difficult to debug without having access to your data system :-)

    But this sounds like the OP codes are not set correctly - be aware that there are opcodes on both the attribute level and attribute value level.

    So if you attribute is modified (a new attribute value added)  this is different from the attribute being replaced by a set of values.

    This is a little difficult to explain - but if you look at the ldif format http://www.zytrax.com/books/ldap/ch8/ or dsmlv2 protocol you should hopefully be able to understand what I mean...

    HTH

    Regards

    Franz Wolfhagen

    This is just to confirm retuning attributes from add is working fine for me with the following code snippet:

    var eruid = work.getString("eruid");
    work.removeAllAttributes();

    /* ... */
     
    work
    .setAttribute("foo", "bar");
    work.getAttribute("foo").setOper
    (Packages.com.ibm.di.entry.Attribute.ATTRIBUTE_ADD);
    work.getAttribute("foo").setVa lueOper(0, Packages.com.ibm.di.entry.AttributeValue.AV_ADD);
     
    work
    .setProperty(Packages.com.ibm.di.dispatcher.Defs.STATUSCODE, new Packages.java.lang.Integer(
        Packages.com.ibm.itim.remoteservices.provider.Status.SUCCESSFUL));

    This is almost the same as you snippet, and I assume all other attributes and properties have been properly set in you AL... Try to minimise/simplify the testcase, I have not experienced LDAP error 32. I found logger.trace.com.ibm.itim.remoteservices.level=DEBUG_MAX to be more helpful as opposed to dataservices.ldap.

    Hope this helps,

       T

    Updated on 2013-08-29T09:43:07Z at 2013-08-29T09:43:07Z by TiborB
  • dgowda01
    dgowda01
    32 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-09-16T16:05:38Z  

    I finally got this adapter to work as required. Here's an excerpt from the adapter developer's guide:

    // Setting Lookup Entry that will be passed to Lookup Connector
    var lookupEntry = system.newEntry();
    lookupEntry.newAttribute("erLdapServiceGroup");
    lookupEntry.setAttribute("erLdapServiceGroup",groupName);
    lookupEntry.newAttribute("objectclass");
    lookupEntry.setAttribute("objectclass","erLdapGroupAccount");
    // Calling Group connector in lookup mode
    conLDAPGroupLookup.lookup(lookupEntry);
    // Copying all the attributes from lookup entry to retrun entry
    var retWorkAttribute = "";
    var returnAttributes = lookupEntry.getAttributeNames();
    for (i=0; i<returnAttributes.length; i++) {
    var retLookupAttr = lookupEntry.getAttribute(returnAttributes[i]);
    var lookupAttrName = retLookupAttr.getName();
    work.newAttribute(lookupAttrName);
    var name = work.getAttributeNames();
    retWorkAttribute = work.getAttribute(lookupAttrName);
    for (j=0;j<retLookupAttr.size();j++ ) {
    retWorkAttribute.addValue(retLookupAttr.getValue(j));
    retWorkAttribute.setOper(Packages.com.ibm.di.entry.Attribute.ATTRIBUTE_ADD);
    retWorkAttribute.setValueOper(j,Packages.com.ibm.di.entry.AttributeValue.AV_ADD);
    }
    }
    // Setting status in work entry
    work.setProperty( Packages.com.ibm.di.dispatcher.Defs.STATUSCODE,
    new Packages.java.lang.Integer(Packages.com.ibm.itim.remoteservices.provider.Status.SUCCESSFUL));

    The key here is the whole of lookupEntry is being written back to work (with operation). What I was doing, wrong, was adding only the 'target generated attribute' to the return work object. This works fine during modify. But during add, we must return the whole work object.

     

    Thanks to all for pitching in with help.

  • franzw
    franzw
    519 Posts

    Re: Return attributes from custom RMI adapter

    ‏2013-09-16T17:01:50Z  
    • dgowda01
    • ‏2013-09-16T16:05:38Z

    I finally got this adapter to work as required. Here's an excerpt from the adapter developer's guide:

    // Setting Lookup Entry that will be passed to Lookup Connector
    var lookupEntry = system.newEntry();
    lookupEntry.newAttribute("erLdapServiceGroup");
    lookupEntry.setAttribute("erLdapServiceGroup",groupName);
    lookupEntry.newAttribute("objectclass");
    lookupEntry.setAttribute("objectclass","erLdapGroupAccount");
    // Calling Group connector in lookup mode
    conLDAPGroupLookup.lookup(lookupEntry);
    // Copying all the attributes from lookup entry to retrun entry
    var retWorkAttribute = "";
    var returnAttributes = lookupEntry.getAttributeNames();
    for (i=0; i<returnAttributes.length; i++) {
    var retLookupAttr = lookupEntry.getAttribute(returnAttributes[i]);
    var lookupAttrName = retLookupAttr.getName();
    work.newAttribute(lookupAttrName);
    var name = work.getAttributeNames();
    retWorkAttribute = work.getAttribute(lookupAttrName);
    for (j=0;j<retLookupAttr.size();j++ ) {
    retWorkAttribute.addValue(retLookupAttr.getValue(j));
    retWorkAttribute.setOper(Packages.com.ibm.di.entry.Attribute.ATTRIBUTE_ADD);
    retWorkAttribute.setValueOper(j,Packages.com.ibm.di.entry.AttributeValue.AV_ADD);
    }
    }
    // Setting status in work entry
    work.setProperty( Packages.com.ibm.di.dispatcher.Defs.STATUSCODE,
    new Packages.java.lang.Integer(Packages.com.ibm.itim.remoteservices.provider.Status.SUCCESSFUL));

    The key here is the whole of lookupEntry is being written back to work (with operation). What I was doing, wrong, was adding only the 'target generated attribute' to the return work object. This works fine during modify. But during add, we must return the whole work object.

     

    Thanks to all for pitching in with help.

    And thanks for the good feedback with the actual solution !!

    Regards

    Franz Wolfhagen

  • Bhushan1
    Bhushan1
    2 Posts

    Re: Return attributes from custom RMI adapter

    ‏2018-07-24T09:33:38Z  

    Hi,

    I want to achieve same in case of Modify operation. I tried above but its not working. Can anyone please provide any pointers? 

    Updated on 2018-07-24T11:54:58Z at 2018-07-24T11:54:58Z by Bhushan1