Forum Discussion

Franco_30420's avatar
Franco_30420
Icon for Nimbostratus rankNimbostratus
May 13, 2014

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's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

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

     

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    Please see if this helps.

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

    • boneyard's avatar
      boneyard
      Icon for MVP rankMVP
      how does it work, please provide solutions for others.
    • Franco_30420's avatar
      Franco_30420
      Icon for Nimbostratus rankNimbostratus
      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.

     

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    try this:

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