Ridenominazione di un oggetto

DirectoryEntry fornisce il metodo Rename per ridenominare gli oggetti nella directory.

Nell'esempio riportato di seguito viene illustrato come utilizzare Rename per cambiare il nome di un oggetto 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);
)

Vedere anche

Riferimenti

System.DirectoryServices
DirectoryEntry

Concetti

Creazione, eliminazione, ridenominazione e spostamento di oggetti

Send comments about this topic to Microsoft.

Copyright © 2007 Microsoft Corporation. Tutti i diritti riservati.