<div class="xam_msg_class">
<div style="font: normal 13px Arial; color:rgb(0, 0, 0);"><div>Ok, I've resolved. The expression is evaluated two times: I've protected the script from null input and the second time (with new value) it works!</div><div><br></div><div><div> <attribute></div><div> <ref>icfs:groups</ref></div><div> <displayName>Gruppi</displayName></div><div> <inbound></div><div> <expression></div><div> <script></div><div> <relativityMode>absolute</relativityMode></div><div> <code></div><div><span style="background-color: transparent;"> if (input != null) {</span></div><div> def isdirettore = false</div><div> input.eachWithIndex { gruppo, index -><span style="background-color: transparent;"> </span></div><div><span style="background-color: transparent;"> if (gruppo =~ /^.*_DIR,OU=.*$/) {</span></div><div><span style="background-color: transparent;"> isdirettore = true</span></div><div><span style="background-color: transparent;"> }</span></div><div> }</div><div> isdirettore</div><div> }</div><div> </code></div><div> </script></div><div> </expression></div><div> <target></div><div> <path>$user/extension/mise:isDirettore</path></div><div> </target></div><div> </inbound></div><div> </attribute></div></div><div><br></div><div>Thanks a lot.</div><div><br></div><div> Fabio</div><div><br></div><br>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Da</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: "midPoint" midpoint-bounces@lists.evolveum.com</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">A</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: midpoint@lists.evolveum.com</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Cc</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: </span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Data</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Thu, 3 Sep 2015 16:48:16 +0200</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">Oggetto</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Re: [midPoint] Help looping on Active Directory groups</span></div>
<br>
<div class="xam_msg_class">>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<div class="moz-cite-prefix">> Fabio,<br>>
<br>>
you're right: it's icfs:groups, not ri:groups (sorry for that).<br>>
<br>>
The error you're experiencing is caused by the fact that midPoint
evaluates not only the current value of attribute, but also a
change in that value. So, sometimes it needs to take the old
attribute value (which is null in this case, because - at least I
am convinced so - midPoint considers the account as being newly
created in this particular case) and execute the provided script
on it.<br>>
<br>>
So you should just assume that input might be null, and treat is
just like an empty array.<br>>
<br>>
See also <a href="http://lists.evolveum.com/pipermail/midpoint/2015-August/001292.html" _djrealurl="http://lists.evolveum.com/pipermail/midpoint/2015-August/001292.html"></a><a class="moz-txt-link-freetext" href="http://lists.evolveum.com/pipermail/midpoint/2015-August/001292.html" _djrealurl="http://lists.evolveum.com/pipermail/midpoint/2015-August/001292.html">http://lists.evolveum.com/pipermail/midpoint/2015-August/001292.html</a><br>>
<br>>
Best regards,<br>>
Pavol<br>>
<br>>
</div>
<blockquote cite="mid:NU3UZB$AB067E08A09A1A88F1726624B579B1E4@nsr.it" type="cite">
<div class="xam_msg_class">>
<div style="font: normal 13px Arial; color:rgb(0, 0, 0);">>
<div>> Hi Pavol,</div>
<div>> thanks for your suggestions. Now, I have modified the xml
code for attribute on the AD resource:</div>
<div><br>>
</div>
<div>>
<div>> <attribute></div>
<div>> <ref>icfs:groups</ref></div>
<div>>
<displayName>Gruppi</displayName></div>
<div>> <inbound></div>
<div>> <expression></div>
<div>> <script></div>
<div>>
<relativityMode>absolute</relativityMode></div>
<div>> <code></div>
<div><span style="background-color: transparent;">>
def isdirettore = false</span></div>
<div>> def n = input.size()</div>
<div><span style="background-color: transparent;">>
for (def i = 0; i < n; i++)
{</span></div>
<div>> def gruppo =
input.get(i)</div>
<div><span style="background-color: transparent;">>
if (it =~
/^CN=.*_DIV.._DIR.*$/) {</span></div>
<div><span style="background-color: transparent;">>
isdirettore = true</span></div>
<div>> }</div>
<div>> }</div>
<div>> isdirettore</div>
<div>> </code></div>
<div>> </script></div>
<div>> </expression></div>
<div>> <target></div>
<div>>
<path>$user/extension/mise:organizzazione</path></div>
<div>> </target></div>
<div>> </inbound></div>
<div>> </attribute></div>
</div>
<div><br>>
</div>
<div><br>>
</div>
<div>> But I have the "input" variable null, as I can see from
idm.log:</div>
<div><br>>
</div>
<div>>
<div>> ERROR (com.evolveum.midpoint<span style="background-color: transparent;">.model.common.expression.script.ScriptExpression):
Expression error: java.lang.NullPointerException: Cannot
invoke me</span><span style="background-color: transparent;">thod size() on null object (old)
expression in mapping in inbound expression for
{<a class="moz-txt-link-freetext" href="http://midpoint.evolveum.com/xml/ns" _djrealurl="http://midpoint.evolveum.com/xml/ns">http://midpoint.evolveum.com/xml/ns</a></span><span style="background-color: transparent;">/public/connector/icf-1/resource-schema-3}groups
in <a class="moz-txt-link-freetext" href="resource:Resource-ActiveDirectoryXXX(Active" _djrealurl="resource:Resource-ActiveDirectoryXXX(Active">resource:Resource-ActiveDirectoryXXX(Active</a> Directory
XXX)</span></div>
</div>
<div><br>>
</div>
<div>> The only difference is the namespace: you have suggested
me "ri:groups" but it isn't defined in ns instance-3; so I
put "icfs:groups". It could made the difference?</div>
<div>> Any other suggestion?</div>
<div><br>>
</div>
<div>> Thanks in advance. Regards.</div>
<div><br>>
</div>
<div>> Fabio</div>
<br>>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">> Da</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">:
"midPoint" <a class="moz-txt-link-abbreviated" href="mailto:midpoint-bounces@lists.evolveum.com" _djrealurl="mailto:midpoint-bounces@lists.evolveum.com">midpoint-bounces@lists.evolveum.com</a></span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">> A</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">:
<a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com" _djrealurl="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a></span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">> Cc</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: </span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">> Data</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Thu, 3
Sep 2015 15:45:57 +0200</span></div>
<div><span style="font-family:Arial; font-size:11px; color:#5F5F5F;">> Oggetto</span><span style="font-family:Arial; font-size:12px; color:#5F5F5F; padding-left:5px;">: Re: [midPoint] Help looping on Active
Directory groups</span></div>
<br>>
<div class="xam_msg_class">> >
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<div class="moz-cite-prefix">> > Hello Fabio,<br>>
> <br>>
> the problem is that you've put your script to <b>ri:title</b>
attribute. So (I think) that as an input you get the value
of this attribute, which is a string. The <source>
declaration is not appropriate here.<br>>
> <br>>
> If you want to process ri:groups attribute, please
put this mapping under <b>ri:groups</b> attribute.<br>>
> Also, use <b><relativityMode>absolute</relativityMode></b>
(as a child of <script>) in order to get all the
values of ri:groups at once.<br>>
> Remove the <source> part and refer to the input
variable (now called gruppi) simply as <b>input</b>.<br>>
> <br>>
> Hope this helps,<br>>
> Pavol<br>>
> <br>>
> </div>
<blockquote cite="mid:2CDAB07C-46FF-4E0B-962B-20649AD477D5@nsr.it" type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div style="font-family: -apple-system-font; line-height: 16px;" class="">> >
<div class="">> > Hi,</div>
<div class="">> > I have an Active Directory resource
and I need to reconcile users. In populating a virtual
user attribute I need to check if the corresponding AD
account has a particular group assigned. This is a
snippet of the resource xml:</div>
</div>
<div style="font-family: -apple-system-font; line-height: 16px;" class=""><br class="">>
> </div>
<div style="font-family: -apple-system-font; line-height: 16px;" class="">> >
<div class="">> > <attribute></div>
<div class="">> >
<c:ref>ri:title</c:ref></div>
<div class="">> >
<displayName>Gruppi</displayName></div>
<div class="">> > <inbound></div>
<div class="">> >
<source></div>
<div class="">> >
<name>gruppi</name></div>
<div class="">> >
<path>$shadow/attributes/groups</path></div>
<div class="">> >
</source> </div>
<div class="">> >
<expression></div>
<div class="">> >
<script></div>
<div class="">> >
<code></div>
<div class="">> > def
isdirettore = false</div>
<div class="">> > def n
= gruppi.size()</div>
<div class="">> > for
(def i = 0; i < n; i++) {</div>
<div class="">> >
def gruppo = gruppi.get(i)</div>
<div class="">> >
if (it =~ /^CN=.*_DIV.._DIR.*$/) {</div>
<div class="">> >
isdirettore = true</div>
<div class="">> > }</div>
<div class="">> > }</div>
<div class="">> >
isdirettore</div>
<div class="">> >
</code></div>
<div class="">> >
</script></div>
<div class="">> >
</expression></div>
<div class="">> >
<target></div>
<div class="">> >
<path>$user/extension/mise:organizzazione</path></div>
<div class="">> >
</target></div>
<div class="">> > </inbound></div>
<div class="">> > </attribute></div>
</div>
<div style="font-family: -apple-system-font; line-height: 16px;" class=""><br class="">>
> </div>
<div style="font-family: -apple-system-font; line-height: 16px;" class="">> > I need to loop on assigned AD
groups and I need to check the string format of each
group using a regular expression. The problem is that in
the variable named “gruppi” I have only a string and not
an array or List. Do you have any ideas?</div>
<div class=""><br class="">>
> </div>
<div class="">> > Thanks and regards.</div>
<div class=""><br class="">>
> </div>
<div class="">> > Fabio</div>
<div class=""><br class="">>
> </div>
<div apple-content-edited="true" class="">> >
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">> >
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">> >
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">> >
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">> >
<div class=""><font class="" size="1"><span class="" style="font-family: 'Lucida Sans'; color: rgb(17, 52, 80); orphans: 2; widows: 2;">> > --</span><br class="" style="orphans: 2; widows: 2; color: rgb(17, 52, 80);">>
> <span class="" style="font-family: 'Lucida Sans'; color: rgb(17, 52, 80); orphans: 2; widows: 2;">Fabio Contessi
<<a moz-do-not-send="true" href="mailto:f.contessi@nsr.it" _djrealurl="mailto:f.contessi@nsr.it" class="">f.contessi@nsr.it</a></span><span class="" style="font-family: 'Lucida Sans'; color: rgb(17, 52, 80); orphans: 2; widows: 2;">></span><br class="" style="orphans: 2; widows: 2; color: rgb(17, 52, 80);">>
> <br class="" style="orphans: 2; widows: 2; color: rgb(17, 52, 80);">>
> <span class="" style="orphans: 2; widows: 2;"><font class="" color="#015494" face="LucidaSans-Demi">nova systems roma
/ nsr</font></span></font></div>
<div class=""><br class="">>
> </div>
</div>
</div>
</div>
</div>
</div>
<br>>
>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>>
>
<pre wrap="">> > _______________________________________________
midPoint mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" _djrealurl="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" _djrealurl="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
<br>>
> </div>
</div>
</div>
<br>>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>>
<pre wrap="">> _______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" _djrealurl="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" _djrealurl="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
<br>>
</div>
</div>
</div>