T
Tamir Khason
The PropertyValueCollection element 0 contains a COM IDispatch Pointer
(__ComObject), use late binding to retrieve the HighPart
and LowPart properties, of the LastLogon Date.
Combine both into a long and pass it to FromFileTime.
Add a reference to activeds.tlb
Try this:
Dim de As DirectoryEntry = _
New DirectoryEntry("LDAP://xxxx/CN=Users,DC=xx,DC=yy,DC=zz")
Dim mySearcher as DirectorySearcher = new DirectorySearcher(de)
mySearcher.Filter = "(samAccountName=administrator)"
mySearcher.PropertiesToLoad.Add("samAccountName")
mySearcher.PropertiesToLoad.Add("lastLogon")
Dim myResult as SearchResult
myResult = mySearcher.FindOne()
de = new DirectoryEntry(myResult.Path)
Dim pcoll as PropertyCollection = de.Properties
Dim li as LargeInteger
Dim oli as object = pcoll("lastLogon")(0) ' Set object reference to
ILargeInteger
Dim lDate as Long = (oli.HighPart * &h100000000) + oli.LowPart 'Combine
LowPart and HighPart
Console.WriteLine("DATE = {0
}" ,DateTime.FromFileTime(lDate)) 'Convert
from FileTime foramt to DateTime
(__ComObject), use late binding to retrieve the HighPart
and LowPart properties, of the LastLogon Date.
Combine both into a long and pass it to FromFileTime.
Add a reference to activeds.tlb
Try this:
Dim de As DirectoryEntry = _
New DirectoryEntry("LDAP://xxxx/CN=Users,DC=xx,DC=yy,DC=zz")
Dim mySearcher as DirectorySearcher = new DirectorySearcher(de)
mySearcher.Filter = "(samAccountName=administrator)"
mySearcher.PropertiesToLoad.Add("samAccountName")
mySearcher.PropertiesToLoad.Add("lastLogon")
Dim myResult as SearchResult
myResult = mySearcher.FindOne()
de = new DirectoryEntry(myResult.Path)
Dim pcoll as PropertyCollection = de.Properties
Dim li as LargeInteger
Dim oli as object = pcoll("lastLogon")(0) ' Set object reference to
ILargeInteger
Dim lDate as Long = (oli.HighPart * &h100000000) + oli.LowPart 'Combine
LowPart and HighPart
Console.WriteLine("DATE = {0

from FileTime foramt to DateTime