# APM access::session question

**URL:** <https://community.f5.com/t/apm-access-session-question/38911>\
**Category:** Technical Forums\
**Tags:** big-ip-access-policy-manager-apm, irules, devops, security, application-delivery\
**Created:** [September 30, 2013, 10:05pm UTC](https://community.f5.com/t/apm-access-session-question/38911 "2013-09-30T22:05:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dietmar\_Moltner](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@Dietmar\_Moltner](https://community.f5.com/u/Dietmar_Moltner)\
**Post date:** [September 30, 2013, 10:05pm UTC](https://community.f5.com/t/apm-access-session-question/38911/1 "2013-09-30T22:05:43Z")

</div>

Hi all,

I am currently creating an APM policy (we are using 11.3) which uses a LDAP query to read several attributes from the authenticated user into the session variables “session.ldap.last.attr.xxx” (Example: the shortname of the user from Ldap is stored as “session.ldap.last.attr.shortname”). Is there any chance to read all attributes being located under “session.ldap.last.attr”? It would be perfect if I could read all “keys” under session.ldap.last.attr so that I can access the different Ldap attributes from iRules dynamically.

Any ideas on that?

Thx in advance for your support

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [October 1, 2013, 1:13am UTC](https://community.f5.com/t/apm-access-session-question/38911/2 "2013-10-01T01:13:36Z")

</div>

Unfortunately, the APM session table doesn’t expose its elements like a collection or list, so you must address variables explicitly.

---

<div class="post-metadata">

**Author:** ![Dietmar\_Moltner](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@Dietmar\_Moltner](https://community.f5.com/u/Dietmar_Moltner)\
**Post date:** [October 14, 2013, 5:09pm UTC](https://community.f5.com/t/apm-access-session-question/38911/3 "2013-10-14T17:09:25Z")

</div>

Kevin,

thx for your fast response. Maybe there is another way to achieve tha goal: my intention is to add the related LDAP attributes within the policy (AD query) and find this set of LDAP attributes in the session to inject it in the traffic to the backend as headers. Idea is to set the list of LDAP attributes only at one point in the policy so that the solution is dynamic i.e. I do not want to hardcode the attribute names also within the irule

Any further ideas on that?

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [October 14, 2013, 6:43pm UTC](https://community.f5.com/t/apm-access-session-question/38911/4 "2013-10-14T18:43:43Z")

</div>

That isn’t going to be easy. The APM session table is neither a list nor an array, and cannot be queried for “all matching values”. The LDAP attributes will fill the table upon a successful query and will be available, by name, from that point forward.

That said, you could technically create a list object beforehand of all the LDAP objects that you care about, then cycle through them. Example:

```tcl
when ACCESS_ACL_ALLOWED {
    set ldaplist [list "cn" "sn" "description" "whenCreated" "whenChanged" "displayName" "name" "objectGUID" "lastLogoff" "lastLogon" "primaryGroupID" "objectSid" "sAMAccountName" "userPrincipalName"]

    foreach x $ldaplist {
        HTTP::header insert $x [ACCESS::session data get session.ldap.last.attr.$x]
    }
}

```

---

<div class="post-metadata">

**Author:** ![Dietmar\_Moltner](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@Dietmar\_Moltner](https://community.f5.com/u/Dietmar_Moltner)\
**Post date:** [October 14, 2013, 6:50pm UTC](https://community.f5.com/t/apm-access-session-question/38911/5 "2013-10-14T18:50:11Z")

</div>

Got it, thing is is a valid option for - thx a lot for your support
