Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#8

Re: NetUserGetGroups & NetUserGetLocalGroups

  Alt 28. Sep 2007, 20:31
Hallo Rolf,

vergleiche mal:

Delphi-Quellcode:
// 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;
Grüße vom marabu
  Mit Zitat antworten Zitat