Creating Nodes in an Active Directory Hierarchy
The Active Directory hierarchy can be comprised of several thousand nodes. Each node represents an object, such as a network printer or a user in a domain. Corporate networks constantly change as new employees are hired and objects such as network printers and computers are added. ADSI technology provides ways to programmatically add these objects to the directory tree.
To create a directory entry in the hierarchy, you must use the Children property of the DirectoryEntry component. The Children collection provides an Add method that allows you to add a node to the Children collection directly below the parent node that you are currently bound to. To do this, you must specify a name for the new node and the name of a schema template that you wish to associate with the node. For example, you may want to use a schema titled "computer" to add new computers.
To create a node in an Active Directory hierarchy
- Bind an instance of the DirectoryEntry object to the parent directory and call the Add method to add a child to the directory. For more information, see Creating DirectoryEntry Component Instances.
' Visual Basic Dim entry As New DirectoryServices.DirectoryEntry("WinNT://DomainName") entry.Children.Add("NewEntryName", "SchemaNametoUse") // C# System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry("WinNT://DomainName"); entry.Children.Add("NewEntryName","NameofSchemaTemplate");
Introduction to Active Directory Objects | Searching Active Directory Hierarchies | Walkthrough: Adding Active Directory Objects | Removing Active Directory Nodes | Modifying Object Properties in an Active Directory Hierarchy