Forum Discussion
parse username
I am trying to get only the UserID with the following iRule, but I end up getting it and also the password and I only want the UserID. Can someone help me, this is driving me crazy!
when HTTP_REQUEST_DATA { if {([HTTP::payload] contains "UserID")} { set UserID "unknown" foreach x [split [[HTTP::payload]] "&"] { if { $x starts_with "UserID=" } { set UserID [lindex [split $x "="] 1] } }
log local0. "User $UserID attempted login from [IP::client_addr] and referer: [HTTP::header "Referer"]"
} }
And I get the following result:
TCL error: /Common/LOG-User - invalid command name "UserID=abcdef&Password=password1234&destination=&saveDestination=false" while executing "[HTTP::payload]"
- Kevin_Davies
Nacreous
Updated iRule using findstr...
when HTTP_REQUEST_DATA { Set UserID [findstr [HTTP::payload] "UserID=" 7 "&"] log local0. "User $UserID attempted login from [IP::client_addr] and referer: [HTTP::header "Referer"]" }
Does that work better for you?
- Stanislas_Piro2
Cumulonimbus
Hi,
you can use following code:
when HTTP_REQUEST_DATA { set UserID [URI::query "?[HTTP::payload]" "UserID"] log local0. "User $UserID attempted login from [IP::client_addr] and referer: [HTTP::header "Referer"]" }
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