重命名对象
DirectoryEntry 提供了 Rename 方法以重命名目录中的对象。
下面的示例说明如何使用 Rename 更改 User 对象的名称。
Try
' Bind to the user object to modify.
Dim child As New DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com")
' Rename the object to Jeff Smith.
child.Rename("CN=New User Name")
Catch COMEx As COMException
' If a COMException is thrown, then the following code can capture the text of the error.
' For instructions about handling COM exceptions, see Handling Errors.
Console.WriteLine(COMEx.ErrorCode)
End Try '}
try
{
// Bind to the user object to modify.
DirectoryEntry child = new DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com");
// Rename the object to Jeff Smith.
child.Rename("CN=New User Name");
}
catch (COMException COMEx)
{
// If a COMException is thrown, then the following code can capture the text of the error.
// For more information about handling COM exceptions, see Handling Errors.
Console.WriteLine(COMEx.ErrorCode);
)
另请参见
参考
System.DirectoryServices
DirectoryEntry
概念
Send comments about this topic to Microsoft.
版权所有 (C) 2007 Microsoft Corporation。保留所有权利。