Forum Discussion

Jcan_4445_38285's avatar
Icon for Nimbostratus rankNimbostratus
Feb 11, 2019

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, I want to assign 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?


2 Replies

  • You can try with this

          ACCESS::session data set session.custom.mail [URI::query [HTTP::uri] User]     
  • Fatim's avatar
    Icon for Nimbostratus rankNimbostratus

    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:

    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:

    1. When an APM session is started, the iRule sets the uri variable to the current URI.

    2. The query variable is set to the query string portion of the URI.

    3. The userid variable is set to the value of the User parameter in the query string, using a regular expression to extract it.

    4. 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.

    5. 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.