AD: convert accountexpires value -> datetime?

[ASP.NET]

There's all kinds of info on the web about how to convert the AD accountexpires supermega long integer to a datetime.  I'm so glad that they didn't do this for us already in AD.

I would like to know how to take the String representation of this 8-byte integer to a datetime.  If you reference this Large Integer data type that I keep seeing mentioned, please tell me where to find it because I cannot find what namespace contains it.

bamapieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam BrownSr Solutions ArchitectCommented:
The powershell method for converting it is [DateTime].FromFileTime([Int64].Parse($timestamp))
I don't know if that's an .net function or not (I'm not exactly a programmer)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bamapieAuthor Commented:
I dunno.  Tested it like so:

         string sAccountExpires = "159394408940000000";

         System.DateTime dtAccountExpires = System.DateTime.FromFileTime(System.Int64.Parse(sAccountExpires));

and got a wacky number: 2/7/2106 12:28:14 AM.
0
Adam BrownSr Solutions ArchitectCommented:
Well, that's the correct conversion for that timestamp. Run it on this one: 129461653790936115 (pulled that from my test DC). The lastlogontimestamp is actually a count of 100 nanosecond intervals since Jan 1, 1601 rather than an 8 byte value, so you know :D
0
bamapieAuthor Commented:
Okay, I think it's really close.  But I can't figure out why it doesn't match my AD tools I'm using to view the data with.

For example, take 129465738256471166.

My calculation says it's 4/6/2011 9:30:25 AM.

But my AD tools say that this date is 4/6/2011 7:08:04 PM.

This isn't a GMT thing, obviously.  It's something with a difference in my calculation and theirs.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.