// uses JWALM
function GetGroups(srvName, usrName: WideString; groups: TStrings): DWORD;
var
dwEntriesRead, dwEntriesTotal: DWORD;
grpi0: Pointer;
pInfo: PGroupInfo0;
nErr: Integer;
begin
Result := NetUserGetGroups(PWideChar(srvName), PWideChar(usrName), 0, grpi0,
MAX_PREFERRED_LENGTH, dwEntriesRead, dwEntriesTotal);
if nErr = NERR_SUCCESS
then
begin
pInfo := grpi0;
while dwEntriesRead > 0
do
begin
groups.Add(pInfo.grpi0_name);
Inc(pInfo);
Dec(dwEntriesRead);
end;
NetAPIBufferFree(grpi0);
end;
end;
procedure TDemoForm.GroupsButtonClick(Sender: TObject);
var
nErr: DWORD;
begin
with GroupsBox
do
begin
Clear;
nErr := GetGroups(ServerEdit.Text, UserEdit.Text, Items);
if nErr = NERR_SUCCESS
then ShowMessage(Format('
%d groups found', [Count]))
else ShowMessage(SysErrorMessage(nErr));
end;
end;