Forum Discussion
Extract email from uri in APM
In APM I'm trying to extract email from uri and assign it to custom variable, but without luck
basically from URL https://web.domain1.com/?User=user3@AnotherDomain.com&variable2=blabla, I want to assign user3@AnotherDomain.com to variable userid.
I tried something like this: mcget {URI::query [HTTP::uri] User} return
But no results (but I'm sort of newbie to bigip) Any suggestions?
- Stanislas_Piro2Cumulonimbus
You can try with this
when ACCESS_SESSION_STARTED { ACCESS::session data set session.custom.mail [URI::query [HTTP::uri] User] }
- FatimNimbostratus
It looks like you are using F5 BIG-IP APM (Access Policy Manager) to extract the email address from a URI and assign it to a custom variable. It works similarly like to export LinkedIn contacts to excel. Here's an example iRule that should work:
when ACCESS_SESSION_STARTED {
set uri [HTTP::uri]
set query [URI::query $uri]
set userid [lindex [regexp -inline {User=([^&]+)} $query] 1]
if {$userid ne ""} {
set session_data(userid) $userid
}
}Here's how this iRule works:
When an APM session is started, the iRule sets the uri variable to the current URI.
The query variable is set to the query string portion of the URI.
The userid variable is set to the value of the User parameter in the query string, using a regular expression to extract it.
If a userid value is found, it is stored in the session_data(userid) variable, which is a custom session variable that you can use in subsequent APM policies or iRules.
You can modify the iRule to assign the userid variable to your custom variable userid instead of session_data(userid) if you prefer.
Make sure to attach this iRule to your APM virtual server. You can do this in the BIG-IP Configuration utility by going to Local Traffic > Virtual Servers > [your APM virtual server] > Resources > iRules > Edit > Add.
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