Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Сети > Список пользователей домена Windows


Автор: Proximo_RZN 1.8.2005, 15:26
Здравствуйте. Перерыл весь DRKB, но так и не нашел как получить список ВСЕХ пользователей домена (т.е. уташить их из Active Directory). Желательно универсальное решение для 2000/2003.
Спасибо.

Автор: Girder 11.8.2005, 16:35
Код
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    TreeView1: TTreeView;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure GetEnumRes(Root:PNetResource; LevelMax:integer; dwType:DWord; TreeV:TTreeView; Tree:TTreeNode);
var hEnum:DWord;
    C,S,i:DWord;
    Buf,t:PNetResource;
begin
 if LevelMax<0 then exit;
 if WNetOpenEnum(RESOURCE_GLOBALNET,dwType,0,Root,hEnum)<>NO_ERROR then exit;
 C:=$FFFFFFFF;
 S:=32768;
 Buf:=nil;
 try
  GetMem(Buf,S);
  if WNetEnumResource(hEnum,C,Buf,S)<>NO_ERROR then exit;
  t:=Buf;
  for i:=1 to C do
   begin
    GetEnumRes(t,LevelMax-1,dwType,TreeV,TreeV.Items.AddChild(Tree,t^.lpRemoteName));
    Application.ProcessMessages;
    inc(t);
   end;
 finally
  if Buf<>nil then FreeMem(Buf,S);
  WNetCloseEnum(hEnum);;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 GetEnumRes(nil,2,RESOURCETYPE_DISK,TreeView1,nil);
end;

end.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)