Wie kann man checken, ob ein User (wenn mann Passwort,Username und Domain hat) User der Domain ist. (Delphi-Funktion)
mfg. Manfred T.
gefunden bei google …von Colin Wilson:
> Try this…
>
> function GetDomainName : string;
> var
> hProcess, hAccessToken : THandle;
> InfoBuffer : PChar;
> AccountName : array [0…UNLEN] of char;
> DomainName : array [0…DNLEN] of char;
>
> InfoBufferSize : Integer;
> AccountSize : Integer;
> DomainSize : Integer;
> snu : SID_NAME_USE;
>
> begin
> InfoBufferSize := 1000;
> AccountSize := sizeof (AccountName);
> DomainSize := sizeof (DomainName);
>
> hProcess := GetCurrentProcess;
> if OpenProcessToken (hProcess, TOKEN_READ, hAccessToken) then
> try
> GetMem (InfoBuffer, InfoBufferSize);
> try
> if GetTokenInformation(hAccessToken,TokenUser, InfoBuffer,
> InfoBufferSize, InfoBufferSize) then
> LookupAccountSid (Nil, PSIDAndAttributes (InfoBuffer)^.sid,
> AccountName, AccountSize,DomainName, DomainSize, snu)
> else
> RaiseLastWin32Error;
> finally
> FreeMem (InfoBuffer)
> end;
> result := DomainName
> finally
> CloseHandle (hAccessToken)
> end
> end;