Forum Discussion
Assign a variable based on AD query
I think I have this figured it but was hoping to get a sanity check.
I have an access policy that is querying AD. Later on I am sending an email to the user but there are two potential email fields.
If the user has f5EmailAddress as an AD attribute then I need to use that - if they don’t then I need to use session.ad.last.email.
I think this should just be a variable assignment after the AD query but I’m not sure if my syntax is correct.
Here’s what I have (forgive me in advance I’m writing this on an iPhone)
session.custom.company.email = if { ( [mcget {session.ad.last.attr.f5ProfileEmailAddress}] contains “@“)} { return ([mcget {session.ad.last.attr.f5ProfileEmailAddress }]} else { return ([mcget {session.ad.last.attr.email}])}
- dp_119903Cirrostratus
...I should add my approach here is to just assign a custom variable session.custom.company.email - and have that variable be what is in the “to” field on the email.
So my hope is that this logic will look and see if there is the f5EmailAddress variable and if there is assign it to the custom field and if not then assign the regular AD email field.
Looks good to me!
if { ( [mcget {session.ad.last.attr.f5ProfileEmailAddress}] contains “@“)} { return ([mcget {session.ad.last.attr.f5ProfileEmailAddress }]) } else { return ([mcget {session.ad.last.attr.email}]) }
For some good examples, check these code snippets from Stanislas:
https://devcentral.f5.com/codeshare/apm-variable-assign-examples-1107
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com