LDAP Transform Dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2017 01:46 PM
I am needing to get the expiry date from AD into the sys_user table. I have seen examples on here, but nothing seems to work for me
Anyone have an easy solution to do this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2017 09:23 AM
I just did this last month:
1.Create the expiry date field on the user form (date/time)
2.Navigate to your LDAP server
Add your AD expiry field name to the attributes section ( accountexpires)
Save
3.Navigate to your users transform map
Add a new field map
Target field ( your new field on the user form)
Date Format yyyy-MM-dd hh:mm:ss
Use Source Script = true
Script:
// This function converts the UTC date/time to local date/time
function getLocalTimeZoneDateTime(dateTimeUTC) {
var gdt = new GlideDateTime(dateTimeUTC);
return gdt.getDisplayValueInternal();
}
var dtUtil = new DateTimeUtils();
if (source.u_accountexpires === undefined) {
// set a blank value if the source is 'undefined'
target.setValue("your_user_form_expiry_date_variable", '');
} else if (source.u_accountexpires != 0) {
// convert the date from int8 format to GlideDateTime in UTC
var expiresUTC = dtUtil.int8ToGlideDateTime(source.u_accountexpires);
// convert the GlideDateTime in UTC to Local TimeZone
var expiresLocal = getLocalTimeZoneDateTime(expiresUTC.toString());
//log.info("ExpiresLocal: " + expiresLocal);
// Set the value to the Local Time Zone value
answer = expiresLocal
} else {
// set a blank value if the source is anything else.
target.setValue("u_expires", '');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 10:55 AM
Worked like a charm. I had it all but the script part. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2017 01:33 PM
Did that work for you?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 06:25 AM
Hi Cheyennes,
I know this is very old post,
Can you assists on the Ldap date conversion.
I followed the steps suggested,still no Luck !
Any Suggestions?