Manipulating ADAM programmatically can be a little challenging. First, the documentation that is installed with ADAM does not cover its programming interfaces. However, that documentation can be found within MSDN, under Networking and Directory Services. Second, while that documentation provides samples in VBScript, Visual Basic and C#, I could only get the VBScript code to work and translated that into C# code myself. When manipulating ADAM programmatically, one uses the same tools as one would use to manipulate Active Directory, which brings us to the last of our challenges. The .NET Framework Class Library includes a DirectoryServices namespace for working with entries in a Directory Service, but that namespace has very limited facilities, which is why I often refer to it as the ghetto of the .NET Framework. The most important class in the namespace, the DirectoryEntry class, has a property called NativeObject that allows one to work with the directory using the COM Active Directory Service Interface library.
Here, then, is the code for creating the application directory partition for TaskVision II within ADAM, and for creating a container for users within it.
using
namespace
{
[FlagsAttribute]
HEAD = 1,
WRITABLE = 4
};
[STAThread]
System.Collections.Hashtable rConfigurationSection =
rConfigurationSection = (System.Collections.Hashtable)System.Configuration.ConfigurationSettings.GetConfig(CConfigurator.c_sConfigurationSection_Credentials);
rConfigurationSection = (System.Collections.Hashtable)System.Configuration.ConfigurationSettings.GetConfig(CConfigurator.c_sConfigurationSection_ADAMInstance);
DirectoryEntry.Exists(sADsPath_ApplicationDirectoryPartition);
}
fExists =
ActiveDs.IADsOpenDSObject rOpenObject = (ActiveDs.IADsOpenDSObject)
ActiveDs.IADsContainer rContainer = (ActiveDs.IADsContainer)rOpenObject.OpenDSObject(sADsPath,sUserName,sPassword,(
ActiveDs.IADs rObject = (ActiveDs.IADs)rContainer.Create("organization",
rObject.Put("instanceType",DIRECTORY_SERVICE_CONTAINER_PROPERTIES.HEAD|DIRECTORY_SERVICE_CONTAINER_PROPERTIES.WRITABLE);
rObject.Put("description",sApplicationDirectoryPartitionDescription);
rObject.SetInfo();
rContainer = (ActiveDs.IADsContainer)rOpenObject.OpenDSObject(sADsPath_ApplicationDirectoryPartition,sUserName,sPassword,(
rObject = (ActiveDs.IADs)rContainer.Create("container",
System.Console.WriteLine(((rException.Message ==
The app.config file:
<?
<
</
The .NET Directory Entry class is used merely to check whether or not the application directory partition already exists, and if it does not, to retrieve a reference to the COM Active Directory Service Interfaces. Those interfaces are then used to create a directory partition for the application, with the path, o=TaskVisionII,c=US, and then to create a container for users, CN=Users,o=TaskVisionII,c=US, within that partition.
[This posting is provided "AS IS" with no warranties, and confers no rights.]