Convert Active Directory AccountExpires attribute to DateTime

The attribute accountExpires in Active Directory is a UTC FileTime number to convert this to a valid .NET DateTime type we need to convert it's value. First add the accountExpires attribute to the list of attributes as a System.Int64 type via the Active Directory Properties collection.

Properties Collection

Then use Dynamic Columns to convert the value, here we are going to return NULL if no expiry has been set and Today if the account is expired.

using System;

partial class DataSourceRowOverride : Simego.DataSync.DynamicColumns.DataSourceRowInternal //Do Not Change This Line</span>
    DateTime? MyAccountExpiresDateTime 
            if(accountExpires == Int64.MaxValue)
                return defalut(DateTime?);
            if(accountExpires == 0)
                return DateTime.Today;
            return DateTime.FromFileTimeUtc(accountExpires.Value);