LDAP - formatting large integer values

Rish_007
Kilo Contributor

Hi,

We currently import users from Active Directory using LDAP. I would like to import the lastlogon attribute which has a large integer value. How can I transform this into a date (and time) field onto the User table? I have created a date time field which does not work and produces an error during transform

Error: Unable to format 129726533735107764 using format string dd-MM-yyyy for field *name*

I have also created an integer field and added an attribute format=glide_duration, and as I understand this is the only supported formatter for integer values, however I would like to display a date value.

Any assistance would be greatly appreciated. Thanks in advance!

4 REPLIES 4

mdwallick
Giga Contributor

What you'll need to do is convert that long integer into a date time. I'm not an AD expert, but I'd be willing to bet that value is the number of MICROseconds since 1970-01-01 00:00:00 UTC.

You might lose a few seconds of accuracy (Java/JavaScript doesn't really support microsecond time), but if you take that long integer and divide it by 1,000,000 (one million), and discard the decimal, you can then use the result as an epoch timestamp, which Java/JavaScript can easily translate into a date/time value.

Using the value you specified above (129726533735107764), if you divide that by one million and discard the decimal, you get 1297265337. If you treat that value as an epoch time stamp and convert it, the result you get is Wed, 09 Feb 2011 15:28:57 GMT.

You won't map this field directly into your user table. You'll need to use an onBefore transform script to do the calculation and set the result of that calculation to the target field.

Does that help?


mdwallick
Giga Contributor

What you'll need to do is convert that long integer into a date time. I'm not an AD expert, but I'd be willing to bet that value is the number of MICROseconds since 1970-01-01 00:00:00 UTC.

You might lose a few seconds of accuracy (Java/JavaScript doesn't really support microsecond time), but if you take that long integer and divide it by 1,000,000 (one million), and discard the decimal, you can then use the result as an epoch timestamp, which Java/JavaScript can easily translate into a date/time value.

Using the value you specified above (129726533735107764), if you divide that by one million and discard the decimal, you get 1297265337. If you treat that value as an epoch time stamp and convert it, the result you get is Wed, 09 Feb 2011 15:28:57 GMT.

You won't map this field directly into your user table. You'll need to use an onBefore transform script to do the calculation and set the result of that calculation to the target field.

Does that help?


john_roberts
Mega Guru

There's a helper function in the DateTimeUtils script include to convert int8 values.


Rish_007
Kilo Contributor

Thanks for your responses! I had also found a similar article on the community which helped a little. Account expiry dates.

I changed the integer field to a glide_date_time and created an onBefore script using the DateTimeUtils function and worked great!

var dtUtil = new DateTimeUtils();
target.u_last_logon_ad = dtUtil.int8ToGlideDateTime(source.u_lastlogon);