<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Jason,<br>
    <br>
    the iterator (as a concept) is used anyway. (To react if the
    username is used, and try again, until maxIterations is reached).<br>
    <br>
    In your case, if you'd have two users with exactly the same
    first/lastnames, you'd need  it too (unless you are using middle
    name initial of something like that, which still can have exact
    match with another user).<br>
    <br>
    In other project, we are using <tokenExpression> as documented
    here
    <a class="moz-txt-link-freetext" href="https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO">https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO</a>
    and in this blog post:
    <a class="moz-txt-link-freetext" href="https://www.evolveum.com/provisioning-random-samaccountname-value/">https://www.evolveum.com/provisioning-random-samaccountname-value/</a><br>
    <br>
    The latter blog is dealing with unique sAMAccountName attribute
    while the DN is expected to be unique (because it's based on
    midPoint user/name which is guaranteed to be unique).<br>
    <br>
    The concept is very flexible.<br>
    <br>
    You can check our blogs for other interesting concepts too :-)<br>
    <br>
    Regards,<br>
    Ivan<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 11/20/2014 09:34 PM, Jason Everling
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFkZXY5EcyR1+M-V9A-aDeF6FLEzA5W6BZS_U1MiSSOLfAK-pQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">This is great, Thanks! I shouldn't need the
        iterator then, Our current way is flastname, filastname,
        firlastname and so on so this would be better.
        <div><br>
        </div>
        <div>JASON</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Nov 20, 2014 at 2:11 PM, Ivan
          Noris <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:ivan.noris@evolveum.com" target="_blank">ivan.noris@evolveum.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> I believe I've set
              something similar in our CSV sample:<br>
              <br>
              <a moz-do-not-send="true"
href="https://github.com/Evolveum/midpoint/raw/master/samples/resources/csvfile/localhost-csvfile-resource-advanced-nosync-2.xml"
                target="_blank">https://github.com/Evolveum/midpoint/raw/master/samples/resources/csvfile/localhost-csvfile-resource-advanced-nosync-2.xml</a><br>
              <br>
              See the comments for expression description. This was from
              our real customer setup. I see now that I'd probably use
              basic.norm(basic.stringify(...)) to get rid of diacritics.<br>
              <br>
              <outbound><br>
                <source><br>
                  <name>tmpGivenName</name><br>
                  <path>$user/givenName</path><br>
                </source><br>
                <source><br>
                  <name>tmpFamilyName</name><br>
                  <path>$user/familyName</path><br>
                </source><br>
                <expression><br>
                  <script><br>
                    <code><br>
              <!-- Generate user name:<br>
              - FamilyName + GivenName initial (1 character)<br>
              - no diacritics, all lower case (normalized)<br>
              - max. length 12 including iterator, so the family name
              part may be shortened:<br>
              John Smith: smithj<br>
              Jay Smith: smithj1<br>
              Max Verylonglastname: verylonglasm (notice the family name
              being shortened)<br>
              Marty Verylonglastname: verylonglam1 (notice the family
              name being shortened)<br>
              --><br>
              <br>
              <!--<br>
              tmpFamilyName = tmpFamilyName ? tmpFamilyName.getNorm() :
              ''<br>
              tmpGivenName = tmpGivenName ? tmpGivenName.getNorm() :
              ''--><br>
              <br>
              tmpGivenNameInitial =
              basic.stringify(tmpGivenName)?.size() &gt; 0 ?
              (basic.stringify(tmpGivenName)).substring(0,1) : ''<br>
              <br>
              if (iteration == 0) {<br>
                if (basic.stringify(tmpFamilyName).size() &lt; 11) {<br>
                basic.norm(basic.stringify(tmpFamilyName +
              tmpGivenNameInitial))<br>
                }<br>
                else {<br>
                 
              basic.norm(basic.stringify(tmpFamilyName)?.substring(0,
              11) + basic.stringify(tmpGivenNameInitial))<br>
                }<br>
              }<br>
              else {<br>
                if (basic.stringify(tmpFamilyName).size() &lt; 10) {<br>
                basic.norm(basic.stringify(tmpFamilyName +
              tmpGivenNameInitial)) + iterationToken<br>
               }<br>
               else {<br>
                 basic.norm(basic.stringify(tmpFamilyName?.substring(0,
              10) + tmpGivenNameInitial)) + iterationToken<br>
               }<br>
              }<br>
                    </code><br>
                  </script><br>
                </expression><br>
              </outbound><br>
              <br>
              Regards,<br>
              Ivan
              <div>
                <div class="h5"><br>
                  <br>
                  <div>On 11/20/2014 06:20 PM, Jason Everling wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">I decided to make this seperate,
                      <div><br>
                      </div>
                      <div>So the username gets generated with the
                        following</div>
                      <div><br>
                      </div>
                      <div>
                        <div>        <expression></div>
                        <div>            <script></div>
                        <div>                <code></div>
                        <div>                    tmpGivenNameInitial =
                          basic.stringify(tmpGivenName)?.size() &gt;
                          0 ?</div>
                        <div>                   
                          (basic.stringify(tmpGivenName)).substring(0,2)
                          : ''</div>
                        <div>                    if (iteration == 0) {</div>
                        <div>                   
                          basic.norm(basic.stringify(tmpGivenNameInitial
                          + tmpFamilyName))</div>
                        <div>                    }</div>
                        <div>                    else {</div>
                        <div>                   
                          basic.norm(basic.stringify(tmpGivenNameInitial
                          + tmpFamilyName)) + iterationToken</div>
                        <div>                    }</div>
                        <div>                </code></div>
                        <div>            </script></div>
                        <div>        </expression></div>
                      </div>
                      <div><br>
                      </div>
                      <div>Would there be a way, instead of using the
                        iterationToken to use another script if the
                        username is already taken.</div>
                      <div><br>
                      </div>
                      <div>Try filastname and if not try firlastname ?</div>
                      <div><br>
                      </div>
                      <div>I was thinking maybe this which is probably
                        not correct but easier to visualize.</div>
                      <div><br>
                      </div>
                      <div>
                        <div>        <expression></div>
                        <div>            <script></div>
                        <div>                <code></div>
                        <div>                    tmpGivenNameInitial =
                          basic.stringify(tmpGivenName)?.size() &gt;
                          0 ?</div>
                        <div>                   
                          (basic.stringify(tmpGivenName)).substring(0,2)
                          : ''</div>
                        <div>                    if (iteration == 0) {</div>
                        <div>                   
                          basic.norm(basic.stringify(tmpGivenNameInitial
                          + tmpFamilyName))</div>
                        <div>                    }</div>
                        <div>                    else {</div>
                        <div>
                          <div>                    tmpGivenNameInitial =
                            basic.stringify(tmpGivenName)?.size()
                            &gt; 0 ?</div>
                          <div>                   
                            (basic.stringify(tmpGivenName)).substring(0,3)
                            : ''</div>
                        </div>
                        <div>                   
                          basic.norm(basic.stringify(tmpGivenNameInitial
                          + tmpFamilyName))                </div>
                        <div>                    }</div>
                        <div>                </code></div>
                        <div>            </script></div>
                        <div>        </expression></div>
                      </div>
                      <div><br>
                      </div>
                      <div>JASON</div>
                    </div>
                    <br>
                  </div>
                </div>
                <font><br>
                  <br>
                  CONFIDENTIALITY NOTICE:<br>
                  This e-mail together with any attachments is
                  proprietary and confidential; intended for only the
                  recipient(s) named above and may contain information
                  that is privileged. You should not retain, copy or use
                  this e-mail or any attachments for any purpose, or
                  disclose all or any part of the contents to any
                  person. Any views or opinions expressed in this e-mail
                  are those of the author and do not represent those of
                  the Baptist School of Health Professions. If you have
                  received this e-mail in error, or are not the named
                  recipient(s), you are hereby notified that any review,
                  dissemination, distribution or copying of this
                  communication is prohibited by the sender and to do so
                  might constitute a violation of the Electronic
                  Communications Privacy Act, 18 U.S.C. section
                  2510-2521. Please immediately notify the sender and
                  delete this e-mail and any attachments from your
                  computer. </font><br>
                <br>
                <fieldset></fieldset>
                <br>
                <pre>_______________________________________________
