Thanks for confirming - it is a pleasure to help out....
Just a general comment - removing accents/diacritics is a one way function - there is no good way AFAIK to reverse process - so from an architectural PoV this is a dangerous operation as you cannot get back to the original data. So such conversions should be used with care and only where there is not a need of getting the data back....
Original Message:
Sent: Wed October 09, 2024 04:13 AM
From: Paul van den Brink
Subject: SDI Assembly Line how to remove diacritics from a string
Hi Franz,
Yes, this is what I was looking for.
It works!
TAL
Regards,
Paul
------------------------------
Paul van den Brink
Original Message:
Sent: Tue October 08, 2024 09:06 AM
From: Franz Wolfhagen
Subject: SDI Assembly Line how to remove diacritics from a string
I do not think the IBMJS JavaScript engine implements the string.normalize(). Instead you can use the Java Normalize class :
//var givenName = "orčpžsíáýd";var givenName = work.getString("givenName");givenNameClean = java.text.Normalizer.normalize(givenName, java.text.Normalizer.Form.NFD).replaceAll("\\p{M}", "");task.logmsg("givenName : " + givenName);task.logmsg("givenNameClean : " + givenNameClean);
When receiving a string from a work attribute use the getString() method - that is simpler but be aware that in the case of multiple values it only returns the first value as a string.
HTH - and let the SDI questions coming :-)
------------------------------
Franz Wolfhagen
WW IAM Solution Engineer - Certified Consulting IT Specialist
IBM Security Expert Labs
Original Message:
Sent: Tue October 08, 2024 08:14 AM
From: Paul van den Brink
Subject: SDI Assembly Line how to remove diacritics from a string
Hi,
I am using SDI with an assemblyline to sync AD accounts to an SDS ldap, which is used by Security Verify Access.
The source AD record has a givenName attribute which contains diacritics, I want to put this givenName value in the CN attribute of the record in SDS ldap but without the diacritics.
On the web I found the following function:
function Convert(string){
return string.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
}
I've implemented this function in my asseblyline:
var givenName = "" + work.givenName;
var givenNameClean = Convert(givenName);
This results in an error:
java.lang.Exception: Error calling method 'normalize(string)' on an object of type 'String [JavaScript Object]'
at com.ibm.di.script.ScriptEngine.unWrap(ScriptEngine.java:977)
at com.ibm.di.script.ScriptEngine.interpret(ScriptEngine.java:942)
at com.ibm.di.script.ScriptEngine.interpret(ScriptEngine.java:925)
at com.ibm.di.server.AttributeMapping$SingleAttributeMap.eval(AttributeMapping.java:729)
at com.ibm.di.server.AttributeMapping.mapAttribute(AttributeMapping.java:281)
at com.ibm.di.server.AttributeMapping.mapEntry(AttributeMapping.java:510)
at com.ibm.di.server.AttributeMapping.mapEntry(AttributeMapping.java:361)
at com.ibm.di.server.AssemblyLineComponent.modify(AssemblyLineComponent.java:1818)
at com.ibm.di.server.AssemblyLineComponent.update(AssemblyLineComponent.java:1761)
at com.ibm.di.server.AssemblyLine.msExecuteNextConnector(AssemblyLine.java:3833)
at com.ibm.di.server.AssemblyLine.executeMainStep(AssemblyLine.java:3429)
at com.ibm.di.server.AssemblyLine.executeMainLoop(AssemblyLine.java:3026)
at com.ibm.di.server.AssemblyLine.executeMainLoop(AssemblyLine.java:3009)
at com.ibm.di.server.AssemblyLine.executeAL(AssemblyLine.java:2975)
at com.ibm.di.server.AssemblyLine.run(AssemblyLine.java:1338)
I there a way to make this work?
Any idea is welcome.
Thanks in advance,
Paul
------------------------------
Paul van den Brink
------------------------------