home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 April
/
Chip_2002-04_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
NT.ZIP
/
NTGetUserInfo.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-06-19
|
2KB
|
79 lines
unit NTGetUserInfo;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TNTGetUserInfo = class(TComponent)
private
{ Private declarations }
FUserName:String;
FServer:String;
FFullName:String;
FComment:String;
FFlags:DWORD;
FUserID:DWORD;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Server:string read FServer write FServer;
property UserName:String read FUserName write FUserName;
property FullName:String read FFullName;
property Comment:String read FComment;
property Flags:DWORD read FFlags;
property UserID:DWORD read FUserID;
function Execute:LongInt;
end;
Type USER_INFO_20=record
usri20_name:LPWSTR; usri20_full_name:LPWSTR; usri20_comment:LPWSTR; usri20_flags:DWORD; usri20_user_id:DWORD;End;
function NetUserGetInfo(Server:PWideChar;UserName:PWideChar;Level:DWORD;Buffer:Pointer):LongInt; stdcall; external 'netapi32.dll';
procedure Register;
implementation
function TNTGetUserInfo.Execute:LongInt;
var TheUser:Array[0..255] Of WideChar;
TheServer:Array[0..255] Of WideChar;
MyInfo:USER_INFO_20;
MyPtr:Pointer;
begin
MyPtr:=nil;
StringToWideChar(FUserName,@TheUser,255);
If FServer<>'' Then
Begin
StringToWideChar(FServer,@TheServer,255);
Result:=NetUserGetInfo(@TheServer,@TheUser,20,@MyPtr);
End Else
Begin
Result:=NetUserGetInfo(nil,@TheUser,20,@MyPtr);
End;
If MyPtr<>nil Then
Begin
MyInfo:=USER_INFO_20(MyPtr^);
FFullName:=WideCharToString(MyInfo.usri20_full_name);
FComment:=WideCharToString(MyInfo.usri20_comment);
FFlags:=MyInfo.usri20_flags;
FUserID:=MyInfo.usri20_user_id;
End Else
Begin
FFullName:='';
FComment:='';
FFlags:=0;
FUserID:=0;
End;
end;
procedure Register;
begin
RegisterComponents('NT Tools - User Management', [TNTGetUserInfo]);
end;
end.