<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">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">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>