Microsoft KB Archive/241474

= How To Render the Global Address List with ADSI =

Article ID: 241474

Article Last Modified on 9/28/2007

-

APPLIES TO


 * Microsoft Active Directory Service Interfaces 2.5
 * Microsoft Active Directory Service Interfaces 1.0
 * Microsoft Active Directory Service Interfaces 2.0

-



This article was previously published under Q241474



SUMMARY
This article demonstrates how to display the Microsoft Exchange Global Address List (GAL) using Active Directory Services Interfaces (ADSI).



MORE INFORMATION
In order to render the GAL using ADSI in an Active Server Page (.asp), you must have the following software installed on your Microsoft Windows NT network.


 * Microsoft Exchange Server 5.5
 * ADSI 2.5 (recommended)
 * Internet Information Server

Use the following steps for implementation:
 * 1) Copy the following code sample into your .asp file.
 * 2) Change any reference to "MyServer" with the name of the target Microsoft Exchange Server.
 * 3) Open the .asp file in your client browser to view the results.

In this sample ADSI uses an OLEDB provider and Lightweight Directory Access Protocol(LDAP) to retrieve information from the Exchange directory. For information about building ADO queries for ADSI, please click the article number below to view the article in the Microsoft Knowledge Base:

187529 How To Using ADO to Access Objects Through ADSI LDAP Provider

  Global Address List <%  'TO DO : Change the below name to your Exchange server name '  ' Note if you want to use NT Challenge Response authentication this ' will need to be the same machine as the ASP is running on  strServerName = "MyServer" strUser = Request.ServerVariables("LOGON_USER") 'retrieve the user if strUser = "" then Response.Write "You are using Anonymous authentication you will need to change it so the user can be identified" Response.End end if

set oConn = CreateObject("ADODB.Connection") set oCommand = CreateObject("ADODB.Command") set oRS = CreateObject("ADODB.Recordset")

oConn.Provider = "ADsDSOObject" oConn.Open "Ads Provider"

set oCommand.ActiveConnection = oConn 'set the active connection

' Next we will build the LDAP query that will be used to retrieve the contents of the GAL. ' We will specify which server we want to run the query against, ' a filter for what types of objects we are looking for, the attributes we would like ' returned, and the type of search ' A filter of (objectClass=person) will return mailboxes, distribution lists, and custom recipients

strQuery= ";(objectClass=person);cn,telephoneNumber,physicalDeliveryOfficeName,title,company,objectClass,uid;subtree" oCommand.CommandText = strQuery oCommand.Properties("Page Size") = 99  'a paged query is used to avoid Exchange LDAP server limits set oRS = oCommand.Execute  'Execute the query

' Now we will loop through the results of our query '  and build a table to display the Global Address List %>  

