Forum Discussion

tdaish's avatar
tdaish
Icon for Altostratus rankAltostratus
Aug 15, 2023

APM AdAuth HTTP Header Insert iRule Switch Statement

Hi folks, first forum post here, looking for a hand with iRules!  Currently when a user connects from their PC to the Virtual Server, as part of the Access Policy they are presented with an Logon Pa...
  • PeteWhite's avatar
    Aug 17, 2023

    As Jason said, there are many ways to do this and your method looks fine.  But note your typo in IP::client_addr. And it is good practise to use -- to terminate switch options.

    You could also do this by checking whether the header already exists

    when ACCESS_ACL_ALLOWED
    {
         if { ! [HTTP::header exists iv-user] } {
              HTTP::header insert "iv-user" [ACCESS::session data get "session.logon.last.username"] }
         }
    }

     

  • tdaish's avatar
    tdaish
    Aug 21, 2023

    Doh! My bad, thanks for that. I did find that the F5 does not like:

    // do nothing

     within those braces, so I have omitted the contents and left it as:

    when ACCESS_ACL_ALLOWED
    {
         switch -- [IP::client_addr] {
              "10.0.0.1" -
              "10.0.0.2" {}
         default {
              HTTP::header insert "iv-user" [ACCESS::session data get "session.logon.last.username"] }
         }
    }

    This should be okay right?