Parsing LoginExpirationTime



By: dgersic

January 2, 2008 11:40 am

Reads: 476

Comments:2

Rating:0

Problem

A Forum reader recently asked:

“I’m trying to parse a string in a format “d.M.y” (like 23.12.2007) for Login Expiration Time. Any ideas?”

And here’s the response from Dave Gersic …

Solution

If you know it’ll always be in that format, you can just break it up with substring.

I have this policy on one of my DelimText drivers to allow specified Login Expiration Time in human format:

<?xml version="1.0" encoding="UTF-8"?><policy
xmlns:jdate="http://www.novell.com/nxsl/java/java.util.Date"
xmlns:jdateformat="http://www.novell.com/nxsl/java/java.text.SimpleDateFormat">
 <rule>
  <description>Expire Accounts - Specified Date</description>
  <conditions>
   <and>
    <if-operation mode="case" op="equal">add</if-operation>
    <if-op-attr name="Login Expiration Time" op="available"/>
   </and>
  </conditions>
  <actions>
   <do-set-local-variable name="ExpireDate">
    <arg-string>
     <token-substring length="2" start="4">
      <token-op-attr name="Login Expiration Time"/>
     </token-substring>
     <token-text xml:space="preserve">/</token-text>
     <token-substring length="2" start="6">
      <token-op-attr name="Login Expiration Time"/>
     </token-substring>
     <token-text xml:space="preserve">/</token-text>
     <token-substring length="4" start="0">
      <token-op-attr name="Login Expiration Time"/>
     </token-substring>
    </arg-string>
   </do-set-local-variable>
   <do-reformat-op-attr name="Login Expiration Time">
    <arg-value type="time">
     <token-xpath expression="round(jdate:parse($ExpireDate)div 1000)"/>
    </arg-value>
   </do-reformat-op-attr>
   <do-break/>
  </actions>
 </rule>
 <rule>
  <description>Expire Accounts - Default 1 Year</description>
  <conditions>
   <and>
    <if-operation mode="case" op="equal">add</if-operation>
    <if-op-attr name="Login Expiration Time" op="not-available"/>
   </and>
  </conditions>
  <actions>
   <do-set-dest-attr-value name="Login Expiration Time">
    <arg-value type="string">
     <token-xpath expression="round(jdate:getTime(jdate:new()) div
1000)+31536000"/>
    </arg-value>
   </do-set-dest-attr-value>
   <do-break/>
  </actions>
 </rule>
</policy>

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags:
Categories: Uncategorized

Disclaimer: As with everything else at NetIQ Cool Solutions, this content is definitely not supported by NetIQ, so Customer Support will not be able to help you if it has any adverse effect on your environment.  It just worked for at least one person, and perhaps it will be useful for you too.  Be sure to test in a non-production environment.

2 Comments

  1. By:bstumpp

    I am not completely sure what you are trying to do, but another option would be to use the “Convert Time” verb. It is a new verb in IDM 3.5 and will allow you to convert time from one format to another. Such as from number of milliseconds since January 1, 1970 to a Month/Day/Year format.

  2. By:geoffc

    I am pretty sure the example given by David G. is specifically for a user WITHOUT access to IDM 3.5.x. This is how you do it the old way.

    For a link to the ‘new’ way, check:
    http://www.novell.com/communities/node/2572/using-time-tokens-idm-35

    And yes, the new time tokens are WAY easier than Java time.

Comment