<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Tim,<br>
    <br>
    this is perfectly doable, but using iterator in object template. The
    main scenario is like this:<br>
    <br>
    - account is detected on resource during synchronization/inbound
    phase<br>
    - user attributes are prepared (user/familyName, user/givenName,
    etc. but not user/name)<br>
    - midPoint processes object templates (in my case, default user
    template configured in System Config)<br>
    - object template will compute user/name attribute<br>
    - midPoint user is created<br>
    <br>
    I have just tried to do this:<br>
    <br>
    Resource:<br>
    <br>
    1. my CSV resource has only inbound expressions<br>
    2. unique key in CSV resource configuration properties is the
    "employeeNumber"<br>
    3. mapping for CSV attribute "icfs:name" (beware, not
    employeeNumber) has target to user's employeeNumber attribute<br>
    4. mapping for CSV attribute "employeeType" to user's attribute
    employeeType<br>
    <br>
    The resource does not create user's name directly when doing
    synchronization (or import).<br>
    <br>
    Synchronization configuration is based on comparing user's
    employeeNumber with account's icfs:name (which is also
    employeeNumber in this case).<br>
    <br>
    Accounts in CSV (demo)<br>
    "employeeNumber","firstname","lastname","employeeType"<br>
    "12345","John","Smith","employee"<br>
    "22222","John","Smith","employee"<br>
    <br>
    (you can have other columns too, like password or disabled etc.)<br>
    <br>
    Object template (which is set to default in System configuration,
    but of course you may use resource-specific (or addUser action
    specific):<br>
    <br>
    <objectTemplate
    xmlns='<a class="moz-txt-link-freetext" href="http://midpoint.evolveum.com/xml/ns/public/common/common-3">http://midpoint.evolveum.com/xml/ns/public/common/common-3</a>'><br>
    <name>Default User Template with iterator</name><br>
        <mapping><br>
            <name>Object Template: Generate name for employees
    (employeeType=employee)</name><br>
            <source><br>
                <path>givenName</path><br>
            </source><br>
            <source><br>
                <path>familyName</path><br>
            </source><br>
            <source><br>
                <path>employeeType</path><br>
            </source><br>
            <expression><br>
                <script><br>
                    <code><br>
    tmpGivenName = basic.norm(basic.stringify(givenName))<br>
    tmpFamilyName = basic.norm(basic.stringify(familyName))<br>
    <br>
    tmpGivenName + '.' + tmpFamilyName + iterationToken<br>
                    </code><br>
                </script><br>
            </expression><br>
            <target><br>
                <path>name</path><br>
            </target><br>
            <condition><br>
                 <script><br>
                    <code>employeeType == 'employee'</code><br>
                </script>  <br>
            </condition><br>
        </mapping><br>
    <br>
        <iteration><br>
            <maxIterations>999</maxIterations><br>
            <tokenExpression><br>
                <script><br>
                    <code><br>
        if (iteration == 0) {<br>
            return "";<br>
        } else {<br>
            return "" + (iteration+1)<br>
        }<br>
                    </code><br>
                </script><br>
            </tokenExpression><br>
        </iteration><br>
    </objectTemplate><br>
    <br>
    This configuration will create first user named "john.smith" and
    second one named "john.smith2" (this is configured in the object
    template iteration / tokenExpression. The condition for iterator is
    based on user's employeeType and is used only when
    employeeType==employee.<br>
    <br>
    This is roughly stripped from on one of my custom configurations.
    Hope it helps and there are no syntax/xml problems caused by me. If
    there is any problem, I'll try to prepare the configuration more
    thoroughly.<br>
    <br>
    Best regards,<br>
    Ivan<br>
    <br>
    <div class="moz-cite-prefix">On 06/11/2014 04:22 PM, Tim Tompkins
      wrote:<br>
    </div>
    <blockquote
cite="mid:CABaosD=wtF_vyQ2gxk6WAoEQA-b7zVdmj4ZXJjA5D10w9QfY+Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I am trying to get the unique account name creation setup,
          however this is in reverse of the FAQ at</div>
        <div><a moz-do-not-send="true"
href="https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO">https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO</a><br>
        </div>
        <div><br>
        </div>
        <div>The scenario is I have an HR csv feed that gives me
          identities containing firstname, lastname, and employee #,
          from that i would like to generate unique names for midpoint
          accounts. The names would be firstnameLastnameToken</div>
        <div><br>
        </div>
        <div>I've tried it in the Mappings definition but that is not
          picking up when creating 2 distinct users with the same name
          different employee number. </div>
        <div><br>
        </div>
        <div>Any Ideas?</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div><br>
        </div>
        <div>Tim</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <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>