The first step in developing any ADSI application that accesses the Exchange Server directory is creating a valid instance of ADSI and passing this instance a valid path to the object you want to access. When writing Java, Visual Basic, VBScript, or VBA applications, the easiest way to create a valid instance of the ADSI library is to use the GetObject(AdsPath) syntax. The AdsPath parameter contains a valid ADSI path to a specific object. For example, to access a specific Exchange Server object named ExServer, a specific Organization in Exchange Server named Microsoft, and a specific site in the Organization named ExSite, you would pass in the following AdsPath to the GetObject method:
LDAP://ExServer/ou=ExSite, o=Microsoft |
The LDAP at the beginning of the path specifies the ADSI provider to use. If you just want to set an object variable to a specific ADSI provider without attempting to open an object, you can also use the GetObject(ADSIProvider) syntax. For example,
oIADs = GetObject("LDAP:") |
sets the oIADs variable to the LDAP provider. To specify a different provider, you would replace the LDAP string with WinNT or NDS. To access a specific recipient in a specific container on the ExServer Exchange Server, you would use the following AdsPath:
LDAP://ExServer/cn=RecipientName, cn=RecipientContainer, ou=ExSite, o=Microsoft |
As you can see from both examples, the syntax for creating a valid path follows this structure:
LDAP://Exchange NT Server Name/cn=Bottommost object, cn=next level of object, ou=Exchange Site, o=Exchange Organization |
Throughout the sample application in this chapter, you will see examples of how to use this syntax to query different parts of the Exchange Server directory.