Account expiry dates

andrewnorris
Giga Contributor

Hello

We currently import our users from active directory to SNC via the LDAP plugin. I want to bring over the account expiry dates too but as this is stored in Integer8 format it will need some transform scripting to get it to show a human-readable date format.

I'm afraid I have no idea how to convert Integer* to the current date format. Can anyone offer help or guidance?

Thanks
Andy

33 REPLIES 33

john_roberts
Mega Guru

I couldn't find anything built in. Since I've heard the request a few times I made one. I'll probably check this in but I'm not sure of the best place for it yet. Until then this should do the trick.

1. Create a new class to hold conversion script since this is good practice. This is done by creating a new Script Include.
- Name: DateConversion
- Script:



var DateConversion = Class.create();
DateConversion.prototype = {
initialize : function() {
},
int8ToGlideDateTime : function(int8Date) {
var msDate = new Packages.org.apache.poi.hpsf.Util.filetimeToDate(int8Date);
var gDate = new Packages.com.glide.glideobject.GlideDateTime();
gDate.setValue(msDate);
return gDate;
}
}


2. Add a new field 'Account Expires' to sys_user
3. Add the following tranform script to convert and populate the new field from AD.


// convert and set account expiration date from AD
var dateConv = new DateConversion();
target.u_account_expires = dateConv.int8ToGlideDateTime(source.u_accountexpires);


The AD Account Expires date is always the end of the day. You may have to manipulate the time depending on your system timezone and how you want the value to display on the user record.


John

Thanks for such a swift reply.

I've created the script include, added the new field and the transform field map. Do i need to put the transform scipt in the script field on the field map item or as an 'onStart', 'onComplete' or 'onAfter' transform script separately?

Also, should the 'script include' have a closing semi-colon or not?

Thanks
Andy


Use script field on the Table Transform Map form. The include script looks fine.


John

I'm not having any luck with this. I've checked and double-checked the scripts and they seem fine.

What data format should the new field 'Account Expires' on the sys_user table be? String, date or date-time?

Thanks
Andy