Discussion:
Whitespace in ldap attributes
(too old to reply)
rpuggal
2018-04-11 15:44:39 UTC
Permalink
Raw Message
Hello , we found an issue with a customer system where some attributes ended up with trailing whitespaces or whitespaces in the middle of the attributes which was not intended and causing some issues. Is there a way in TDI to figure out all such attributes and trim all whitespaces using the trim function to write the entries back and fix them ?

We are using ISDS Virtual appliance as the directory store and there doesn't seem to be a way to idnetify such attributes via ldapsearches or at least none that I could figure out.
yn2000
2018-04-11 17:52:39 UTC
Permalink
Raw Message
First of all, I assumed that the attribute contains some data already.
Second, you cannot just rename an attribute, because in the DB2 backend engine, there is a table representing that attribute, so that it takes dropping a table and recreating another table to rename an attribute; but then, what about the data inside that old table?
So, if I were you, especially with a non-flexible Virtual Appliance device, the safe bet would be to build a new ISDS appliance with the correct attribute and use TDI to migrate the data with some attribute mapping.
Rgds. YN.
Eddie Hartman
2018-04-12 20:34:30 UTC
Permalink
Raw Message
You could iterate thru the ldap, checking all string attributes (work,getObject(attName) instanceof Sjava.lang.String) for whitespace, then if found trimming the value(s) and modifying that attribue. You can do this uaing the LDAPConnector method replaceAttribute(). I may have a script snippet lying around somewhere that was used to do this - if I can find it 😀
Eddie Hartman
2018-04-13 10:16:20 UTC
Permalink
Raw Message
Post by Eddie Hartman
You could iterate thru the ldap, checking all string attributes (work,getObject(attName) instanceof Sjava.lang.String) for whitespace, then if found trimming the value(s) and modifying that attribue. You can do this uaing the LDAPConnector method replaceAttribute(). I may have a script snippet lying around somewhere that was used to do this - if I can find it 😀
Ok, so first you have to have an Iterator reading through your directory. You could put this code in the After Initialize Hook of that Connector in order to store a reference to the underlying LDAPConnector CI (Connector Interface) used for the Iterator:

ldapConnector = thisConnector.connector;

Then in the DataFlow section you have a script like this:

dn = work.getString("$dn");
for (attribute in work) {
// Get Attribute Name
attName = attribute.getName();
// Loop through all values
for (value in attribute) {
// If of type String then trim and see if it makes a difference
if (typeof(value).equals("string")) {
trimmed = value.trim();
if (trimmed.length != value.length) {
// Remove the old value and add the trimmed one
ldapConnector.removeAttributeValue(dn, attName, value);
ldapConnector.addAttributeValue(dn, attName, trimmed);
}
}
}
}

Hope this helps!
rpuggal
2018-04-13 21:04:18 UTC
Permalink
Raw Message
Thanks so much Eddie and YN for the responses. Eddie your approach is exactly what I was thinking I just didn't know how to do it in TDI exaclty. Thanks for the script. Will try it out and see how it works for me !
yn2000
2018-04-16 20:55:55 UTC
Permalink
Raw Message
Wait a sec...
Eddie was talking about the value of an attribute, while I was talking about the attribute itself, driven from these words "...trailing whitespaces or whitespaces in the middle of the attributes..."
For example: { "candyFlavor": "LemonMint" }
YN: whitespaces in the middle of the attribute is 'candy Flavor'
EH: whitespaces in the middle of the value of an attribute is 'Lemon Mint'
Rgds. YN.

Loading...