Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to update a multivalued attribute using JNDI Connector in SDI?

173 views
Skip to first unread message

DIVYA RAIBAGKAR

unread,
Aug 6, 2021, 10:17:55 AM8/6/21
to
I have a custom attribute on user profile which is multi-valued and stores data in Binary Data. The syntax in LDAP for attribute is Binary - octet string (1.3.6.1.4.1.1466.115.121.1.5) .

I am unable to push new values from JNDI connector to update this attribute.

var json= system.newAttribute("customAttributeName");

Approach 1 :
var role = new com.ibm.json.java.OrderedJSONObject();
roleJSON.put("role","test-role");
roleJSON.put("country","India");
var access= new com.ibm.json.java.JSONObject();
access.put("Sample",roleJSON);

json.addValue(access);

Issue : No value is being sent in ISIM request, the attribute is marked for NO CHANGE.


Approach 2 :
var role = new com.ibm.json.java.OrderedJSONObject();
roleJSON.put("role","test-role");
roleJSON.put("country","India");
var access= new com.ibm.json.java.JSONObject();
access.put("Sample",roleJSON);

json.addValue(access.toString());

Issue : The attribute is being updated but the request has Object type value [B@d468185d and in LDAP the value is set to garbage value.

If anybody could assist me how can I handle updating such attribute from JNDI connector?

Thanks
Divya

Eddie Hartman

unread,
Aug 9, 2021, 6:46:51 AM8/9/21
to
It looks to me that you are trying to write JSON values to your attribute. There is a much simpler way to do this:

role = { role: "test-role", country: "india" };
jsonStr = toJson(role);

However, you say your attribute is multi-valued and binary (OctetString). To encode a string value you could use code like this:

enc = new com.ibm.asn1.BEREncoder();
enc.encodeOctetString(jsonStr.getBytes());
byteValue = enc.toByteArray();

You could add this as a value to an attribute (att.addValue()) and then write this using the JNDI Connector. Note that you have additional methods available in this Connector Interface to work with values of an attribute, like:

https://www.stephen-swann.co.uk/javadoc/tdi7.0/com/ibm/di/connector/JNDIConnector.html#addAttributeValue(java.lang.String,%20java.lang.String,%20java.lang.String)
https://www.stephen-swann.co.uk/javadoc/tdi7.0/com/ibm/di/connector/JNDIConnector.html#removeAttributeValue(java.lang.String,%20java.lang.String,%20java.lang.String)

and

https://www.stephen-swann.co.uk/javadoc/tdi7.0/com/ibm/di/connector/JNDIConnector.html#replaceAttributeValue(java.lang.String,%20java.lang.String,%20java.lang.String)

Maybe I am not understanding what you are trying to achieve. I'd be happy to get online and look at this with you.

/Eddie

DIVYA RAIBAGKAR

unread,
Aug 9, 2021, 8:27:35 AM8/9/21
to
Hi Eddie,
Thanks for the reply.

The reason I am using OrderedJSONObject is that the values are going to be dynamic and varies per person entity. And I have to preserve the Order in which the data is entered.

I am using TDI 7.2 where the BEREncoder is part of com.ibm.ldap.bp.asn1 package but doesn't have encodeOctetString method.

My end goal id to update the custom attribute as per business logic via JNDI connector.

Could you please tell me which JAR needs to added to classpath for this script ? As there is no much information about com.ibm.asn1 Package

Thanks
Divya

DIVYA RAIBAGKAR

unread,
Aug 11, 2021, 7:11:02 AM8/11/21
to
Hi Eddie,

As per your suggestion I tried to update the value as follows :
//create the JSON
role = { role: "test-role", country: "india" };
jsonStr = toJson(role);
//get Byte Array
enc = new com.ibm.ldap.bp.asn1.BEREncoder()//new Packages.com.ibm.asn1.BEREncoder();
enc.encodeOctetString(jsonStr.getBytes());
byteValue = enc.toByteArray();

var json= system.newAttribute("customAttributeName");
##ATTEMPT 1 try to set value as ByteArray , I get TDI exception while submitting the request using JNDI :: com.ibm.dsml2.jndi.MalformedResponseException: Illegal Text data found as child of: H1 value: "Error Page Exception"
json.addValue(byteValue);
work.setAttribute(json);

##ATTEMPT 2 try to set jsonStr as it is in request. The request gets submitted to ISIM but the value set on user is encoded/garbage such as [B@ac9b7670
json.addValue(jsonStr)
work.setAttribute(json);

##ATTEMPT 3 try to set the JavaScript object as it is. Tries to map the value as 'Object:[object Object]' and doesn't get pushed to ISIM'
json.addValue(role);
work.setAttribute(json);

Nothing seem to be working for updating this custom attribute though JNDI connector.
Could you please help !!?

Eddie Hartman

unread,
Aug 11, 2021, 3:10:44 PM8/11/21
to
Note that the simplest solution using toJson() also behaves in the same way each time (at least this is my experience), and so I have never used BEREncoder().

Like I said before, we could do a screen share if you like and look at this together. I can see you are comfortable scripting. This means that you should be able to use the JNDIConnector.addAttributeValue() or .replaceAttributeValue() calls from your AL script. I use the corresponding calls in the extension class, the LDAPConnector, to handle massive multi-valued attribute updating most efficiently (like for group membership).

/Eddie

Franzw

unread,
Aug 12, 2021, 2:27:39 AM8/12/21
to
I am wondering why you are using the JNDI Connector - could you explain why you are doing this ?
If you working from some sample (JAVA) code show it - that may give a lot of needed information to solve your problem.
Also if you could point to a public website describing the API you are truing to use that woulkd also help.

Regards
Franz Wolfhagen
0 new messages