Microsoft KB Archive/187529: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - """ to """) |
||
(One intermediate revision by the same user not shown) | |||
Line 52: | Line 52: | ||
== SUMMARY == | == SUMMARY == | ||
The Active Directory Service Interfaces (ADSI) 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 | The Active Directory Service Interfaces (ADSI) 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.<br /> | ||
<br /> | <br /> | ||
The connection object Execute method's CommandText (first object) is an LDAP query composed of four elements separated by semicolons, in the following format: | The connection object Execute method's CommandText (first object) is an LDAP query composed of four elements separated by semicolons, in the following format: | ||
Line 60: | Line 60: | ||
* server is the name (or IP address) of the server hosting the directory. | * server is the name (or IP address) of the server hosting the directory. | ||
* adsidn is the distinguished name (DN) of the starting point for your query expressed ADsPath format with | * adsidn is the distinguished name (DN) of the starting point for your query expressed ADsPath format with "/" separators and the root of the namespace to the left. You can also use an X.500 style attributed name format with the relative distinguished names separated by commas and the root of the name space to the right. | ||
* 1dap filter is the LDAP filter string (see rfc2254). | * 1dap filter is the LDAP filter string (see rfc2254). | ||
* attributescsv is a comma separated list of names of the attributes to be returned for each row in the recordset. | * attributescsv is a comma separated list of names of the attributes to be returned for each row in the recordset. | ||
Line 69: | Line 69: | ||
To return the ADsPath, class, and cn attributes of all the objects in all the recipient containers in an Exchange server, you can use the following CommandText (in URL format): | To return the ADsPath, class, and cn attributes of all the objects in all the recipient containers in an Exchange server, you can use the following CommandText (in URL format): | ||
<pre class="codesample"> LDAP:<//server/o=organization/ou=site/cn=recipients>; | <pre class="codesample"> LDAP:<//server/o=organization/ou=site/cn=recipients>; | ||
(objectClass=*);ADsPath,objectClass,cn;subtree | (objectClass=*);ADsPath,objectClass,cn;subtree" | ||
</pre> | </pre> | ||
or (in attributed name format): | or (in attributed name format): | ||
Line 88: | Line 88: | ||
Set conn = New ADODB.Connection | Set conn = New ADODB.Connection | ||
conn.Provider = | conn.Provider = "ADSDSOObject" | ||
conn.Open | conn.Open "ADs Provider" | ||
Set rs = conn.Execute( _ | Set rs = conn.Execute( _ | ||
"<LDAP://server/o=organization/ou=site/cn=recipients>;" _ | |||
& | & "(objectClass=*);ADsPath,objectClass,cn;subtree") | ||
While Not rs.EOF | While Not rs.EOF |
Latest revision as of 12:39, 21 July 2020
Article ID: 187529
Article Last Modified on 7/13/2004
APPLIES TO
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
- Microsoft Active Directory Service Interfaces 2.0
- Microsoft ActiveX Data Objects 1.5
- Microsoft ActiveX Data Objects 2.0
- Microsoft ActiveX Data Objects 2.1 Service Pack 2
- Microsoft ActiveX Data Objects 2.5
This article was previously published under Q187529
SUMMARY
The Active Directory Service Interfaces (ADSI) 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
where:
- server is the name (or IP address) of the server hosting the directory.
- adsidn is the distinguished name (DN) of the starting point for your query expressed ADsPath format with "/" separators and the root of the namespace to the left. You can also use an X.500 style attributed name format with the relative distinguished names separated by commas and the root of the name space to the right.
- 1dap filter is the LDAP filter string (see rfc2254).
- attributescsv is a comma separated list of names of the attributes to be returned for each row in the recordset.
- scope is either: base, onelevel, or subtree.
NOTE: rfc2253 specifies the LDAP syntaxes on which the ADSI LDAP syntax is based.
To return the ADsPath, class, and cn attributes of all the objects in all the recipient containers in an Exchange server, you can use the following CommandText (in URL format):
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
MORE INFORMATION
The following Visual Basic sample code illustrates this query:
Sample Code
Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Set conn = New 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
REFERENCES
For a listing and explanation of common LDAP RFCs, including RFC 2253 and RFC 2254, please see the following article in the Microsoft Knowledge Base:
221606 Common LDAP RFCs
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
275917 PRB: ADSI 2.5 and MDAC 2.6 Compatibility Issues
Keywords: kbhowto kbtophit kbmdacnosweep KB187529