Forum Discussion
APM - Negate an expr
Hi,
I would like to negate an expr in my VPE, so i can test that a session variable does not contain a specific string.
I have tried to set the negation logical operator (! or "not") but it does not seem to work.
Thank you by advance!
9 Replies
- kunjan
Nimbostratus
Try "ne", like
expr { [mcget {session.logon.last.usnername}] ne "" } - Franco_30420
Nimbostratus
Yes but ne is a strict comparison.
for example i would need something like: expr { [string tolower [mcget {session.ad.last.attr.mail}]] not contains "external" }
- kunjan
Nimbostratus
Please see if this helps.
expr { [string match -nocase *external* [mcget {session.ad.last.attr.mail}]] == 0 } - Franco_30420
Nimbostratus
It works!
Thanks a lot!- how does it work, please provide solutions for others.
- Franco_30420
Nimbostratus
The answer posted by kunjan: expr { [string match -nocase *external* [mcget {session.ad.last.attr.mail}]] == 0 }
- nirobi03_194837
Nimbostratus
I was having a similar issue and that worked for me as well. I wanted to assign Portal Access to all users unless they are in a specific AD Group.
I had an issue with spaces in the string. I had the ability to re-name the AD Group and removed spaces, but I am sure there is a way to make it work with spaces.
expr { [string match -nocase * AD Group Name * [mcget {session.ad.last.attr.memberOf}]] == 0 }
- didnt work with spaces
expr { [string match -nocase * "AD Group Name" * [mcget {session.ad.last.attr.memberOf}]] == 0 }
- didnt work with spaces and quotes
expr { [string match -nocase * ADGroupName * [mcget {session.ad.last.attr.memberOf}]] == 0 }
- Since I was able to change the AD name, worked without spaces
If somebody would be able to provide an answer for getting this to work with spaces, that will be beneficial since changing the name or value isn't always possible.
- kunjan
Nimbostratus
try this:
expr { [string match -nocase {*AD Group Name*} [mcget {session.ad.last.attr.memberOf}]] == 0 } - nirobi03_194837
Nimbostratus
That did the trick.
Thanks!!
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