Partager via


Modification du nom d'un objet

DirectoryEntry fournit la méthode Rename permettant de renommer les objets de l'annuaire.

L'exemple suivant montre comment utiliser Rename pour changer le nom d'un objet d'utilisateur.

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

Voir aussi

Référence

System.DirectoryServices
DirectoryEntry

Concepts

Création, suppression, changement de nom et déplacement des objets

Send comments about this topic to Microsoft.

Copyright © 2007 par Microsoft Corporation. Tous droits réservés.