home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 April
/
Chip_2002-04_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
NT.ZIP
/
NTGetUserDomain.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-06-19
|
1KB
|
55 lines
unit NTGetUserDomain;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TNTGetUserDomain = class(TComponent)
private
{ Private declarations }
FUserID:String;
FDomainName:String;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property UserID:String read FUserID write FUserID;
property DomainName:String read FDomainName;
function Execute:Boolean;
end;
procedure Register;
implementation
function TNTGetUserDomain.Execute:Boolean;
var psnuType:DWord;
lpszDomain:Array[0..2048] Of Char;
UserSID:Array[0..1024] Of Char;
dwDomainLength:DWORD;
dwSIDBuffSize:DWORD;
lpszUserName:Array[0..250] Of Char;
begin
dwDomainLength:=250;
dwSIDBuffSize:=1024;
StrPCopy(lpszUserName,FUserID);
If Not LookupAccountName(nil,lpszUserName,@UserSID,dwSIDBuffSize,lpszDomain,dwDomainLength,psnuType) Then
Begin
Result:=False;
End Else
Begin
Result:=True;
FDomainName:=StrPas(lpszDomain);
End;
end;
procedure Register;
begin
RegisterComponents('NT Tools - Additional', [TNTGetUserDomain]);
end;
end.