<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 Roman,<br>
      <br>
      it's a bit more complicated. We distinguish between <b>assigned</b>
      resource object and <b>linked</b> resource object.<br>
      <br>
      Linked resource objects describe the state "as is". Assigned ones
      describe the state "as should be".<br>
      See also <a
        href="https://wiki.evolveum.com/display/midPoint/Assigning+vs+Linking">https://wiki.evolveum.com/display/midPoint/Assigning+vs+Linking</a>.<br>
      <br>
      Assigned resource object is stored in the <assignment> item,
      and shown in GUI under "Assignments" (along with assigned roles
      and orgs).<br>
      Linked resource object is stored in <linkRef> item, and show
      in GUI under "Accounts".<br>
      <br>
      From your question I thought you are asking about assigned
      accounts.<br>
      If you would like to refer to linked accounts, you can use
      something like this:<br>
      <br>
      <tt>   <mapping></tt><tt><br>
      </tt><tt>      <strength>strong</strength></tt><tt><br>
      </tt><tt>      <source></tt><tt><br>
      </tt><tt>         <c:path>linkRef</c:path></tt><tt><br>
      </tt><tt>      </source></tt><tt><br>
      </tt><tt>      <expression></tt><tt><br>
      </tt><tt>         <value>Here we are</value></tt><tt><br>
      </tt><tt>      </expression></tt><tt><br>
      </tt><tt>      <target></tt><tt><br>
      </tt><tt>         <c:path>description</c:path></tt><tt><br>
      </tt><tt>      </target></tt><tt><br>
      </tt><tt>      <condition></tt><tt><br>
      </tt><tt>         <script></tt><tt><br>
      </tt><tt>           
        <relativityMode>absolute</relativityMode></tt><tt><br>
      </tt><tt>            <code></tt><tt><br>
      </tt><tt>                import
        com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType</tt><tt><br>
      </tt><tt>                import
        com.evolveum.midpoint.schema.SelectorOptions</tt><tt><br>
      </tt><tt>                import
        com.evolveum.midpoint.schema.GetOperationOptions</tt><tt><br>
      </tt><tt>                </tt><tt><br>
      </tt><tt>                log.info('linkRef = {}',
        linkRef)          // this is a PrismContainer</tt><tt><br>
      </tt><tt>                for (singleLinkRef in
        linkRef.getValues()) {</tt><tt><br>
      </tt><tt>                    log.info('checking {}',
        singleLinkRef)</tt><tt><br>
      </tt><tt>                    oid = singleLinkRef.oid</tt><tt><br>
      </tt><tt>                    options =
        SelectorOptions.createCollection(GetOperationOptions.createNoFetch())</tt><tt><br>
      </tt><tt>                    try {</tt><tt><br>
      </tt><tt>                        shadow =
        midpoint.getObject(ShadowType.class, oid, options)</tt><tt><br>
      </tt><tt>                    } catch (Exception e) {</tt><tt><br>
      </tt><tt>                        log.error('got exception: {}', e)</tt><tt><br>
      </tt><tt>                        shadow = null</tt><tt><br>
      </tt><tt>                    }</tt><tt><br>
      </tt><tt>                    resourceOid =
        shadow?.resourceRef?.oid</tt><tt><br>
      </tt><tt>                    log.info('resource oid = {}',
        resourceOid)</tt><tt><br>
      </tt><tt>                    if (resourceOid?.equals("<font
          color="#cc0000"><b>.....given resource oid.......</b></font>"))
        {</tt><tt><br>
      </tt><tt>                        return true</tt><tt><br>
      </tt><tt>                    }</tt><tt><br>
      </tt><tt>                }</tt><tt><br>
      </tt><tt>               false</tt><tt><br>
      </tt><tt>               </code></tt><tt><br>
      </tt><tt>         </script></tt><tt><br>
      </tt><tt>      </condition></tt><tt><br>
      </tt><tt>   </mapping></tt><tt><br>
      </tt><br>
      Or, you can take inspiration from MidpointFunctionsImp.
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      countAccounts method.<br>
      <br>
      Hope this helps,<br>
      Pavol<br>
      <br>
      <br>
    </div>
    <blockquote cite="mid:558D5FFF.6030203@ami.cz" type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      Hi Pavol,<br>
      thanks for Your answer.<br>
      I tried many tests about resources assignments, but no success.<br>
      Assigments to resources are saved as ShadowType in user object in
      link refs, but they have no resources oid's.<br>
      How to get resource oid's?<br>
      <br>
      Thanks!<br>
      Regards<br>
      Roman Pudil<br>
      <div class="moz-signature">
        <title></title>
        <meta http-equiv="Content-Type" content="text/html;
          charset=utf-8">
        <p> </p>
        <table style="border-collapse:collapse;">
          <tbody>
            <tr>
              <td colspan="2" style="font-family:Arial, sans-serif;
                font-size:11px; color:#000000; vertical-align:bottom;">
                <p> <span style="font-size:14px; font-weight:bold;">Roman

                    Pudil</span><br>
                  solution architect<br>
                  <br>
                  gsm: [+420] 775 663 666<br>
                  e-mail: <a moz-do-not-send="true"
                    href="mailto:roman.pudil@ami.cz">roman.pudil@ami.cz</a>
                </p>
              </td>
              <td style="border-right:1px solid #cccccc;">   </td>
              <td>   </td>
              <td style="font-family:Arial, sans-serif; font-size:11px;
                color:#000000; vertical-align:bottom;">
                <p> AMI Praha a.s.<br>
                  Pláničkova 11<br>
                  162 00 Praha 6<br>
                  tel./fax: [+420] 274 783 239<br>
                  web: <a moz-do-not-send="true"
                    href="http://www.ami.cz">www.ami.cz</a> </p>
              </td>
              <td style="border-right:1px solid #cccccc;">   </td>
              <td>   </td>
              <td style="font-family:Arial, sans-serif; font-size:11px;
                color:#000000;">
                <p> <img src="cid:part4.08090704.06010400@evolveum.com"
                    alt="AMI Praha a.s." title="AMI Praha a.s."> </p>
              </td>
            </tr>
            <tr>
              <td colspan="8"><br>
                <a moz-do-not-send="true"
href="http://www.ami.cz/reseni-a-sluzby/bezpecnost-dat/identity-management"><img
                    src="cid:part5.03030604.00040402@evolveum.com"
                    alt=""></a></td>
            </tr>
            <tr>
              <td colspan="8" style="font-family:Arial, sans-serif;
                font-size:11px; color:#808080;"> <br>
                Textem tohoto e-mailu podepisující neslibuje uzavřít ani
                neuzavírá za společnost AMI Praha a.s.<br>
                jakoukoliv smlouvu. Každá smlouva, pokud bude uzavřena,
                musí mít výhradně písemnou formu.</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="moz-cite-prefix">Dne 26.6.2015 v 11:06 Pavol Mederly
        napsal(a):<br>
      </div>
      <blockquote cite="mid:558D161C.1010100@evolveum.com" type="cite">
        <meta content="text/html; charset=utf-8"
          http-equiv="Content-Type">
        <div class="moz-cite-prefix">Roman,<br>
          <br>
          very quickly, because I have to go just now:<br>
          <br>
          I would check directly the assignments, like this:<br>
          <br>
          (This is a quickly hacked mapping that assigns "Directly under
          root" value for all Orgs that have assignment with a given
          targetRef. For resources, you have to work with
          getConstruction().getResourceRef().)<br>
          <br>
          <tt>   <mapping></tt><tt><br>
          </tt><tt>      <strength>strong</strength></tt><tt><br>
          </tt><tt>      <source></tt><tt><br>
          </tt><tt>         <c:path>assignment</c:path></tt><tt><br>
          </tt><tt>      </source></tt><tt><br>
          </tt><tt>      <expression></tt><tt><br>
          </tt><tt>         <value>Directly under
            root</value></tt><tt><br>
          </tt><tt>      </expression></tt><tt><br>
          </tt><tt>      <target></tt><tt><br>
          </tt><tt>         <c:path>description</c:path></tt><tt><br>
          </tt><tt>      </target></tt><tt><br>
          </tt><tt>      <condition></tt><tt><br>
          </tt><tt>         <script></tt><tt><br>
          </tt><tt>           
            <relativityMode>absolute</relativityMode></tt><tt><br>
          </tt><tt>            <code></tt><tt><br>
          </tt><tt>                   log.info('assignment = {}',
            assignment)          // assignment is a PrismContainer</tt><tt><br>
          </tt><tt>                   for (assignmentValue in
            assignment.getValues()) {</tt><tt><br>
          </tt><tt>                        log.info('checking {}',
            assignmentValue)</tt><tt><br>
          </tt><tt>                        targetRef =
            assignmentValue.asContainerable().getTargetRef()</tt><tt><br>
          </tt><tt>                        if
            (targetRef?.getOid()?.equals("98f0f92d-d4d3-465e-840e-69ef12724013"))
            {      // OID is the root OU</tt><tt><br>
          </tt><tt>                            log.info('Yes')</tt><tt><br>
          </tt><tt>                            return true</tt><tt><br>
          </tt><tt>                        }</tt><tt><br>
          </tt><tt>                        log.info('No')</tt><tt><br>
          </tt><tt>                   }</tt><tt><br>
          </tt><tt>                   false</tt><tt><br>
          </tt><tt>               </code></tt><tt><br>
          </tt><tt>         </script></tt><tt><br>
          </tt><tt>      </condition></tt><tt><br>
          </tt><tt>   </mapping></tt><tt><br>
          </tt><br>
          Hope this helps,<br>
          Pavol<br>
          <br>
        </div>
        <blockquote cite="mid:558D05F4.7020807@ami.cz" type="cite">
          <meta http-equiv="content-type" content="text/html;
            charset=utf-8">
          Hi all,<br>
          how to check in mapping (in template object) that user is
          assigned to selected resource?<br>
          What is the right condition?<br>
          <br>
          Thanks!<br>
          Roman Pudil<br>
          <div class="moz-signature">-- <br>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html;
              charset=utf-8">
            <p> </p>
            <table style="border-collapse:collapse;">
              <tbody>
                <tr>
                  <td colspan="2" style="font-family:Arial, sans-serif;
                    font-size:11px; color:#000000;
                    vertical-align:bottom;">
                    <p> <span style="font-size:14px; font-weight:bold;">Roman



                        Pudil</span><br>
                      solution architect<br>
                      <br>
                      gsm: [+420] 775 663 666<br>
                      e-mail: <a moz-do-not-send="true"
                        href="mailto:roman.pudil@ami.cz">roman.pudil@ami.cz</a>
                    </p>
                  </td>
                  <td style="border-right:1px solid #cccccc;">   </td>
                  <td>   </td>
                  <td style="font-family:Arial, sans-serif;
                    font-size:11px; color:#000000;
                    vertical-align:bottom;">
                    <p> AMI Praha a.s.<br>
                      Pláničkova 11<br>
                      162 00 Praha 6<br>
                      tel./fax: [+420] 274 783 239<br>
                      web: <a moz-do-not-send="true"
                        href="http://www.ami.cz">www.ami.cz</a> </p>
                  </td>
                  <td style="border-right:1px solid #cccccc;">   </td>
                  <td>   </td>
                  <td style="font-family:Arial, sans-serif;
                    font-size:11px; color:#000000;">
                    <p> <img
                        src="cid:part9.09090606.03070700@evolveum.com"
                        alt="AMI Praha a.s." title="AMI Praha a.s."> </p>
                  </td>
                </tr>
                <tr>
                  <td colspan="8"><br>
                    <a moz-do-not-send="true"
href="http://www.ami.cz/reseni-a-sluzby/bezpecnost-dat/identity-management"><img
                        src="cid:part10.08080406.07070909@evolveum.com"
                        alt=""></a></td>
                </tr>
                <tr>
                  <td colspan="8" style="font-family:Arial, sans-serif;
                    font-size:11px; color:#808080;"> <br>
                    Textem tohoto e-mailu podepisující neslibuje uzavřít
                    ani neuzavírá za společnost AMI Praha a.s.<br>
                    jakoukoliv smlouvu. Každá smlouva, pokud bude
                    uzavřena, musí mít výhradně písemnou formu.</td>
                </tr>
              </tbody>
            </table>
          </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">midPoint@lists.evolveum.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
        </blockquote>
        <br>
        <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">midPoint@lists.evolveum.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
      </blockquote>
      <br>
      <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>