<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hello Paul,<br>
<br>
yes, midpoint.searchObjects can be used to implement that.<br>
<br>
An example that I was able to create is this:<br>
<br>
<small><tt><expression></tt><tt><br>
</tt><tt> <script></tt><tt><br>
</tt><tt> <code></tt><tt><br>
</tt><tt>import com.evolveum.midpoint.prism.query.EqualFilter</tt><tt><br>
</tt><tt>import com.evolveum.midpoint.prism.query.ObjectQuery</tt><tt><br>
</tt><tt>import javax.xml.namespace.QName</tt><tt><br>
</tt><tt>import
com.evolveum.midpoint.xml.ns._public.common.common_3.UserType</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt>prismContext =
midpoint.createEmptyObject(UserType.class).asPrismObject().getPrismContext()
// temporary solution </tt><tt>until there's a
midpoint.getPrismContext() method<br>
</tt><tt> </tt><tt><br>
</tt><tt>log.info("Trying to find a user with a nickname = {}",
input)</tt><tt><br>
</tt><tt>filter = EqualFilter.createEqual(new QName("nickName"),
UserType.class, prismContext, null, input)</tt><tt><br>
</tt><tt>query = ObjectQuery.createObjectQuery(filter)</tt><tt><br>
</tt><tt>list = midpoint.searchObjects(UserType.class, query)</tt><tt><br>
</tt><tt>if (list.size() > 0) {</tt><tt><br>
</tt><tt> 'Found: ' + list.get(0).getFamilyName()</tt><tt><br>
</tt><tt>} else {</tt><tt><br>
</tt><tt> 'Nothing found'</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><tt> </code></tt><tt><br>
</tt><tt> </script></tt><tt><br>
</tt><tt></expression></tt><tt><br>
</tt></small><br>
(Yes, I know it's a bit ugly. :-) Maybe someone could find a nicer
solution.)<br>
<br>
This specific script is used as an inbound expression for an
attribute. It tries to find a user with a nickName (chosen as an
example) equals to the value of the attribute.<br>
And then it uses a user's familyName attribute to construct the
return value.<br>
<br>
I suppose we don't have anything like this in our examples because
it is quite a non-usual thing - to search midPoint repository from
within a mapping. Other aspects aside, I think it would be quite
slow to execute. Maybe there would be some other way how to
achieve what you'd like to do.<br>
<br>
What exactly is your scenario, your requirement?<br>
<br>
Best regards,<br>
Pavol<br>
<br>
<br>
On 12. 3. 2015 18:25, Paul Heaney wrote:<br>
</div>
<blockquote cite="mid:5501CBF3.1080604@pheaney.co.uk" type="cite">Hi,
<br>
<br>
We're looking to synchronise users assistants from Active
Directory to midPoint, to do this we need to do a search on
midPoint based on the received assistant value. I believe we
should be able to do this with the searchObjects function within
the midPoint script library (using Groovy) though unfortunatly I'm
having a few difficulties getting the syntax of the query
parameter correct in my groovy script.
<br>
<br>
I've had a look at the samples and also the test scripts though
don't seem to be able to find an example, does anyone have an
example or pointers on this call?
<br>
<br>
Thanks
<br>
Paul
<br>
_______________________________________________
<br>
midPoint mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
<br>
</blockquote>
<br>
</body>
</html>