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>

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading...Loading...
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.

Leave a Reply

Leave a Comment

By: dgersic
Jan 2, 2008
11:40 am
Reads:
1,876
Score:
Unrated