<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><mapping><o:p></o:p></p>
<p class="MsoNormal">        <name>Generate Login Name from CSV</name><o:p></o:p></p>
<p class="MsoNormal">        <source><o:p></o:p></p>
<p class="MsoNormal">            <c:path>$focus/givenName</c:path><o:p></o:p></p>
<p class="MsoNormal">        </source><o:p></o:p></p>
<p class="MsoNormal">        <source><o:p></o:p></p>
<p class="MsoNormal">            <c:path>$focus/familyName</c:path><o:p></o:p></p>
<p class="MsoNormal">        </source><o:p></o:p></p>
<p class="MsoNormal">        <source><o:p></o:p></p>
<p class="MsoNormal">            <c:path>$focus/additionalName</c:path><o:p></o:p></p>
<p class="MsoNormal">        </source><o:p></o:p></p>
<p class="MsoNormal">        <expression><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><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"><o:p></o:p></p>
<p class="MsoNormal">                <language>http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</language><o:p></o:p></p>
<p class="MsoNormal">                <code><o:p></o:p></p>
<p class="MsoNormal">                     def givenNameStr = ''+givenName<o:p></o:p></p>
<p class="MsoNormal">                     def familyNameStr = ''+familyName<o:p></o:p></p>
<p class="MsoNormal">                     def additionalNameStr = ''+additionalName<o:p></o:p></p>
<p class="MsoNormal">                     <o:p></o:p></p>
<p class="MsoNormal">                     if (iteration == 0 &amp; additionalName != null) {<o:p></o:p></p>
<p class="MsoNormal">                     return (givenNameStr.substring(0,1) + '' + additionalNameStr.substring(0,1) + '' + familyNameStr.substring(0, Math.min(familyNameStr.length(),5))) + iterationToken;<o:p></o:p></p>
<p class="MsoNormal">                       } <o:p></o:p></p>
<p class="MsoNormal">                     else if (iteration == 0 &amp; additionalName == null) {<o:p></o:p></p>
<p class="MsoNormal">                        return (givenNameStr.substring(0,1) + '' + givenNameStr.substring(0,1) + '' + familyNameStr.substring(0, Math.min(familyNameStr.length(),5))) + iterationToken;<o:p></o:p></p>
<p class="MsoNormal">                        <o:p></o:p></p>
<p class="MsoNormal">                     }<o:p></o:p></p>
<p class="MsoNormal">                     else if (iteration &gt; 10 &amp; familyNameStr.length() &gt; 5 &amp; additionalName == null) {<o:p></o:p></p>
<p class="MsoNormal">                     return (givenNameStr.substring(0,1) + '' + givenNameStr.substring(0,1) + '' + familyNameStr.substring(0, Math.min(familyNameStr.length(),4))) + iterationToken;<o:p></o:p></p>
<p class="MsoNormal">                     }<o:p></o:p></p>
<p class="MsoNormal">                     else if (iteration &gt; 10 &amp; familyNameStr.length() &gt; 5 &amp; additionalName == null) {<o:p></o:p></p>
<p class="MsoNormal">                     return (givenNameStr.substring(0,1) + '' + givenNameStr.substring(0,1) + '' + familyNameStr.substring(0, 4)) + iterationToken;<o:p></o:p></p>
<p class="MsoNormal">                     }<o:p></o:p></p>
<p class="MsoNormal">                     <o:p></o:p></p>
<p class="MsoNormal">                     else {<o:p></o:p></p>
<p class="MsoNormal">                     return "";<o:p></o:p></p>
<p class="MsoNormal">                     }<o:p></o:p></p>
<p class="MsoNormal">                </code><o:p></o:p></p>
<p class="MsoNormal">            </script><o:p></o:p></p>
<p class="MsoNormal">        </expression><o:p></o:p></p>
<p class="MsoNormal">        <target><o:p></o:p></p>
<p class="MsoNormal">            <c:path>$focus/extension/ccxLoginName</c:path><o:p></o:p></p>
<p class="MsoNormal">        </target><o:p></o:p></p>
<p class="MsoNormal">    </mapping><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">But when the iteration reaches the 10<sup>th</sup> 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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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<b> JJohns10</b>,
 instead I’m getting <b>JJohnso10</b>.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any ideas how to accomplish this?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#002060">Daniel</span></b><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<hr size="2" width="100%" align="center">
<span style="font-size:7.5pt;font-family:"Arial",sans-serif;color:gray">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.
</span>
</body>
</html>