[midPoint] Set maximum character limit for username + iteration

Macias, Daniel Daniel.Macias at carecentrix.com
Wed Oct 21 22:23:36 CEST 2020


Hello,

I trying to set a maximum amount of characters for the username in AD to 8 due to the limitations of other apps that use the same attribute value. When constructing the username in the Object Template from CSV feed using First Name, Last Name, and, if available, Middle Name, I have the following mapping;

<mapping>
        <name>Generate Login Name from CSV</name>
        <source>
            <c:path>$focus/givenName</c:path>
        </source>
        <source>
            <c:path>$focus/familyName</c:path>
        </source>
        <source>
            <c:path>$focus/additionalName</c:path>
        </source>
        <expression>
<script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"xsi:type="c:ScriptExpressionEvaluatorType">
                <language>http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</language>
                <code>
                     def givenNameStr = ''+givenName
                     def familyNameStr = ''+familyName
                     def additionalNameStr = ''+additionalName

                     if (iteration == 0 & additionalName != null) {
                     return (givenNameStr.substring(0,1) + '' + additionalNameStr.substring(0,1) + '' + familyNameStr.substring(0, Math.min(familyNameStr.length(),5))) + iterationToken;
                       }
                     else if (iteration == 0 & additionalName == null) {
                        return (givenNameStr.substring(0,1) + '' + givenNameStr.substring(0,1) + '' + familyNameStr.substring(0, Math.min(familyNameStr.length(),5))) + iterationToken;

                     }
                     else if (iteration > 10 & familyNameStr.length() > 5 & additionalName == null) {
                     return (givenNameStr.substring(0,1) + '' + givenNameStr.substring(0,1) + '' + familyNameStr.substring(0, Math.min(familyNameStr.length(),4))) + iterationToken;
                     }
                     else if (iteration > 10 & familyNameStr.length() > 5 & additionalName == null) {
                     return (givenNameStr.substring(0,1) + '' + givenNameStr.substring(0,1) + '' + familyNameStr.substring(0, 4)) + iterationToken;
                     }

                     else {
                     return "";
                     }
                </code>
            </script>
        </expression>
        <target>
            <c:path>$focus/extension/ccxLoginName</c:path>
        </target>
    </mapping>

In other words, I'm using the first name initial + the middle name initial (if available, if not, then the first name initial will be used) + the first 6 letters of the last name (if it has more than 6 characters) +  iteration; when there's no iteration, the username will not have a number at the end.

But when the iteration reaches the 10th iteration, I'd like to cut down the last name to a max of 5 characters so the username will have a total of 8 characters.

The mapping above is working but it ignores the max, is simply ignored. The username is created with 6 characters + iteration. For example, John J. Johnson, if username value already exists 10 times, the should be constructed as JJohns10, instead I'm getting JJohnso10.

Any ideas how to accomplish this?

Thanks in advance,

Daniel

________________________________
This communication is intended only for the use of the individual or entity named as the addressee. It may contain information that is privileged and/or confidential under applicable law. If you are not the intended recipient or such recipient's employee or agent, you are hereby notified that any dissemination, copy or disclosure of this communication is strictly prohibited. If you have received this communication in error, please immediately notify CareCentrix Compliance Hot Line at (877) 848-8229 and notify the sender by electronic mail. Please delete this communication without making any copies. Thank you for your cooperation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201021/5128a151/attachment.htm>


More information about the midPoint mailing list