function FileTimeToDateTime(ft: TFileTime): TDateTime;
var
tzi: TTimeZoneInformation;
lt, st: TSystemTime;
begin
GetTimeZoneInformation(tzi);
FileTimeToSystemTime(ft, st);
SystemTimeToTzSpecificLocalTime(@tzi, st, lt);
Result := SystemTimeToDateTime(lt);
end;
...
procedure Tfrm_main.GetADSInfo(suchbegriff :
string);
var rs,conn,
com : Variant;
strBase, strFilter, strAttributes, strADS :
string;
begin
conn := CreateOleObject('
ADODB.Connection');
com := CreateOleObject('
ADODB.Command');
try
conn.Provider := '
ADsDSOObject';
conn.open;
com.ActiveConnection := conn;
strBase := '
<LDAP://test.com>';
if rb_name.Checked = TRUE
then
strFilter := '
(&(objectCategory=person)(objectClass=user)(displayname='+suchbegriff+'
))';
if rb_lanid.Checked = TRUE
then
strFilter := '
(&(objectCategory=person)(objectClass=user)(sAMAccountName='+suchbegriff+'
))';
strAttributes := '
givenname,sn,sAMAccountName,lastLogon,pwdLastSet,badPasswordTime,telephoneNumber';
strADS := strBase + '
;' + strFilter + '
;' + strAttributes + '
;subtree';
Com.CommandText := strADS;
Com.Properties['
Page Size'] := 100000;
Com.Properties['
Searchscope'] := 2;
Com.Properties['
Cache Results'] := False;
rs :=
Com.Execute;
if Not rs.EOF
then
begin
lbl_vorname.Caption := rs.Fields['
givenname'].Value;
lbl_nachname.Caption := rs.Fields['
sn'].Value;
lbl_lanid.Caption := UpperCase(rs.Fields['
sAMAccountName'].Value);
// hier knallt es: Inkompatible Typen: '_FILETIME' und 'Variant'
lbl_passwordchange.Caption := DateTimeToStr(FileTimeToDateTime(rs.Fields['
pwdLastSet'].Value));
end
else
MessageDlg('
Kein Datensatz gefunden.',mtInformation,[mbOK],0);
Rs := NULL;
finally
com := NULL;
conn.Close;
conn := NULL;
end;
end;
...