The value of LongInteger is set to 0X7FFFFFFFFFFFFFFF when the account never
expires, this is an invalid value for FromFileTime to convert to a date.
So you need to validate the value before calling FromFileTime, try this...
...
DateTime retDate;
if((li.HighPart == Int32.MaxValue) && (li.LowPart == -1))
{
retDate = DateTime.MaxValue; //never expires - invalid date, return
some meaningful date
}
else {
// Valid date to convert to DateTime format
long date = (((long)(li.HighPart) << 32) + (long) li.LowPart);
retDate = DateTime.FromFileTime(date).ToString();
}
return retDate;
}
Willy.
"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:eV**************@TK2MSFTNGP12.phx.gbl...
I'm taking the value of the expire date out of an AD account
(accountExpires
attribute) and passing it into this function.
static DateTime LargeIntToDateTime(ActiveDs.LargeInteger li)
{
long lTime;
lTime = (long)li.HighPart;
lTime <<= 32;
lTime |= (uint)li.LowPart;
return System.DateTime.FromFileTime(lTime);
}
It worked a month ago, but it seems like on a certain day it started
throwing this exception:
Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
I'm way out of my element. Could someone hit me with a clue stick.