Value from Active Directory for the field 'Password Last Set' is not in the date and time format.

AbdulRahman89
Giga Contributor

I have configured ServiceNow to query and fetch User and Generic Accounts. However two fields which are flowing from MS Active Directory namely 'Password Last Set' and  'Last Logon' seems to be in completely different format other than date and time.

I have tried the following script but it does not seem to work.

 

====================================

answer = (function transformEntry(source) {
var gdt = new GlideDateTime();

var s = source.u_pwdlastset;

gdt.setNumericValue((mstime - 116444736000000000)/10000);

var lastset = gdt.getValue();
return lastset;

})(source);

==================================

Also I have tried the solution provided in the below article, which does not seems work at all.

https://community.servicenow.com/community?id=community_question&sys_id=c5ba0f2ddb5cdbc01dcaf3231f9619f3&view_source=searchResult

 

 

I would appreciate if you could review this in detail and help me with your expertise. 

1 ACCEPTED SOLUTION

AbdulRahman89
Giga Contributor

Here is the solution:

 

 

answer = (function transformEntry(source) {

var gdt = new GlideDateTime();
var mstime = parseInt(source.u_pwdlastset);
gdt.setNumericValue((mstime - 116444736000000000)/10000);
log.info(gdt.getValue()+'date');
return gdt.getValue(); // return the value to be put into the target field

})(source);

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Abdul,

What values are coming in target once you use that script?

Are they not looking same as LDAP?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Its is giving a numerical value like "131876208004375493" - as per MSDN website, here is the formal definition "The date and time that the password for this account was last changed. This value is stored as a large integer that represents the number of 100 nanosecond intervals since January 1, 1601 (UTC)."

 

And I have also found a stackoverflow article, but struggling to make this work in ServiceNow.

https://stackoverflow.com/questions/52260811/active-directory-lastlogontimestamp-convert-integer-to-date 

 

Any help would be appreciated!

AbdulRahman89
Giga Contributor

Its is giving a numerical value like "131876208004375493" - as per MSDN website, here is the formal definition "The date and time that the password for this account was last changed. This value is stored as a large integer that represents the number of 100 nanosecond intervals since January 1, 1601 (UTC)."

 

And I have also found a stackoverflow article, but struggling to make this work in ServiceNow.

https://stackoverflow.com/questions/52260811/active-directory-lastlogontimestamp-convert-integer-to-date 

Hi Abdul,

Can you check below links:

1st link should help you resolve

https://community.servicenow.com/community?id=community_blog&sys_id=6c9ceae1dbd0dbc01dcaf3231f961931

https://community.servicenow.com/community?id=community_question&sys_id=56315fe9dbdcdbc01dcaf3231f9619a7

https://community.servicenow.com/community?id=community_question&sys_id=c616cb61db1cdbc01dcaf3231f9619b9

What value does this variable hold?

mstime

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader