Platform SDK: Active Directory, ADSI, and Directory Services

Creating a Recipients Container

After you create the following recipients container, you must recalculate the address book hierarchy. The Exchange Administrator application uses standard Windows service manager calls to send a control code to the directory service. The API for accessing the service control manager is documented in the Win32 documentation, but the code used by the Exchange Administrator is not published. The control code needed by the administrator is DS_SERVICE_CONTROL_RECALC_HIERARCHY. The value of this constant is 129.

Dim objExistingCont As IADsContainer
Dim objNewCont As IADs
' Bind to an existing container
Set objExistingCont = GetObject("LDAP://Server/cn=Recipients,ou=Site")
' Create the container
Set objNewCont = objExistingCont.Create("Container", "cn=MyNewContainer")
' Put the continer-info prop to tell Exchange this is a recipients cont.
objNewCont.Put "Container-Info", &H80000001
objNewCont.SetInfo
Set objCont = Nothing
Set objNewCR = Nothing

Note: This example is specific to Exchange Server version 5.5 and below, and is not upwardly compatible with Exchange 6.0. Management and access of Exchange 6.0 Servers should be made through the CDO Exchange Management interfaces instead.