HOWTO: Using ADO to Access Objects Through ADSI LDAP ProviderID: Q187529
|
The Active Directory Service Interfaces (ADSI) version 2.0 Lightweight
Directory Access Protocol (LDAP) provider implements OLE DB interfaces that
allow you to use ActiveX Data Objects (ADO) to access objects in LDAP
compliant directories. You must create an ADO connection object and set its
Provider property to "ADsDSOObject". You can specify any string, including
"", as the connection string (first argument) of the ADO connection
object's open method.
The connection object Execute method's CommandText (first object) is an
LDAP query composed of four elements separated by semicolons, in the
following format:
<LDAP://server/adsidn>;ldapfilter;attributescsv;scope
LDAP:<//server/o=organization/ou=site/cn=recipients>;
(objectClass=*);
ADsPath,objectClass,cn;subtree"
or (in attributed name format):
<LDAP://server/cn=recipients,ou=site,o=organization>, _
(objectClass=*);ADsPath,objectClass;subtree
The following Visual Basic 5.0 sample code illustrates this query:
Dim conn As Connection
Dim rs As Recordset
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"
Set rs conn.Execute( _
"<LDAP://server/o=organization/ou=site/cn=recipients>; _
(objectClass=*);ADsPath,objectClass,cn;subtree")
While Not rs.EOF
Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, _
rs.Fields(2).Value
rs.MoveNext
Wend
conn.Close
Additional query words: kbVBp500 kbSDKPlat kbADO kbADSI kbDSupport kbdse
Keywords :
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 11, 1999