Click here to Skip to main content
13,088,846 members (70,099 online)
Click here to Skip to main content
Add your own
alternative version


31 bookmarked
Posted 5 May 2004

Exchange Server, ASP and ADSI / LDAP

, 5 May 2004
Rate this:
Please Sign up or sign in to vote.
How to access the address book of the Exchange Server with ASP and ADSI / LDAP.


With ADSI (Active Directory Service Interface), Microsoft offers a COM-component for the access to various directory services. ADSI is a component of Windows 2000.

You can think of ADSI as a kind of ODBC-interface for various directory services. In a network, directory services act as an administration of users and capabilities, e.g. computers, printers, users and services.

The structure of a directory service is hierarchic, it can be seen as a directory tree: there is a root where you can start from to other entries. The root can contain containers (knots) and leaves. Containers themselves can contain other entries while leaves mark the end of a branch in a directory tree. Every entry in this directory describes an object and has specific attributes. This can be illustrated with the Windows file system: the hard disk c: is the root, the directories/folders are the containers and the files are the leaves.

Examples for directory systems which are supported by ADSI are: WinNT (access to Windows NT), GC (Windows 2000 Global Catalog), IIS (Internet Information Server Metabase), NWCOMPAT (Novell NetWare 3.x), NDS (Novell NetWare 4.x) and LDAP-directories.

The directory service LDAP will especially be considered in this context. LDAP (Lightweight Directory Access Protocol) was developed at the University of Michigan in the early 90’s and allows an easier access to the directory services of X.500 protocol. LDAP is based on TCP/IP and uses the port number 389. More and more firms integrate LDAP in their products, e.g. Microsoft with its products Exchange, Windows 2000 and Site Server.

Access to the LDAP directory of Exchange

First of all, it must be assured that the internet user has got access to the LDAP directory.

The read access via ADSI to an object in the directory tree takes place with the GetObject method:

StrServer = "Exchange01"
Set cont = GetObject("LDAP://" & strServer)
For Each obj in cont
   Response.Write obj.Name & "<BR>"

The root of the LDAP of Exchange contains the different locations of the company. The contents of this container can be displayed via the FOR-NEXT loop. StrServer is the name of the exchange server on the network.

After displaying the different locations, the Exchange users of the different locations can be displayed in the next step.

To accomplish this, the root must be known. In this specific case, it is "o=BSP".

strServer = "Exchange01"
strOrganisation = "o=BSP"
strLocation = "ou=Mannheim"

Set cont = GetObject("LDAP://" & strServer &"/cn=Recipients,"_
           & strLocation & "," & strOrganisation)
For Each obj in cont
   Response.Write & obj.Name & "<BR>"

This means an access to the container "cn= Recipients", which contains the data of the exchange users. With the For-NEXT loop, the individual objects of this container, i.e. the users, can be displayed.

Now that the single users are known, their attributes can be displayed:

strServer = "Exchange01"
strOrganisation = "o=BSP"
strLocation = "ou=Mannheim"
strUser = "cn=ckiefer"
Set objMailbox = GetObject("LDAP://" & strServer &"/" &strUser& ",_
   cn=Recipients," & strLocation & "," & strOrganisation)
response.write "<table border=1>"
response.write "<tr><td colspan=""2"">Userdetails</td></tr>"
response.write "<tr><td>name</td><td>" & & "</td></tr>"
response.write "<tr><td>mail</td><td>" & objMailbox.mail & "</td></tr>"
response.write "<tr><td>cn</td><td>" & & "</td></tr>"
response.write "<tr><td>sn</td><td>" & & "</td></tr>"
response.write "<tr><td>givenname</td><td>" & objMailbox.givenname & "</td></tr>"
response.write "<tr><td>member</td><td>" & objMailbox.member & "</td></tr>"
response.write "<tr><td>department</td><td>" & objMailbox.department & "</td></tr>"
response.write "<tr><td>title</td><td>" & objMailbox.title & "</td></tr>"
response.write "<tr><td>uid</td><td>" & objMailbox.uid & "</td></tr>"
response.write "<tr><td>company</td><td>" & & "</td></tr>"
response.write "<tr><td>telephonenumber</td><td>" &_
   objMailbox.telephonenumber & "</td></tr>"
response.write "<tr><td>facsimiletelephonenumber</td><td>" &_
   objMailbox.facsimiletelephonenumber & "</td></tr>"
response.write "<tr><td>postaladdress </td><td>" &_
   objMailbox.postaladdress & "</td></tr>"
response.write "<tr><td>homepostaladdress </td><td>" &_
   objMailbox.homepostaladdress & "</td></tr>"
response.write "<tr><td>physicalDeliveryOfficeName</td><td>"_
   & objMailbox.physicalDeliveryOfficeName & "</td></tr>"
response.write "</table>"

If you put these functions together, you can write an ASP script which allows you to display the entries of the Exchange address book.

Download the complete script and enjoy.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Christian Kiefer
Web Developer
Germany Germany
Christian Kiefer works as a Consultant and developer for internet-software in the middle of Germany.

As an Internet specialist, Christian has designed and developed many ASP based applications that take advantage of advanced database and directory services.

Christian specializes in advanced Internet technologies such as DHTML, ASP, ADSI, XML, and ASP.NET.

You may also be interested in...


Comments and Discussions

QuestionWhat is strOrganisation = "o=BSP"?? Pin
zenjohn1-Nov-06 14:16
memberzenjohn1-Nov-06 14:16 
QuestionLDAP query slows down too long Pin
emmpergul1-Aug-06 10:02
memberemmpergul1-Aug-06 10:02 
QuestionWhere is index_exchange.asp? Pin
pguths24-Nov-05 7:55
memberpguths24-Nov-05 7:55 
AnswerRe: Where is index_exchange.asp? Pin
Christian Kiefer30-Nov-05 21:15
memberChristian Kiefer30-Nov-05 21:15 
GeneralLDAP:// protocol in web browser Pin
cacadeperro31-Oct-05 11:38
membercacadeperro31-Oct-05 11:38 
GeneralRe: LDAP:// protocol in web browser Pin
Christian Kiefer31-Oct-05 23:20
memberChristian Kiefer31-Oct-05 23:20 
Questionwhere is the exchange server? Pin
explosure99914-Aug-05 23:17
memberexplosure99914-Aug-05 23:17 
Aaron3118-Jul-05 16:29
memberAaron3118-Jul-05 16:29 
Christian Kiefer26-Jul-05 22:18
memberChristian Kiefer26-Jul-05 22:18 
GeneralExchange 5.5 Pin
Offlinesurfer30-Sep-04 11:46
memberOfflinesurfer30-Sep-04 11:46 
GeneralRe: Exchange 5.5 Pin
Christian Kiefer28-Oct-04 22:40
memberChristian Kiefer28-Oct-04 22:40 
Generalselect box is empty Pin
lizm10023-Jul-04 5:50
memberlizm10023-Jul-04 5:50 
GeneralRe: select box is empty Pin
Anonymous8-Oct-04 1:20
sussAnonymous8-Oct-04 1:20 
GeneralThank you Pin
Thomas Felting10-May-04 22:46
memberThomas Felting10-May-04 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170813.1 | Last Updated 6 May 2004
Article Copyright 2004 by Christian Kiefer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid