Share via


Opening Contacts from Active Directory

Topic Last Modified: 2006-06-30

The Iperson.DataSource property returns the attached IDataSource interface. The IDataSource interface exposes two methods that open contacts from the Active Directory® directory service: Open and OpenObject.

You can call the IDataSource.Open method to bind to, and open data from, an existing item specified by a URL. The IDataSource.OpenObject method allows you to open data from a different object at run time.

The LDAP binding string contains prefixes and distinguishing names that specify the position of the contact in the Active Directory hierarchy. Use the following prefixes: CN for common names, DC for domains, and O or OU for organizations. CN specifies the common name of the object and the classification of the object, such as users. Use as many DCs as necessary for each qualification in the domain name, including a DC for sub-domains.

Example

The following example shows how to open a contact from Active Directory. The LDAP binding string contains the first and last names of the user, the classification of the user, and the domain of the server. The IDataSource.Open method uses the LDAP binding string to bind to and open the contact from Active Directory.

Example

Visual Basic

'Declare variables
Dim iPer As New CDO.Person
Dim strLDAP As String

'Setup the LDAP string 
strLDAP = "LDAP://servername/cn=Max Benson, cn=users, dc=domain, dc=com"

'Open the contact to Active Directory
iPer.DataSource.Open strURL

See Also

Other Resources

IDataSource Interface