Opening Contacts from Active Directory

Opening Contacts from Active Directory

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Iperson.DataSource property returns the attached IDataSource interface. The IDataSource interface exposes two methods that open contacts from Microsoft® Active Directory®: 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 illustrates 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.

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

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.