Creating Paths to Active Directory Objects and Attributes


The first step in developing any ADSI application that accesses Active Directory is creating a valid instance of ADSI and passing this instance a valid path to the object you want to access. When you write Java, Visual Basic, VBScript, or Visual Basic for Applications (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 container object named Users , using a specific server named DirServer and in a specific domain named Microsoft.com , you pass in the following AdsPath to the GetObject method:

 LDAP://DirServer/cn=Users, dc=Microsoft, dc=com 

The LDAP at the beginning of the path specifies the ADSI provider to use. If you want to simply 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, the following sets the oIADs variable to the LDAP provider:

 oIADs = GetObject("LDAP:") 

To specify a different provider, you can replace the LDAP string with WinNT or NDS . To access a specific recipient in a specific container on the DirServer server, you use the following AdsPath :

 LDAP://DirServer/cn=  RecipientName  , cn=  RecipientContainer  , dc=Microsoft, dc=com 

As you can see from the examples, the syntax for creating a valid path follows this structure:

 LDAP://  DirectoryServer  /cn=  Bottommost object  , cn=  next level of object  , dc=  domain1  , dc=  domain2  

The sample application in this chapter shows examples of how to use this syntax to query different parts of Active Directory.

Note  

Do not mix cases in your identifiers when you create paths (for example, CN= users or dc= microsoft . If you do, you will get an error from ADSI.




Programming Microsoft Outlook and Microsoft Exchange 2003
Programming MicrosoftВ® OutlookВ® and Microsoft Exchange 2003, Third Edition (Pro-Developer)
ISBN: 0735614644
EAN: 2147483647
Year: 2003
Pages: 227
Authors: Thomas Rizzo

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net