Adding Objects To The Directory : Add « Directory Services « C# / CSharp Tutorial






using System;
using System.DirectoryServices;

public class MainClass 
{
  public static int Main(string[] args)
  {
    DirectoryEntry MyObject = new DirectoryEntry();
    MyObject.Path = "LDAP://HMSRevenge/OU=Users,DC=Test,DC=com";

    DirectoryEntries users = MyObject.Children;

    DirectoryEntry NewUser = users.Add("New User", "user");
    NewUser.Properties["company"].Add("Your Corporation");
    NewUser.Properties["employeeID"].Add("01");
    NewUser.Properties["userPassword"].Add("YOurPassword");

    NewUser.CommitChanges();

    return 0;
  }
}








34.3.Add
34.3.1.Add Object
34.3.2.Add Property
34.3.3.Adding Objects To The Directory