Forum Discussion
Bhargav_9588
Nimbostratus
Feb 15, 2010getfield Parsing error
Hello,
I am trying to add an iRule to insert an http header value by stripping out domain from REMOTE_USER header. The following is the iRule I am trying to use:
when HTTP_REQUEST {
set login_user [HTTP::header remote_user ]
if { $login_user contains "\" } {
set ldap_user [getfield $login_user "\" 2]
HTTP::header replace SAPUserID $ldap_user
}
}
But it is throwing the following parsing error while saving:
01070151:3: Rule [insert.header.rule] error:
line 4: [parse error: missing "] ["\" 2]
HTTP::header replace SAPUserID $ldap_user
Any help is appreciated. Thanks in advance.
- Most likely the problem is that the backslash character is an escape sequence (ie. \n for newline, \t for tab, etc). Try adding a second slash to your comparisons.
when HTTP_REQUEST { set login_user [HTTP::header remote_user ] if { $login_user contains "\\" } { set ldap_user [getfield $login_user "\\" 2] HTTP::header replace SAPUserID $ldap_user } }
- hoolio
Cirrostratus
What kind of authentication are you using? - Aaron, somehow it doesn't even phase me that you know that from the top of your head that the base64 decoded string of "QWxhZGRpbjpvcGVuIHNlc2FtZQ==" is "Aladdin:open sesame" B-).
- Bhargav_9588
Nimbostratus
Thanks for your quick response. Parsing error was resolved after adding another backslash. This is how the script looks like: - Bhargav_9588
Nimbostratus
I see the AUTH_TYPE as "NTLM". - Bhargav_9588
Nimbostratus
Is there anyway to get a CGI REMOTE_USER value into a variable in iRule? - hoolio
Cirrostratus
NTLM is a bit more complicated than basic auth. The encoded username and domain is only included on type 3 messages. If the client uses the same connection for multiple HTTP requests, I think the type 3 message will only be sent on the first request/challenge/response exchange. So if you need to insert something from the username or domain in a custom HTTP header for every request, you might need to save the parsed username and manually insert it even if the authorization header isn't present for the current request. - hoolio
Cirrostratus
Actually, joelmoses added a very useful example iRule which parses NTLM auth headers by message type: Posted By Bhargav on 02/16/2010 9:30 AM
- Bhargav_9588
Nimbostratus
Thanks Aaron for your input.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects