<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi <br>
    </p>
    <p>If you want to search for existing shadows in a resource for
      unique user name, try this:  midpoint.isUniqueAccountValue()</p>
    <p><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></p>
    <p>Regards!<br>
      WS<br>
    </p>
    <div class="moz-cite-prefix">W dniu 23.10.2018 o 18:38, Nicolas
      Rossi pisze:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAAxX8cgiRiByDiPCvvQW7b_QXE69JwsZ37uQ7DM1-p1wKfaVyQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">Hi,
              we are trying to query the existing shadows to create a
              unique user name in midPoint. There is a very useful
              function called midpoint.isUniquePropertyValue but it only
              works for users not for shadows (I couldn't find the way
              to make it work).</div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">I
              tried writing a custom query like that:</div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">
              <p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:"SF
                Mono"">objectClass = new QName("<a
                  href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
                  moz-do-not-send="true">http://midpoint.evolveum.com/xml/ns/public/resource/instance-3</a>",
                "AccountObjectClass");</p>
              <p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:"SF
                Mono"">userInMPQuery =
                QueryBuilder.queryFor(ShadowType.class,
                midpoint.getPrismContext())</p>
              <p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:"SF
                Mono""><span class="gmail-Apple-converted-space"> 
                                            </span>.item(ShadowType.F_NAME).eqPoly(name.toString()).and()</p>
              <p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:"SF
                Mono""><span class="gmail-Apple-converted-space"> 
                                            </span>.item(ShadowType.F_OBJECT_CLASS).eq(objectClass).and()</p>
              <p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:"SF
                Mono""><span class="gmail-Apple-converted-space"> 
                                            </span>.item(ShadowType.F_RESOURCE_REF).ref("702ecc89-deba-4542-9618-5b9c8ba94abe")</p>
              <p class="gmail-p1"
style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:"SF
                Mono""><span class="gmail-Apple-converted-space"> 
                                            </span>.build();</p>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">It
              fails with this message:</div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">
              <div class="gmail_default">Caused by:
                com.evolveum.midpoint.util.exception.SchemaException: <b>Cannot
                  combine on-resource and off-resource properties in a
                  shadow search query. Encountered property name</b></div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.createAttributeQueryInternal(ShadowCache.java:1756)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.createAttributeQuery(ShadowCache.java:1711)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.searchObjectsIterative(ShadowCache.java:1598)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.searchObjectsIterative(ShadowCache.java:1578)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.provisioning.impl.ProvisioningServiceImpl.searchObjectsIterative(ProvisioningServiceImpl.java:1000)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.provisioning.impl.ProvisioningServiceImpl.searchObjects(ProvisioningServiceImpl.java:456)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.model.impl.controller.ModelController.searchObjects(ModelController.java:789)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.model.impl.expr.MidpointFunctionsImpl.searchObjects(MidpointFunctionsImpl.java:1060)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
com.evolveum.midpoint.model.api.expr.MidpointFunctions$searchObjects.call(Unknown
                Source)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)</div>
              <div class="gmail_default"><span style="white-space:pre"> </span>at
                Script16.run(Script16.groovy:13)</div>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">It's
              very strange behavior because I can run a similar query on
              the Playground and it works fine:</div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">
              <div class="gmail_default"><query></div>
              <div class="gmail_default">    <filter></div>
              <div class="gmail_default">        <and></div>
              <div class="gmail_default">            <ref></div>
              <div class="gmail_default">               
                <path>resourceRef</path></div>
              <div class="gmail_default">                <value
                oid="702ecc89-deba-4542-9618-5b9c8ba94abe"/></div>
              <div class="gmail_default">            </ref></div>
              <div class="gmail_default">            <equal></div>
              <div class="gmail_default">               
                <path>name</path></div>
              <div class="gmail_default">               
                <value>ealonso</value></div>
              <div class="gmail_default">            </equal></div>
              <div class="gmail_default">        </and></div>
              <div class="gmail_default">    </filter></div>
              <div class="gmail_default"></query></div>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">Any
              help ?</div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"><br>
            </div>
            <div class="gmail_default"
style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">Thanks
              in advance</div>
            <div>
              <div dir="ltr" class="gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div>
                            <div dir="ltr">
                              <div>
                                <div dir="ltr">
                                  <div>
                                    <div dir="ltr">
                                      <div>
                                        <div dir="ltr">
                                          <div>
                                            <div dir="ltr">
                                              <div>
                                                <div dir="ltr"><font
                                                    face="arial,
                                                    helvetica,
                                                    sans-serif"><br>
                                                    <br>
                                                    <font
                                                      color="#444444">Ing
                                                      Nicolás Rossi</font><br>
                                                    <font
                                                      color="#999999">Identicum
                                                      S.A.</font><br>
                                                    <font
                                                      color="#999999">Jorge
                                                      Newbery 3226</font><br>
                                                    <font
                                                      color="#999999">Oficina:
                                                      +54 (11) 4552-3050</font></font></div>
                                                <div dir="ltr"><font
                                                    face="arial,
                                                    helvetica,
                                                    sans-serif"><font
                                                      color="#999999">Móvil:
                                                      +54 (911)
                                                      6041-3920<br>
                                                      <a
                                                        href="http://www.identicum.com"
                                                        target="_blank"
moz-do-not-send="true">www.identicum.com</a></font></font><br>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-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>
    <pre class="moz-signature" cols="72">-- 
Wojciech Staszewski
Administrator Systemów Sieciowych
tel. kom: 663 680 236
<a class="moz-txt-link-abbreviated" href="http://www.diagnostyka.pl">www.diagnostyka.pl</a>
Diagnostyka Sp. z o. o.
ul. Prof. M. Życzkowskiego 16, 31-864 Kraków
Numer KRS: 0000381559 (Sąd Rejonowy dla Krakowa-Śródmieścia w Krakowie, XI Wydział Gospodarczy KRS)
NIP: 675-12-65-009; REGON: 356366975
Kapitał zakładowy: 33 756 500 zł.

Pomyśl o środowisku zanim wydrukujesz ten e-mail.</pre>
  </body>
</html>