active directory - Delphi XE2: Retrieving LastLogon Int64 to TDateTime conversion -
i trying lastlogin information ad @ work. have 1200 accounts. when run query , include lastlogin information, 40 - 45% of accounts, correct date returned. others, default value. 01-01-1601 or 01-01-1970, depending on kind of conversion use. when use slow: net user /domain, can extract last login information, instead of 10 seconds, need 10 minutes. obviously, want faster.
here code use:
var li: olevariant; int64value: int64; localtime: tfiletime; systemtime: tsystemtime; filetime : tfiletime; begin try li := rs.fields[fieldnumber].value; int64value := li.highpart; int64value := int64value shl 32; int64value := int64value or li.lowpart; filetime := tfiletime(int64value); result := encodedate(1601,1,1); if filetimetolocalfiletime(filetime, localtime) if filetimetosystemtime(localtime, systemtime) result := systemtimetodatetime(systemtime); except result := 0; end; end;
the above works, in 40 - 45% of cases. either value not returned ad or there wrong in conversion. not know of is. since part of works, inclined ad not return me values need. when check directly in ad, see correct value. retreiving them query not allways give me information. problem me is, took piece of code internet , understand little not everything. lost numbers can't see. futhermore, debugging not possible me. not allowed install delphi @ work. can develop on computer not connected network , copy executable network try/test everything.
Comments
Post a Comment