Forum Discussion

Ronak_79648's avatar
Ronak_79648
Icon for Nimbostratus rankNimbostratus
Feb 09, 2012

no such variable and variable scope

running v 11.1

 

i have rule.

 

 

when ACCESS_POLICY_AGENT_EVENT {

 

log local0. "Access policy event triggered."

 

if {[ACCESS::policy agent_id] == "LogonSuccess"} {

 

log local0. "Access policy LogonSuccess"

 

set redir 1

 

}

 

}

 

when HTTP_REQUEST {

 

log local0. "HTTP Request detected. [HTTP::uri]"

 

if {$redir == 1} {

 

log local0. "Redir was 1, redirecting"

 

HTTP::redirect https://abc.com/xyz

 

}

 

}

 

 

looking for suggestion on how to make this work. i want to redirect to something based on access policy event.

 

 

i have apm policy assigned to domain test and once autheticated want to go to https://abc.com/xyz

 

trying to implement portal with SSO

 

 

Feb 9 15:07:14 tmm1 info tmm1[8947]: Rule /Common/iRule_abc : Access policy event triggered.

 

Feb 9 15:07:14 tmm1 info tmm1[8947]: Rule /Common/iRule_abcd : Access policy LogonSuccess

 

Feb 9 15:07:14 tmm2 info tmm2[8948]: Rule /Common/iRule_abc

 

: HTTP Request detected. /

 

Feb 9 15:07:14 tmm2 err tmm2[8948]: 01220001:3: TCL error: /Common/iRule_RedirectToPulseSSO - can't read "redir": no such variable while executing "if {$redir == 1} { log local0. "Redir was 1, redirecting" HTTP::redirect https://abc.com/clarian/layoutTemplates/html/access/ssoLog..."

 

 

  • I could be wrong, but it seems like the events as you have them are out of order. You are using a local variable so once you set it, you should be able to call it using that same VIP/connection, but if HTTP_REQUEST is happening before the other event processes then I think you would see what you are seeing there. It can't read the variable because nothing is there. The iRule logging is taking place in the order which you have it in the iRule, but the execution doesn't seem to be following that particular order.

     

     

    Here is a good iRule that may get you going in the right direction, check out the order of events on that:

     

    http://devcentral.f5.com/wiki/iRules.APM-Portal-Host-Rewrite.ashx

     

     

     

  • we found better way to do same. here is how iRule look like

     

     

     

    when ACCESS_POLICY_COMPLETED

     

    {

     

    ACCESS::respond 301 Location "https://fqdn/URI/Login.jsp"

     

    }