Modifying Existing Object Attributes : Modify « Directory Services « C# / CSharp Tutorial






using System;
using System.DirectoryServices;

public class MainClass
{
  public static int Main(string[] args)
  {
    DirectoryEntry MyDirectoryObject = new DirectoryEntry();
    
    MyDirectoryObject.Path = "LDAP://HMSRevenge/CN=Greg MacBeth,OU=users,DC=Test,DC=com";
    MyDirectoryObject.Username = @"Test\tttt";
    MyDirectoryObject.Password = @"MyPassword";

    if(MyDirectoryObject.Properties[("company")].Value == "Old Company Name. inc.")
    {
      MyDirectoryObject.Properties[("company")][0] = "new name";
    }

    MyDirectoryObject.CommitChanges();

    return 0;
  }
}








34.6.Modify
34.6.1.Modifying Existing Object Attributes
34.6.2.Modify Property