For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Marco_Bayarena_'s avatar
Marco_Bayarena_
Icon for Altostratus rankAltostratus
Nov 04, 2015

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

  • 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] }

     

  • 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_'s avatar
      Marco_Bayarena_
      Icon for Altostratus rankAltostratus
      Correction, the first line should state: \\\server\\share\\folder1\\username.
  • 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.

     

  • 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}]]}