<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>OK, thanks!</p>
    <p>Finally I've got it working with this condition script:</p>
    <p><condition>                        <br>
              result = false;<br>
              assignments = user.getAssignment();<br>
              for (assName in assignments) {<br>
              relation =
      assName.getTargetRef()?.getRelation()?.getLocalPart()?.toString();<br>
              type =
      assName.getTargetRef()?.getType()?.getLocalPart()?.toString();<br>
              status =
      assName.getActivation()?.getEffectiveStatus()?.toString();<br>
      <br>
              if ( type == 'OrgType' &amp;&amp; relation ==
      'manager' &amp;&amp; status == 'ENABLED' ) { result =
      true; }<br>
              }<br>
              return result;<br>
      </condition><br>
    </p>
    <br>
    <div class="moz-cite-prefix">W dniu 16.03.2018 o 09:17, Ivan Noris
      pisze:<br>
    </div>
    <blockquote type="cite"
      cite="mid:aacdcb10-4cb3-8f02-8ab7-d126704c8576@evolveum.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Hi Wojciech,</p>
      <p>I only did something <i>similar</i> but not exactly what you
        need.</p>
      <p>I wanted to have an conditional inducement in my metarole, that
        would only return true if the role is not assigned with manager
        relation. (Actually this is from the midPoint Advanced
        Customization training.)<br>
      </p>
      <p>. . .</p>
      <p>    <inducement><br>
                <description>Inducement to create an account as a
        projection of user having assigned an organization with this
        metarole.</description><br>
                <construction><br>
                    <description>Creates an account for user, and
        associates with group created for the organization assigned to
        the user.</description><br>
                    <resourceRef
        oid="3961ffc8-2209-11e8-8018-7738b0ea3fa2"
        type="c:ResourceType"/><br>
                    <kind>account</kind><br>
                    <intent>default</intent><br>
                    <association><br>
                    <ref>ri:ldapOrgGroup</ref><br>
                    <outbound><br>
                        <strength>strong</strength><br>
        <b><font color="#3333ff">                <source><br>
                               
            <path>$focusAssignment/targetRef</path><!--
            XXX to get relation --><br>
                            </source><br>
          </font></b>                <expression><br>
                            <associationFromLink><br>
                                <projectionDiscriminator><br>
                                    <kind>entitlement</kind><br>
                                   
        <intent>ldapOrgGroup</intent><br>
                                </projectionDiscriminator><br>
                            </associationFromLink><br>
                        </expression><br>
        <b>                <condition></b><b><br>
        </b><b>                    <script></b><b><br>
        </b><b>                        <code></b><b><br>
        </b><b>import
          com.evolveum.midpoint.schema.constants.SchemaConstants;</b><b><br>
        </b><font color="#3333ff"><b><br>
          </b><b>if (targetRef != null) {</b><b><br>
          </b><b>    //log.info("LDAP Org Metarole targetRef relation
            is: {} ", targetRef.getRelation())</b><b><br>
          </b><b>    if (targetRef.getRelation() !=
            SchemaConstants.ORG_MANAGER) {</b><b><br>
          </b><b>        return true</b><b><br>
          </b><b>    }</b><b><br>
          </b><b>}</b></font><b><br>
        </b><b>                        </code></b><b><br>
        </b><b>                    </script></b><b><br>
        </b><b>                </condition></b><br>
                    </outbound><br>
                </association><br>
                <strength>weak</strength><!-- Will not
        create account unless it already exists --><br>
                </construction>  <br>
                <order>2</order><br>
                <focusType>UserType</focusType><br>
            </inducement><br>
        . . .<br>
      </p>
      I believe you can have a mapping in the object template that will
      have assignments as a source, and you need to iterate through them
      and check all that are OrgType and where relation is org:manager.
      I don't have this handy, but maybe someone else has.<br>
      <br>
      Best regards,<br>
      Ivan<br>
      <br>
      <div class="moz-cite-prefix">On 15.03.2018 20:06, Wojciech
        Staszewski wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:cfed90b6-5317-6fec-e02c-11ac24ac8357@diagnostyka.pl">
        <pre wrap="">Hello!

Maybe I wrote my post somehow unclear...
I'm looking for condition expression for mapping in the user template,
that assign specified role to an organization manager.

So I have to check if the user has an active assignment of Org type with
org:manager relation.
Unfortunately I don't know how to do it, I cannot find any example in
the wiki or mailing list archives.

Any help appreciated.
Thanks a lot!
WS


W dniu 05.03.2018 o 08:38, Wojciech Staszewski pisze:
</pre>
        <blockquote type="cite">
          <pre wrap="">Hello!

I have to make a mapping condition expression that checks if the user
has assignment of Org type with Manager relation.
What methods should I use for this?

Thanks!
WS
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" moz-do-not-send="true">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" moz-do-not-send="true">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
        </blockquote>
        <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" moz-do-not-send="true">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" moz-do-not-send="true">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
Ivan Noris
Senior Identity Engineer
evolveum.com
</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>
  </body>
</html>