cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert AD accountexpires in Local timezone format

Ckumar
Contributor
0 Kudos
1,636

Hello Everyone,

In my current project IDM 7.2 SP10, we are reading accountexpires attribute from AD and then converting it to a readable format using uInt8ToDate function.

https://help.sap.com/saphelp_nwidmic71/en/using_functions/internal_functions/dse_uint8todate.htm

This function is converting the date in readable GMT format while client want it in local time. While searching SCN, I got below post which says that "True" switch is not working in uInt8ToDate function and even I observed the same.

https://archive.sap.com/discussions/thread/3469115

Can anyone guide how can I convert the date in local timezone. I tried to use getTimezoneOffset() but it thrown error. Any help with the JavaScript formula will be appreciated.

View Entire Topic
former_member201064
Active Participant

Hello C Kumar,

I use this script to retrieve the accountExpires from AD and set it to the local validto attribute for AD:

var MSTimestamp = Par;
var MSTimestampNormalized = (MSTimestamp - 116444736000000000 - 864000000000) / 10000;
var date = new Date(MSTimestampNormalized);

date.toGMTString();
var MonthValue = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
var dayOfMonth = '' + date.getDate();
if (dayOfMonth.length == 1) { dayOfMonth = "0" + dayOfMonth; }
return date.getFullYear() + "-" + MonthValue[date.getMonth()] + "-" + dayOfMonth;

Never thought of the time gap between GMT and CET though. I always take a day of (864000000000) due to the difference from accountExpires and validto.

I guess I would have to add or subtract another milliseconds value to match up the different time zones we have (plants all around the world) if sdomeone actually would complain about a user being locked too early just because of the day hasn't passed yet. I guess the local Domain Controllers in every country handle the date correctly.

If ever needed I would use a time zone difference in hours and store it on each company. Then I'd use this one in the script to add / subtract the amount of hours before calculating the new Date thingy.

Best regards

Dominik

devaprakash_b
Active Contributor
0 Kudos

Hi Dominik,

Can you please let me know how to convert the current date to LDAP/filetime, so that enddate can be passed to the AccountExpires attribute in AD

Regards,

Deva