Querying an LDAP Server using Active Directory and ADOBy Julian
In order to do an ADO query against an LDAP database using Active Directory, you must install the latest version of ADSI (I believe it's currently v2.5). If you are running Windows 2000, Active Directory is already built in. To learn more about LDAP, Acitve Directory, and ADSI, check out these resources:
In our example the query is run against a Site Server LDAP database to get a listing of the users. The SQL statement consistes of:
The first thing you will notice that's different, is that the table source becomes the
LDAP server, port and node you wish to query. The field name
name) is the Attribute value you wish to return. The
WHERE part of the
statement returns all items that are an
SELECT * does not work with the ADs Provider!
In the next part of the code we instantiate an ADO Connection object, and set it's
Since I have setup my Site Server LDAP database to disallow Anonymous acces, I am going to do an authenticated bind. Doing an authenticated bind to an LDAP Server requires that the user you are binding to has Administrative rights. The Administrator password must also be supplied.
Once the connection has been suceesfully opened, the SQL Statement is executed creating an ADO recordset.
And if all goes well, we should be able to iterate the ADO recordset. The
Value is usually returned as a Variant. So keep in mind, that some items may be
returned as Arrays. Generally single value properties are Strings and multi-value
properties are Arrays.
Try querying your LDAP Schema. Have fun!