cancel
Showing results for 
Search instead for 
Did you mean: 

Modify APM variable value

Squeak
Cirrus
Cirrus

Hello,

 

I have a variable that contains a 12 digit numeric value and I want to add a hyphen between the 8th and 9th digits.

The variable looks like this at the moment,

E.g

109511158543

 

I want it to look like this.

 

10951115-8543

 

The variable are a Active Directory attribute and the numeric value are different for different users.

 

Any takes?

 

//Cheers Mike

1 ACCEPTED SOLUTION

I guess 😉

 

here are my tests:

 

variable assign:

 

1 - session.custom.source = Text 109511158543 

2 - session.custom.target = join [scan [mcget {session.custom.source}] "%8s%4s"] "-"

 

After authenticationI have following variables:

session.custom.source 109511158543

session.custom.target 10951115-8543

View solution in original post

6 REPLIES 6

NUT2889
Cirrostratus
Cirrostratus

Hi,

 

I'm not sure the expression under APM visual policy is support or not.

 

But i have one idea for you.

  • Use the APM to call iRule : https://support.f5.com/csp/article/K13296
  • Use iRule to replace the value : https://devcentral.f5.com/s/articles/intermediate-irules-handling-strings-20429

Stanislas_Piro2
Cumulonimbus
Cumulonimbus

You can add a variable assign in VPE, with expression like

set var [mcget {session.xxx.xxx}] return "[string range $var 0 7]-[string range $var 8 end]"

 

Or even better

 

join [scan [mcget {session.xxx.xxx}] "%8s%4s"] "-"

 

I tried your solution but I didn´t get it to work. I added a Variable assign in the VPE like this,

session.session.custom.xx = join [scan [mcget {session.session.session.custom.xx}] "%8s%4s"] "-"

Or maybe I did something wrong?

 

//Mike

I guess 😉

 

here are my tests:

 

variable assign:

 

1 - session.custom.source = Text 109511158543 

2 - session.custom.target = join [scan [mcget {session.custom.source}] "%8s%4s"] "-"

 

After authenticationI have following variables:

session.custom.source 109511158543

session.custom.target 10951115-8543

Hello,

 

I tried your solution and it worked like a charm. Thanks Stanislas