<div dir="ltr">Thanks Ivan,<div><br></div><div>In fact, I just need to get uniqueness in the emailAddress (I've already have username uniqueness since it's a personal ID #). The emailAddress, has nothing to do with the username in our design. Is there another way to achieve a field uniqueness?</div><div><br></div><div>Regards,</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b><span></span><span></span>Ing. Martín Marchese</b><br><img src="http://www.identicum.com/img/favicon.ico">Identicum S.A.<br>Anchorena 1357 PB<br>Tel: +54 (11) 3526.5509<br><a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a><br><a href="http://www.identicum.com" target="_blank">www.identicum.com</a></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jun 23, 2016 at 3:23 AM, Ivan Noris <span dir="ltr"><<a 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">
    Hi Martin,<br>
    <br>
    my guess is that you are using object template, where name is not
    generated using iterationToken. I have searched our samples for the
    object template you've pasted and found one - possibly the same.<br>
    <br>
    The iterationToken in emailAddress will be non-empty only if the
    iterator was used to generate the unique name.<br>
    So, for example, if I tried to create one user called identicum01
    (given: John, family: Smith) and another user called identicum02
    (given: John, family: Smith), the usernames are unique, so the
    emailAddress attribute will both contain empty iterationToken, which
    is indeed not expected. The iterationToken is only used when you
    have configured the mapping for user/name attribute to use it. And
    then you can use iterationToken also in other mappings.<br>
    <br>
    If user/name is generated from given and family names,
    iterationToken would be used for both user/name values, and the same
    value would then be used in the emailAddress. The iterationToken is
    single-value attribute stored in User object and triggered only if
    the username is not unique and the mapping for user/name is using
    the iterationToken.<br>
    <br>
    See my attached object template; I've just tried it with the
    following use case:<br>
    1. create new user in midPoint, givenName: John, familyName: Smith,
    password: whatever. No name attribute filled. Save.<br>
    Username JSmith was generated, <a href="mailto:emailAddress=JSmith@domain.com" target="_blank">emailAddress=JSmith@domain.com</a><br>
    2. create new user in midPoint, givenName: John, familyName: Smith,
    password: whatever. No name attribute filled. Save.<br>
    Username JSmith1 was generated, <a href="mailto:emailAddress=JSmith1@domain.com" target="_blank">emailAddress=JSmith1@domain.com</a><br>
    <br>
    I think this is what you were trying to achieve.<br>
    Of course you need to specify the mapping strength as normal or
    strong if you wish to generate new user/name and user/emailAddress
    whenever user is renamed. If you don't need this, and only wish to
    set it for the very first time, weak is OK.<br>
    <br>
    See also <a href="https://jira.evolveum.com/browse/MID-1977" target="_blank">https://jira.evolveum.com/browse/MID-1977</a><br>
    <br>
    Regards,<br>
    Ivan<br>
    <br>
    <objectTemplate
    xmlns=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a><br>
                   
xmlns:icfs=<a href="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"</a><br>
                   
    xmlns:t=<a href="http://prism.evolveum.com/xml/ns/public/types-3" target="_blank">"http://prism.evolveum.com/xml/ns/public/types-3"</a><br>
                   
    xmlns:c=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a><br>
                   
    xmlns:q=<a href="http://prism.evolveum.com/xml/ns/public/query-3" target="_blank">"http://prism.evolveum.com/xml/ns/public/query-3"</a><br>
                   
xmlns:ri=<a href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"</a><br>
                    oid="c0c010c0-d34d-b33f-f00d-777222222333"<br>
                    version="1"><span class=""><br>
       <name>User Template CSV sync</name><br></span>
       <description><br>
                Alternative User Template Object.<br>
                This object is used when creating a new account, to set
    it up as needed.<br>
                    </description><br>
       <metadata><br>
         
<createTimestamp>2016-06-23T08:14:13.745+02:00</createTimestamp><br>
          <creatorRef oid="00000000-0000-0000-0000-000000000002"
    type="c:UserType"><!-- administrator --></creatorRef><br>
         
<createChannel><a href="http://midpoint.evolveum.com/xml/ns/public/model/channels-3#objectImport" target="_blank">http://midpoint.evolveum.com/xml/ns/public/model/channels-3#objectImport</a></createChannel><br>
       </metadata><span class=""><br>
       <iteration><br>
          <maxIterations>10</maxIterations><br>
          <tokenExpression><br>
             <script><br>
                <code><br>
              if (iteration == 0) {<br>
                return "";<br>
              } else {<br>
                return ""+iteration;<br>
              }<br>
            </code><br>
             </script><br>
          </tokenExpression><br>
       </iteration><br></span>
       <mapping><br>
          <description><br>
                    Property mapping.<br>
                    Defines how properties of user object are set up.<br>
                    This specific definition sets a full name as a
    concatenation<br>
                    of givenName and familyName.<br>
                            </description><br>
          <strength>weak</strength><br>
          <source><br>
             <c:path>$user/givenName</c:path><br>
          </source><br>
          <source><br>
             <c:path>$user/familyName</c:path><span class=""><br>
          </source><br>
          <expression><br>
             <script><br>
               
<language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                <code><br></span>
                                                    givenName + ' ' +
    familyName<br>
                                            </code><br>
             </script><br>
          </expression><br>
          <target><br>
             <c:path>fullName</c:path><br>
          </target><br>
       </mapping><span class=""><br>
       <mapping><br>
          <strength>weak</strength><br>
          <source><br></span>
             <c:path>givenName</c:path><br>
          </source><br>
          <source><br>
             <c:path>familyName</c:path><span class=""><br>
          </source><br>
          <expression><br>
             <script><br>
               
<language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                <code><br>
              def givenNameStr = ''+givenName<br>
              givenNameStr.substring(0,1) + '' + familyName +
    iterationToken + '@<a href="http://domain.com" target="_blank">domain.com</a>'<br>
            </code><br>
             </script><br>
          </expression><br>
          <target><br></span>
             <c:path>$user/emailAddress</c:path><br>
          </target><br>
       </mapping><span class=""><br>
       <mapping><br>
          <strength>weak</strength><br>
          <source><br></span>
             <c:path>givenName</c:path><br>
          </source><br>
          <source><br>
             <c:path>familyName</c:path><span class=""><br>
          </source><br>
          <expression><br>
             <script><br>
               
<language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                <code><br>
              def givenNameStr = ''+givenName<br>
              givenNameStr.substring(0,1) + '' + familyName +
    iterationToken<br></span>
            </code><br>
             </script><br>
          </expression><br>
          <target><br>
             <c:path>$user/name</c:path><br>
          </target><br>
       </mapping><br>
    </objectTemplate><div><div class="h5"><br>
    <br>
    <div>On 06/22/2016 07:03 PM, Martin Marchese
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">Hi all,
        <div><br>
        </div>
        <div>I have an Object Template for users, and since I need email
          to be unique, I defined an iteration on it:</div>
        <div><br>
        </div>
        <div>
          <div><i><font color="#999999"><objectTemplate
                oid="c0c010c0-d34d-b33f-f00d-777222222333"></font></i></div>
          <div><i><font color="#999999">  <name>User Template CSV
                sync</name></font></i></div>
          <div><i><font color="#999999">  <iteration></font></i></div>
          <div><i><font color="#999999">   
                <maxIterations>10</maxIterations></font></i></div>
          <div><i><font color="#999999">    <tokenExpression></font></i></div>
          <div><i><font color="#999999">      <script></font></i></div>
          <div><i><font color="#999999">        <code></font></i></div>
          <div><i><font color="#999999">          if (iteration == 0) {</font></i></div>
          <div><i><font color="#999999">            return "";</font></i></div>
          <div><i><font color="#999999">          } else {</font></i></div>
          <div><i><font color="#999999">            return ""+iteration;</font></i></div>
          <div><i><font color="#999999">          }</font></i></div>
          <div><i><font color="#999999">        </code></font></i></div>
          <div><i><font color="#999999">      </script></font></i></div>
          <div><i><font color="#999999">    </tokenExpression></font></i></div>
          <div><i><font color="#999999">  </iteration></font></i></div>
        </div>
        <div><i><font color="#999999">...</font></i></div>
        <div><i><font color="#999999">...</font></i></div>
        <div><i><font color="#999999"><br>
            </font></i></div>
        <div><font color="#000000">And then within the emailAddress
            mapping:</font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font>
            <div style="color:rgb(153,153,153);font-style:italic"><mapping></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <strength>weak</strength></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <source></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <path>givenName</path></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </source></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <source></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <path>familyName</path></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </source></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <expression></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <script></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                <language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                <code></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                  def givenNameStr = ''+givenName</div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                  givenNameStr.substring(0,1) + '' + familyName +
              iterationToken + '@<a href="http://domain.com" target="_blank">domain.com</a>'</div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                </code></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              </script></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </expression></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <target></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <path>$user/emailAddress</path></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </target></div>
            <div style="color:rgb(153,153,153);font-style:italic"> 
              </mapping></div>
            <div style="color:rgb(153,153,153);font-style:italic"><br>
            </div>
            <div><font color="#000000">The problem is that whenever I
                create a user, the email is always being set as if the
                iterationToken is '' and this result on duplicate
                emailAddress attribute among users.</font></div>
            <div><font color="#000000"><br>
              </font></div>
            <div><font color="#000000">Is there something I'm doing
                wrong?</font></div>
            <div><font color="#000000"><br>
              </font></div>
            <div><font color="#000000">Thanks in Advance</font></div>
          </font></div>
        <div><br clear="all">
          <div>
            <div data-smartmail="gmail_signature">
              <div dir="ltr">
                <div>
                  <div dir="ltr"><b><span></span><span></span>Ing.
                      Martín Marchese</b><br>
                    <img src="http://www.identicum.com/img/favicon.ico">Identicum
                    S.A.<br>
                    Anchorena 1357 PB<br>
                    Tel: +54 (11) 3526.5509<br>
                    <a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a><br>
                    <a href="http://www.identicum.com" target="_blank">www.identicum.com</a></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
midPoint mailing list
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a 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 & IDM Architect
  <a href="http://evolveum.com" target="_blank">evolveum.com</a>                     <a href="http://evolveum.com/blog/" target="_blank">evolveum.com/blog/</a>
  ___________________________________________________
  "Semper ID(e)M Vix."
</pre>
  </font></span></div>

<br>_______________________________________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a><br>
<br></blockquote></div><br></div>