[midPoint] Query shadows by resource and name

Wojciech Staszewski wojciech.staszewski at diagnostyka.pl
Tue Oct 23 20:51:41 CEST 2018


Hi

If you want to search for existing shadows in a resource for unique user
name, try this:  midpoint.isUniqueAccountValue()

https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO

Regards!
WS

W dniu 23.10.2018 o 18:38, Nicolas Rossi pisze:
> 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).
>
> I tried writing a custom query like that:
>
> objectClass = new
> QName("http://midpoint.evolveum.com/xml/ns/public/resource/instance-3",
> "AccountObjectClass");
>
> userInMPQuery = QueryBuilder.queryFor(ShadowType.class,
> midpoint.getPrismContext())
>
>                            
> .item(ShadowType.F_NAME).eqPoly(name.toString()).and()
>
>                            
> .item(ShadowType.F_OBJECT_CLASS).eq(objectClass).and()
>
>                            
> .item(ShadowType.F_RESOURCE_REF).ref("702ecc89-deba-4542-9618-5b9c8ba94abe")
>
>                             .build();
>
>
> It fails with this message:
>
> Caused by: com.evolveum.midpoint.util.exception.SchemaException:
> *Cannot combine on-resource and off-resource properties in a shadow
> search query. Encountered property name*
> at
> com.evolveum.midpoint.provisioning.impl.ShadowCache.createAttributeQueryInternal(ShadowCache.java:1756)
> at
> com.evolveum.midpoint.provisioning.impl.ShadowCache.createAttributeQuery(ShadowCache.java:1711)
> at
> com.evolveum.midpoint.provisioning.impl.ShadowCache.searchObjectsIterative(ShadowCache.java:1598)
> at
> com.evolveum.midpoint.provisioning.impl.ShadowCache.searchObjectsIterative(ShadowCache.java:1578)
> at
> com.evolveum.midpoint.provisioning.impl.ProvisioningServiceImpl.searchObjectsIterative(ProvisioningServiceImpl.java:1000)
> at
> com.evolveum.midpoint.provisioning.impl.ProvisioningServiceImpl.searchObjects(ProvisioningServiceImpl.java:456)
> at
> com.evolveum.midpoint.model.impl.controller.ModelController.searchObjects(ModelController.java:789)
> at
> com.evolveum.midpoint.model.impl.expr.MidpointFunctionsImpl.searchObjects(MidpointFunctionsImpl.java:1060)
> at
> com.evolveum.midpoint.model.api.expr.MidpointFunctions$searchObjects.call(Unknown
> Source)
> at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
> at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
> at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
> at Script16.run(Script16.groovy:13)
>
> It's very strange behavior because I can run a similar query on the
> Playground and it works fine:
>
> <query>
>     <filter>
>         <and>
>             <ref>
>                 <path>resourceRef</path>
>                 <value oid="702ecc89-deba-4542-9618-5b9c8ba94abe"/>
>             </ref>
>             <equal>
>                 <path>name</path>
>                 <value>ealonso</value>
>             </equal>
>         </and>
>     </filter>
> </query>
>
> Any help ?
>
> Thanks in advance
>
>
> Ing Nicolás Rossi
> Identicum S.A.
> Jorge Newbery 3226
> Oficina: +54 (11) 4552-3050
> Móvil: +54 (911) 6041-3920
> www.identicum.com <http://www.identicum.com>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint

-- 
Wojciech Staszewski
Administrator Systemów Sieciowych
tel. kom: 663 680 236
www.diagnostyka.pl
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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20181023/893d8841/attachment.htm>


More information about the midPoint mailing list