如何修改 Active Directory
“Active Directory 服务接口”(ADSI) 访问分布式计算环境中来自不同网络提供商的目录服务的功能,以提供单组目录服务接口来管理网络资源。管理员和开发人员可以使用 ADSI 服务来枚举和管理目录服务中的资源,而不管是哪种网络环境包含该资源。可使用 Active Directory 执行常见管理任务,如在整个分布式计算环境中添加新用户和管理打印机。 
本示例阐释如何更改某 Active Directory 项的属性值。它是一个小型控制台应用程序,可以从命令提示处运行。该应用程序采用三个命令行参数。第一个参数必须是指向某 Active Directory 项的有效路径。第二个参数是该项的属性名。第三个参数是该项的新值。 尝试运行以下命令,用所需路径和属性名替代特定网络的有效 Active Directory 路径: > ADWrite.exe "LDAP://DC=Microsoft,DC=COM" "name" "Microsoft"写入 Active Directory 至少包括: 创建一个新的 DirectoryEntry: String adPath = ... ;
DirectoryEntry objDirEnt=new DirectoryEntry(adPath);
Dim adPath As String = ...
Dim objDirEnt As DirectoryEntry = New DirectoryEntry(adPath) 
C#  VB    
 设置 DirectoryEntry 对象的属性: String propertyName = ... ;
String newValue = ... ;objDirEnt.Properties[propertyName][0] = newValue;
Dim propertyName As String = ...
Dim newValue As String = ...objDirEnt.Properties(propertyName)(0) = newValue 
C#  VB    
 将更改提交给 Active Directory: objDirEnt.CommitChanges();
objDirEnt.CommitChanges() 
C#  VB