Deleting Objects : Delete « 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;

    foreach(DirectoryEntry D in users)
    {
      if(D.Properties["email"].Value.ToString() == "tom")
      {
        users.Remove(D);
      }
    }
    

    MyObject.CommitChanges();
    return 0;
  }
}








34.4.Delete
34.4.1.Deleting Objects
34.4.2.Delete Object
34.4.3.Remove Object