Cambiar el nombre de un objeto

DirectoryEntry proporciona el método Rename para cambiar el nombre de los objetos del directorio.

En el siguiente ejemplo se muestra cómo usar Rename para cambiar el nombre de un objeto de usuario.

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);
)

Consulte también

Referencia

System.DirectoryServices
DirectoryEntry

Conceptos

Crear, eliminar, cambiar el nombre y mover objetos

Send comments about this topic to Microsoft.

Copyright © 2007 Microsoft Corporation. Reservados todos los derechos.