<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Patrick,</p>
<p>a possible cause: the operation runs under the user who requests
the operation. If he has restricted rights, it might be possible
he simply does not see alice.</p>
<p>There is a method how to run a code "as root" (runPrivileged in
SecurityEnforcer). If this is the problem we can have a look how
to invoke it from script. (Concerning me, only tomorrow as I have
to leave now.)<br>
</p>
<p>Other possibilities... I don't know. The value should not be
String; it should be PolyString. But you've tried that. Also, your
attempts #3 and #4 should work. The correct matching rule is
either none, polyStringNorm, polyStringOrig or polyStringStrict.</p>
<p>Best regards,</p>
<pre class="moz-signature" cols="72">Pavol Mederly
Software developer
evolveum.com
</pre>
<div class="moz-cite-prefix">On 20.09.2016 23:43, <a class="moz-txt-link-abbreviated" href="mailto:pdbogen@cernu.us">pdbogen@cernu.us</a>
wrote:<br>
</div>
<blockquote cite="mid:20160920214345.GW1942@cernu.us" type="cite">
<pre wrap="">Howdy!
I'm working approval schemas that select the approver based on the value of
the extension attribute; the result of this is that I need to locate a User
object based on the Name.
Here's my code that I believe should accomplish this:
import com.evolveum.midpoint.prism.path.ItemPath
import com.evolveum.midpoint.prism.query.EqualFilter
import com.evolveum.midpoint.prism.query.ObjectQuery
import javax.xml.namespace.QName
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType
qn = new QName(<a class="moz-txt-link-rfc2396E" href="http://cernu.us/xml/ns/userSchema">"http://cernu.us/xml/ns/userSchema"</a>, "managerDn")
dn = basic.getExtensionPropertyValue(object, qn)
dn_parts = dn.split(",")
cn_parts = dn_parts[0].split("=")
cn = cn_parts[1]
log.info('assign: searching for manager with username {}', cn)
prismContext = midpoint.getPrismContext()
filter = EqualFilter.createEqual(UserType.F_NAME, UserType.class, prismContext, null, cn)
log.error('assign: {}', filter)
query = ObjectQuery.createObjectQuery(filter)
log.error('assign: {}', query)
managers = midpoint.searchObjects(UserType.class, query)
log.error('assign: {}', managers)
if (managers.size() == 0) {
log.warn('assign: for approval of assignment of {} to {}, no user for cn: {}', object, target, cn)
} else {
managers.each { m ->
log.info('assign: for approval of assignment of {} to {}, found {} for cn: {}', object, target, m, cn)
}
managers.collect { it.getOid() }
}
For brevity, I've excluded some defensive programming around parsing the dn,
etc.; please just assume that 'cn' is valid by the time we create the
EqualFilter.
The logging output of this is:
INFO (com.evolveum.midpoint.expression): assign: searching for manager with username alice
ERROR (com.evolveum.midpoint.expression): assign: EQUAL: name,PPV(String:alice)
ERROR (com.evolveum.midpoint.expression): assign: Q{EQUAL: name,PPV(String:alice),null paging
ERROR (com.evolveum.midpoint.expression): assign: []
WARN (com.evolveum.midpoint.expression): assign: for approval of assignment of user:db85f122-a6fc-4a97-8a42-e37c204db5c4(bob) to role:abe7a780-3644-4b7e-a7e4-8378402ab208(foo), no user for cn: alice
Is there anything obvious I've done wrong? The User 'alice' definitely exists.
Also, I _think_ this was working on 3.4, whereas I'm now on 3.4.1. I don't
know of anything else I might have changed that would break this.
I've tried a few variations:
* Making a filter with PolyString.fromOrig(cn) instead of just cn
* The above, plus replacing the `null` matching rule with variations on new QName("origIgnoreCase")
* Using midpoing.searchObjectByName, which very surprisingly did not work either
* Using ObjectQueryUtil.createNameQuery to create the query
Any advice on this would be quite helpful.
Thanks!
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<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>
<br>
</body>
</html>