<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 Wojciech, I didn't use that function because I am inside a mapping in a User Template, not a Resource. I don't have any reference to the resource (I only know the OID) and the shadow objects which are only present in the mapping inside the Resource. </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></font></div><div dir="ltr"><font face="arial, helvetica, sans-serif"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)">Kind regards, </span></font></div><div dir="ltr"><font face="arial, helvetica, sans-serif"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(7,55,99)"></span><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><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 23, 2018 at 3:54 PM Wojciech Staszewski <<a href="mailto:wojciech.staszewski@diagnostyka.pl">wojciech.staszewski@diagnostyka.pl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div 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="m_7278221127560070234moz-txt-link-freetext" href="https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO" target="_blank">https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO</a></p>
<p>Regards!<br>
WS<br>
</p>
<div class="m_7278221127560070234moz-cite-prefix">W dniu 23.10.2018 o 18:38, Nicolas
Rossi pisze:<br>
</div>
<blockquote type="cite">
<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="m_7278221127560070234gmail-p1">objectClass = new QName("<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>",
"AccountObjectClass");</p>
<p class="m_7278221127560070234gmail-p1">userInMPQuery =
QueryBuilder.queryFor(ShadowType.class,
midpoint.getPrismContext())</p>
<p class="m_7278221127560070234gmail-p1"><span class="m_7278221127560070234gmail-Apple-converted-space">
</span>.item(ShadowType.F_NAME).eqPoly(name.toString()).and()</p>
<p class="m_7278221127560070234gmail-p1"><span class="m_7278221127560070234gmail-Apple-converted-space">
</span>.item(ShadowType.F_OBJECT_CLASS).eq(objectClass).and()</p>
<p class="m_7278221127560070234gmail-p1"><span class="m_7278221127560070234gmail-Apple-converted-space">
</span>.item(ShadowType.F_RESOURCE_REF).ref("702ecc89-deba-4542-9618-5b9c8ba94abe")</p>
<p class="m_7278221127560070234gmail-p1"><span class="m_7278221127560070234gmail-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-wrap"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.createAttributeQueryInternal(ShadowCache.java:1756)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.createAttributeQuery(ShadowCache.java:1711)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.searchObjectsIterative(ShadowCache.java:1598)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.provisioning.impl.ShadowCache.searchObjectsIterative(ShadowCache.java:1578)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.provisioning.impl.ProvisioningServiceImpl.searchObjectsIterative(ProvisioningServiceImpl.java:1000)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.provisioning.impl.ProvisioningServiceImpl.searchObjects(ProvisioningServiceImpl.java:456)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.model.impl.controller.ModelController.searchObjects(ModelController.java:789)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.model.impl.expr.MidpointFunctionsImpl.searchObjects(MidpointFunctionsImpl.java:1060)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
com.evolveum.midpoint.model.api.expr.MidpointFunctions$searchObjects.call(Unknown
Source)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </span>at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)</div>
<div class="gmail_default"><span style="white-space:pre-wrap"> </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="m_7278221127560070234gmail_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>
<br>
<fieldset class="m_7278221127560070234mimeAttachmentHeader"></fieldset>
<pre class="m_7278221127560070234moz-quote-pre">_______________________________________________
midPoint mailing list
<a class="m_7278221127560070234moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a class="m_7278221127560070234moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
<pre class="m_7278221127560070234moz-signature" cols="72">--
Wojciech Staszewski
Administrator Systemów Sieciowych
tel. kom: 663 680 236
<a class="m_7278221127560070234moz-txt-link-abbreviated" href="http://www.diagnostyka.pl" target="_blank">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>
</div>
_______________________________________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">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>
</blockquote></div>