Forum Discussion
iRule to replace NetBIOS-Name with sAMAccountName
All,
I have an iOS app (qlikview 2.1) that is sometimes sending the NetBIOS-Name rather than the sAMAccountName. I am trying to create an iRule to check for this and do a replacement. I am receiving the following error when saving the iRule:
01070151:3: Rule [/Common/qlikview_username_fix] error: /Common/qlikview_username_fix:7: error: [wrong args][HTTP::username replace "$username" "$user"]
Has anyone done this and what am I doing wrong?
Here is my iRule: when HTTP_REQUEST {
if {[string tolower [HTTP::username]] starts_with "domainname"} { set username [string tolower [HTTP::username]] set user [getfield $username "/" 2] set domain [getfield $username "/" 1] HTTP::username replace $username $user} }
Thank you
2 Replies
- Michael_Jenkins
Cirrostratus
According to the wiki page for HTTP::username, it's a read-only command, so you can't update the username with that command. Here's spin off of what I've done in the past that may work for you:
when HTTP_REQUEST { if { [HTTP::header exists "Authorization"] && [HTTP::header value "Authorization"] starts_with "Basic " } { Basic Authentication log local0. " Authorization: [HTTP::header value "Authorization"]" log local0. " Username: [HTTP::username]" log local0. " Password: [HTTP::password]" Parse the username set user [getfield [string tolower [HTTP::username]] "\" 2] Recreate the Authorization header set newAuth "${user}:[HTTP::password]" set newAuthEnc [b64encode $newAuth] HTTP::header replace "Authorization" "Basic $newAuthEnc" Remove the variables unset newAuth unset newAuthEnc unset user } }NOTE: I saw you were using
in your"/"
command. Was that intentional or did you mean to usergetfield
which is used for domain\username notation?"\" - Baddogsettle_16
Nimbostratus
With the help from F5 support, I found a way to fix this in the VPE...I added a check to see if session.logon.last.username starts_with "domain":
If true, do variable assign prior to AD auth: Custom Variable: session.logon.last.username Custom Expression: return [lindex [split [mcget {session.logon.last.username}] "/"] 1]
If false, do AD auth.
This seems to work.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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