Forum Discussion
Strip escape \ from session variable
In APM Access Policy, I am trying to map a drive based on a user's AD Homedirectory attribute. The result of the attribute is \\server\share\folder1\username
This is the custom expression I am using.
homedirectory = expr { [mcget {session.ad./DEFAULT/Multi_Domain_Auth_act_active_directory_query_12_ag.attr.homeDirectory}] }
How would I go about stripping the escape backslashes from the path?
Any help would be appreciated.
5 Replies
- Henrik_Gyllkran
Nimbostratus
If it always contains those double backslashes you could try this:
homedirectory = expr { [string range [mcget {session.ad./DEFAULT/Multi_Domain_Auth_act_active_directory_query_12_ag.attr.homeDirectory}] 1 end] }
- Marco_Bayarena_
Altostratus
This just stripped the first \ leaving \\server\share\folder1\username.
Support recommended adding -decode after mcget: expr { [mcget -decode {session.ad./DEFAULT/Multi_Domain_Auth_act_active_directory_query_12_ag.attr.homeDirectory}] }
That didn't make any difference. It might not work with v11.6 Engineering HF5.
V12.0 399693 It is now possible to use the -decode option for mcget command of a branch rule to decode a session variable before using it. When you create an agent and add a branch rule, the default value of the rule contains an mcget command to fetch the session variable. By default, the session variable is HEX encoded if it contains non-ASCII characters. You need to modify the command in advanced mode and insert the -decode option for mcget command, for example: expr { [mcget -decode {session.ad.last.attr.memberOf}] contains "non-ASCII-characters" }
- Marco_Bayarena_
Altostratus
Correction, the first line should state: \\\server\\share\\folder1\\username.
- Henrik_Gyllkran
Nimbostratus
Sorry, didn't read the text properly and thought that string was just the folder path that jsut got an extra backslash. Didn't see that it referred to a servername as well.
- Henrik_Gyllkran
Nimbostratus
I'm not one to willingly admit defeat so try this:
homedirectory = expr {[string map { \\\\ \\ } [mcget {session.ad./DEFAULT/Multi_Domain_Auth_act_active_directory_query_12_ag.attr.homeDirectory}]]}
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