Forum Discussion
John_Masgalas_4
Nimbostratus
Jan 30, 2009iRule modification - rdp
I currently use the below iRule with our Terminal Services pool. It strips everything after the "@" in the username so that the persistence entry is only the username. I would like to modify it so that usernames that are entered in the form "domain\username" are also entered in the table with just the username. In toehr words I weould like the iRule to strip out everything before the "/". How would I do this? Can someone help?
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
TCP::collect 25
binary scan [TCP::payload] x11a* msrdp
log local0. "Contents after binary scan: $msrdp"
if { [string equal -nocase -length 17 $msrdp "cookie: mstshash="] } {
set msrdp [string range $msrdp 17 end]
set len [string first "\n" $msrdp]
if { $len == -1 } {
TCP::collect
return
}
if { $msrdp contains "@" } {
if { $len > 5 } {
incr len -1
log local0. "Data Persisting on: [getfield $msrdp "@" 1]"
persist uie [getfield $msrdp "@" 1] 10800
}
} else { persist uie $msrdp 10800}
}
TCP::release
}
- John_Masgalas_4
Nimbostratus
UnRuleY and citizen_elah were the ones that wrtoe the iRule for me so if you guys are still around can you help me out? Thanks! - JRahm
Admin
Yep, I'm still lurking...can you post some examples (sanitized) of the contents of msrdp immediately after the binary scan? - John_Masgalas_4
Nimbostratus
here is whats in the ltm log: - JRahm
Admin
You should be able to check for the presence of the backslash, and if present, split on it and take everything in the second field as your persistence value. If you just want the username, and not the @..., you could do a secondary split on the @ and keep the first field. - John_Masgalas_4
Nimbostratus
So I could do that in the same iRule? How would I do it. I'm not very good with iRules. - hoolio
Cirrostratus
If the string you're trying to parse can have three forms:if {$account contains "@"}{ set account [getfield $account "@" 1] } elseif {$account contains "\\"}{ Need to escape the backslash with a backslash set account [getfield $account "\\" 1] }
- John_Masgalas_4
Nimbostratus
OK. So I took hoolio's idea and came up with the below iRule. However it strips everything after the \ instead of before. So a username of domain\username becomes domain. - hoolio
Cirrostratus
Can you log the $msrdp value before you modify it?if { [string equal -nocase -length 17 $msrdp "cookie: mstshash="] } {
if { [string equal -nocase -length 17 $msrdp "cookie: mstshash="] } { log local0. "\$msrdp: $msrdp"
- John_Masgalas_4
Nimbostratus
It does log it after the scan. Adding the log command just duplicates it. It does correctly recognize the usernames. - John_Masgalas_4
Nimbostratus
Here is the output of the other versions of the username 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