none
Convert ADS AccountExpires value to Date in .NET

    Question

  • I am retrieving some user info from Active Directory:

    Dim

     

     

    dicDetails As New Dictionary(Of String, String)

     

     

    Dim search As New DirectorySearcher(_path)

    search.PropertyNamesOnly =

     

    False

    search.Filter =

     

    "(cn=" + UserName + ")"

     

     

    Dim sr As SearchResult = search.FindOne

     

     

    For Each item As String In sr.Properties.PropertyNames

    dicDetails.Add(item, sr.Properties(item)(0).ToString())

     

     

    Next

    Now in my result dictionary I want to convert the accountexpires value to a readble date/time value. I can convert the lastlogon value by using this:

    DateTime

     

     

    .FromFileTime(129119258260033553).ToString

    However, I cannot use the same for accountexpires as it gives me an error of:
    Not a valid Win32 FileTime.
    Parameter name: fileTime

    Any ideas how I can display the accountexpires value in a readable format?

    Monday, March 01, 2010 2:38 PM

Answers