Captain
Captain
380 views

best mode to use for number comparison - numeric or case insensitive

Jump to solution

I have a rule in most of my AD drivers where I am wanting to do a simple number comparison using the 'less than' operator. What mode is the best  to use.....'case insensitive' or 'numeric' .....they both seem to produce the correct outcome and properly comparing the two numbers...just not sure if there is a pro/con to using one over the other.

 

code rule:

?xml version="1.0" encoding="UTF-8"?><policy>
<rule>
<description>sub-ctp-set AttributesSet local variable if eDir PW is expired</description>
<comment xml:space="preserve">This rule will set a local variable if the passwordExpirationTime is less than the current time, the local variable will be used in the OTP of this driver.</comment>
<conditions>
<and>
<if-class-name mode="nocase" op="equal">User</if-class-name>
<if-op-attr name="Password Expiration Time" op="available"/>
</and>
</conditions>
<actions>
<do-set-local-variable name="currTime" scope="policy">
<arg-string>
<token-time format="!CTIME" tz="UTC"/>
</arg-string>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-attr mode="numeric" name="Password Expiration Time" op="lt">$currTime$</if-attr>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="passwordExpired" scope="driver">
<arg-string>
<token-text xml:space="preserve">true</token-text>
</arg-string>
</do-set-local-variable>
</arg-actions>
<arg-actions>
<do-set-local-variable name="passwordExpired" scope="driver">
<arg-string>
<token-text xml:space="preserve">false</token-text>
</arg-string>
</do-set-local-variable>
</arg-actions>
</do-if>
</actions>
</rule>
</policy>

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Captain
Captain

Thank you everyone for the reply......I will use numeric

View solution in original post

0 Likes
5 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

I think that for simple numbers, same number of digits, or even complex ones, for same number of digits (like CTIME) should be fine. 

But when you compare 1 to 10, or the like, I am not sure it will work correct.

0 Likes
Captain
Captain

I'm sorry.....I didn't see the answer in your comment. Are you saying that you think numeric works best for like 1 to 10 compare but that 'case insensitive' would more than likely be fine for CTIME ?

0 Likes
Vice Admiral
Vice Admiral

They are only the same if they are the same number of digits.

If it's case insensitive, 2 > 10 (worng)

If it's numeric, 2 < 10 (correct)

0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner
Always do numeric compare on numbers.
The problem is that sooner or later you stumble up on that one when it does not work.

Numeric always work.
0 Likes
Captain
Captain

Thank you everyone for the reply......I will use numeric

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.