midPoint mailing list
<a moz-do-not-send="true" href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a moz-do-not-send="true" href="http://lists.evolveum.com/mailman/listinfo/midpoint" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a><span class="HOEnZb"><font color="#888888">
</font></span></pre>
                <span class="HOEnZb"><font color="#888888"> </font></span></blockquote>
              <span class="HOEnZb"><font color="#888888"> <br>
                  <pre cols="72">-- 
  Ing. Ivan Noris
  Senior Identity Management Engineer
  <a moz-do-not-send="true" href="http://evolveum.com">evolveum.com</a>
  ___________________________________________
           "Idem per idem - semper idem Vix."
</pre>
                </font></span></div>
            <br>
            _______________________________________________<br>
            midPoint mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
            <a moz-do-not-send="true"
              href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <font size="2"><br>
        <br>
        CONFIDENTIALITY NOTICE:<br>
        This e-mail together with any attachments is proprietary and
        confidential; intended for only the recipient(s) named above and
        may contain information that is privileged. You should not
        retain, copy or use this e-mail or any attachments for any
        purpose, or disclose all or any part of the contents to any
        person. Any views or opinions expressed in this e-mail are those
        of the author and do not represent those of the Baptist School
        of Health Professions. If you have received this e-mail in
        error, or are not the named recipient(s), you are hereby
        notified that any review, dissemination, distribution or copying
        of this communication is prohibited by the sender and to do so
        might constitute a violation of the Electronic Communications
        Privacy Act, 18 U.S.C. section 2510-2521. Please immediately
        notify the sender and delete this e-mail and any attachments
        from your computer. </font><br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
  Ing. Ivan Noris
  Senior Identity Management Engineer
  evolveum.com
  ___________________________________________
           "Idem per idem - semper idem Vix."
</pre>
  </body>
</html>