Board index » delphi » Using Delphi 3.0 to access Active Directory Service Interface (ADSI)

Using Delphi 3.0 to access Active Directory Service Interface (ADSI)

I'm using Delphi 3.0and am having difficulty accessing the Microsoft ADSI
objects. I've done it using VBScript and VB with no problems.

The VB/VBScript code would look like this;

Variant = GetObject("WinNT://ServerName/UserName")

This would return a user object.

Has anyone managed to do this succesfully ??? Please help me, I don't want
to use VB !

 

Re:Using Delphi 3.0 to access Active Directory Service Interface (ADSI)


Try this:

function GetObject (const Name : string) : variant;
var
  Moniker : IMoniker;
  Eaten : integer;
  BindContext : IBindCtx;
  Dispatch : IDispatch;
begin
  OleCheck (CreateBindCtx (0, BindContext));
  OleCheck (MkParseDisplayName (BindContext, PWideChar (WideString (Name)),
Eaten, Moniker));
  OleCheck (Moniker.BindToObject (BindContext, NIL, IDispatch, Dispatch));
  Result := Dispatch;
end;

Then call it from your app:

User := GetObject ('WinNT:...);

have fun
--
Binh Ly
Visit my COM Notes at http://www.castle.net/~bly/com

Quote
Andy Britton <ajbrit...@ndirect.co.uk> wrote in message

news:7qju63$d0219@forums.borland.com...
Quote
> I'm using Delphi 3.0and am having difficulty accessing the Microsoft ADSI
> objects. I've done it using VBScript and VB with no problems.

> The VB/VBScript code would look like this;

> Variant = GetObject("WinNT://ServerName/UserName")

> This would return a user object.

> Has anyone managed to do this succesfully ??? Please help me, I don't want
> to use VB !

Other Threads