LDAP timestamp 'pwdLastSet' convert in IDM regular date format, Px policy
search cancel

LDAP timestamp 'pwdLastSet' convert in IDM regular date format, Px policy

book

Article ID: 230206

calendar_today

Updated On:

Products

CA Identity Manager

Issue/Introduction

We have fetched the 'pwdLastSet' AD attribute in IDM through Px Policy LDAP Query filter. The output received is in 18 digit LDAP Timestamp (default datatype). 

I need to convert this timestamp to a regular Date and Time and store in IDM.

 

Environment

Release : 14.3

Component : Identity Manager, PX Policy

Resolution

The below is provided as is and out of the scope of L1 support. This would return yyyyMMdd format.

function init(ScreenContext){
var adPwdLastChange = ScreenContext.getFieldValue("PasswordLastSet");
var dateInIMFormat= (adPwdLastChange - 116444736000000000) / 10000;

var pwdate = new Date(Math.round(dateInIMFormat));
var pwdExpiryDate = pwdate.getDate();
pwdate.setDate(pwdExpiryDate+90);
var sdf = new java.text.SimpleDateFormat("yyyyMMdd");
ScreenContext.setFieldValue("PasswordExpiryDate",sdf.format(pwdate));
}