Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A first step would be to check out the article series <a href="http://www.windowsitpro.com/home/search.aspx?query=An%20ADSI%20Primer" rel="nofollow">An ADSI primer</a> on Windows IT Pro. It gives a fairly good overview of the basics of ADSI and the <code>IADs</code> interfaces and how to use them (from VBScript, I believe).</p> <p>A second step in Delphi would be to import the <code>Active_Ds</code> type library - this should generate an <code>ActiveDs_TLB.pas</code> file that contains the basic types, interfaces, methods to deal with Active Directory from a native language, using ADSI.</p> <p>To access the native functions, you need to use a so called function import for each of the functions you want - here the code for just one - <code>ADsGetObject</code>:</p> <pre><code>type TADsGetObject = function(aPathName: PWideChar; const aRIID: TGUID; out aObject): HResult; safecall; var ADsGetObject : TADsGetObject = nil; initialization hActiveDS := LoadLibrary(PChar('ActiveDS.dll')); // don't localize if (hActiveDS = 0) then raise Exception.Create(rc_CannotLoadActiveDS); LoadProcAddress(hActiveDS, 'ADsGetObject', @ADsG </code></pre> <p>etObject);</p> <p>Once you've created those functions from the external library, you can go about calling them - something like this:</p> <pre><code>var hr : HRESULT; oIADs : IADs; wsTemp : WideString; begin wsTemp := 'LDAP://cn=IanBoyd,cn=Users,dc=YourCompany,dc=com'; // try to bind to the ADSI object using the "sanitized" path hr := ADsGetObject(PWideChar(wsTemp), IID_IADs, oIADs); if Succeeded(hr) then begin // successful - now retrieve all properties into property cache try oIADs.GetInfo; except on EOleSysError do begin Exit; end; end; // get the object's GUID wsTemp := oIADs.GUID; // do more stuff here..... </code></pre> <p>Next, also see my <a href="http://adsi.mvps.org/adsi/Delphi/index.html" rel="nofollow">ADSI Delphi Tips &amp; Tricks page</a> - so of the info is outdated, though (like the link to The Delphi Magazine's collection CD - that doesn't seem to be available anymore).</p> <p>Searching ADSI with native code is quite involved - that would <strong>definitely</strong> go beyond the scope of such a posting. I did write a fairly extensive article on that - including sample code - which is available upon request from me (send me an e-mail to my address in my profile).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload