library ADSI;
{ enemyleft[at]gmail.com - 05.10.2007 }
uses
SysUtils,
Classes,
ActiveDs_TLB,
adshlp,
Variants;
type
T2dStringArray =
Array of Array of String;
TStringArray =
Array[0..1]
of String;
THelper =
class(TObject)
procedure AddToTreeUsers(disp: IADs);
end;
var
values: T2dStringArray;
value: TStringArray;
helper: THelper;
i: integer = -1;
{$R *.res}
// enumerate users
procedure GettingUsers(
dom: IADsContainer);
begin
dom.Filter := VarArrayOf(['
user']);
ADsEnumerateObjects(
dom, helper.AddToTreeUsers);
end;
// DOMAIN
// open winnt (ActiveDirectory) with other username and password
function OpenUsers(domain, username, password:
String): T2dStringArray;
stdcall;
var
dom: IADsContainer;
begin
ADsOpenObject('
WinNT://' + domain, username, password, 1, IADsContainer,
dom);
GettingUsers(
dom);
result := values;
end;
// DOMAIN
// open winnt (ActiveDirectory) with current user
function GetUsers(domain:
String): T2dStringArray;
stdcall;
var
dom: IADsContainer;
begin
ADsGetObject('
WinNT://' + domain, IADsContainer,
dom);
GettingUsers(
dom);
result := values;
end;
// USER DETAIL
// open winnt (ActiveDirectory) with current user
function GetUsersDetail(domain, username:
String): TStringArray;
stdcall;
var
usr: IADsUser;
begin
ADsGetObject('
WinNT://' + domain + '
/' + username, IADsUser, usr);
value[0] := usr.FullName;
value[1] := usr.Description;
result := value;
end;
// add the users into the array
procedure THelper.AddToTreeUsers(disp: IADs);
begin
Inc(i);
SetLength(values, i+1, 2);
values[i,0] := disp.
Name;
values[i,1] := disp.Schema;
end;
exports
OpenUsers,
GetUsers,
GetUsersDetail;
begin
end.