Форум: "Сети";
Текущий архив: 2004.10.03;
Скачать: [xml.tar.bz2];
ВнизСписок пользователей Найти похожие ветки
← →
Slaga © (2004-07-28 16:05) [0]Какой командой СМД можна получить список пользователей домена ?
← →
Rouse_ © (2004-07-28 16:21) [1]
procedure GetAllUsersFromDomain(var List: TStringList);
var
Buffer, tmpBuffer: Pointer;
PrefMaxLen : Integer;
Resume_Handle : DWORD;
EntriesRead : DWORD;
TotalEntries : DWORD;
I, Size : Integer;
{NickName, }Serv : String;
PSrvr : PWideChar;
begin
List.Clear;
PSrvr := nil;
try
// Переводим имя компьютера типа PWideChar
Serv := "\\" + GetDomainName;
Size := Length(Serv);
GetMem(PSrvr, Size * SizeOf(WideChar) + 1);
StringToWideChar(Serv, PSrvr, Size + 1);
PrefMaxLen := -1;
EntriesRead := 1;
TotalEntries := 1;
Resume_Handle := 0;
Buffer := nil;
// Получаем список пользователей на компьютере из PSrvr
if NetUserEnum(PSrvr, 11, 0, @Buffer, PrefMaxLen, @EntriesRead,
@TotalEntries, @Resume_Handle) = S_OK then
begin
tmpBuffer := Buffer;
for I := 0 to TotalEntries - 1 do
begin
List.Add("usri11_name " + USER_INFO_11(tmpBuffer^).usri11_name);
List.Add("usri11_comment " + USER_INFO_11(tmpBuffer^).usri11_comment);
List.Add("usri11_usr_comment " + USER_INFO_11(tmpBuffer^).usri11_usr_comment);
List.Add("usri11_full_name " + USER_INFO_11(tmpBuffer^).usri11_full_name);
List.Add("usri11_priv " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_priv));
List.Add("usri11_auth_flags " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_auth_flags));
List.Add("usri11_password_age " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_password_age));
// if USER_INFO_11(tmpBuffer^).usri11_home_dir <> nil then
// List.Add("usri11_home_dir " + USER_INFO_11(tmpBuffer^).usri11_home_dir);
List.Add("usri11_parms " + USER_INFO_11(tmpBuffer^).usri11_parms);
List.Add("usri11_last_logon " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_last_logon));
List.Add("usri11_last_logoff " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_last_logoff));
List.Add("usri11_bad_pw_count " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_bad_pw_count));
List.Add("usri11_num_logons " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_num_logons));
List.Add("usri11_logon_server " + USER_INFO_11(tmpBuffer^).usri11_logon_server);
List.Add("usri11_country_code " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_country_code));
List.Add("usri11_workstations " + USER_INFO_11(tmpBuffer^).usri11_workstations);
List.Add("usri11_max_storage " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_max_storage));
List.Add("usri11_units_per_week " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_units_per_week));
//List.Add("usri11_logon_hours " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_logon_hours));
List.Add("usri11_code_page " + IntToStr(USER_INFO_11(tmpBuffer^).usri11_code_page));
List.Add("======================================================");
Resume_Handle := 0;
tmpBuffer := Pointer(DWORD(tmpBuffer) + SizeOf(USER_INFO_11));
end;
end;
finally
NetApiBufferFree(Buffer);
FreeMem(PSrvr);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S: TStringList;
begin
S := TStringList.Create;
try
GetAllUsersFromDomain(S);
Memo1.Text := S.Text;
finally
S.Free;
end;
end;
ЗЫ: NetUserEnum(PSrvr, 11, 0,
вместо третьего параметры можешь подставлять фильтры:FILTER_TEMP_DUPLICATE_ACCOUNT = ($0001);
FILTER_NORMAL_ACCOUNT = ($0002);
(* #define FILTER_PROXY_ACCOUNT (0x0004)*)
FILTER_INTERDOMAIN_TRUST_ACCOUNT = ($0008);
FILTER_WORKSTATION_TRUST_ACCOUNT = ($0010);
FILTER_SERVER_TRUST_ACCOUNT = ($0020);
← →
Rouse_ © (2004-07-28 16:24) [2]Структуру забыл как всегда :)
_USER_INFO_11 = record
usri11_name: LPWSTR;
usri11_comment: LPWSTR;
usri11_usr_comment: LPWSTR;
usri11_full_name: LPWSTR;
usri11_priv: DWORD;
usri11_auth_flags: DWORD;
usri11_password_age: DWORD;
usri11_home_dir: LPWSTR;
usri11_parms: LPWSTR;
usri11_last_logon: DWORD;
usri11_last_logoff: DWORD;
usri11_bad_pw_count: DWORD;
usri11_num_logons: DWORD;
usri11_logon_server: LPWSTR;
usri11_country_code: DWORD;
usri11_workstations: LPWSTR;
usri11_max_storage: DWORD;
usri11_units_per_week: DWORD;
usri11_logon_hours: Pointer;
usri11_code_page: DWORD;
end;
USER_INFO_11 = _USER_INFO_11;
PUSER_INFO_11 = ^_USER_INFO_11;
LPUSER_INFO_11 = ^_USER_INFO_11;
← →
Slaga © (2004-07-28 16:25) [3]Спасибо
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2004.10.03;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.044 c