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!

Try “ne”, like

expr { [mcget {session.logon.last.usnername}] ne "" }

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” }

Please see if this helps.

expr { [string match -nocase *external* [mcget {session.ad.last.attr.mail}]] == 0 }

It works!

Thanks a lot!

how does it work, please provide solutions for others.

The answer posted by kunjan: expr { [string match -nocase *external* [mcget {session.ad.last.attr.mail}]] == 0 }

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.

try this:

expr { [string match -nocase {*AD Group Name*} [mcget {session.ad.last.attr.memberOf}]] == 0 }

That did the trick.

Thanks!!