unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
TStringArray =
array of WideString;
type
TUser =
packed record
Name: WideString;
UserGroups: TStringArray;
end;
TUsers =
array of TUser;
var
Form1: TForm1;
Computer : WideString;
function EnumUsers(
const Server: WideString; filter: DWORD): TStringArray;
implementation
{$R *.dfm}
uses MpuWinNT;
function EnumUsers(
const Server: WideString; filter: DWORD): TStringArray;
var
ui1, pWork : Pointer;
EntriesRead, EntriesTotal: DWORD;
NetError : DWORD;
Loop : Integer;
begin
pWork :=
nil;
if Server <> '
'
then
begin
try
NetError := NetUserEnum(PWideChar(Server), 0, filter, ui1,
MAX_PREFERRED_LENGTH, EntriesRead, EntriesTotal,
nil);
if (NetError = NERR_SUCCESS)
and (EntriesRead > 0)
then
begin
pWork := ui1;
SetLength(Result, EntriesRead);
for Loop := 0
to EntriesRead - 1
do
begin
Result[Loop] := PUserInfo1(ui1)^.usri1_name;
Inc(Integer(ui1), sizeof(Pointer));
end;
end;
finally
NetApiBufferFree(pWork);
end;
end;
end;
function GetUsers(
const Computer: WideString): TUsers;
var
Users : TStringArray;
i, j : Integer;
ui3 : TUserInfo3;
UserGroups : TStringArray;
begin
Users := EnumUsers(Computer, FILTER_NORMAL_ACCOUNT);
SetLength(Result, Length(Users));
for i := 0
to Length(Users) - 1
do
begin
// reset array -> delete old values
SetLength(UserGroups, 0);
//GetUserInfo(Computer, Users[i], ui3);
Result[i].
Name := ui3.usri3_name;
//UserGroups := GetUserGroups(Computer, Users[i]);
SetLength(Result[i].UserGroups, Length(UserGroups));
for j := 0
to Length(UserGroups) - 1
do
Result[i].UserGroups[j] := UserGroups[j];
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Computer := '
192.168.0.10';
GetUsers(Computer);
end;
end.