Attivazione e disattivazione dell'account utente

Per attivare un account utente è necessario rimuovere il flag ADS_UF_ACCOUNTDISABLE dall'attributo userAccountControl dell'oggetto utente. Per ulteriori informazioni sull'attributo userAccountControl, vedere gli argomenti relativi a userAccountControl o User-Account-Control in MSDN Library all'indirizzo https://go.microsoft.com/fwlink/?LinkID=27252 (informazioni in lingua inglese). Il flag ADS_UF_ACCOUNTDISABLE è definito in ADS_User_Flag_Enum. Per ulteriori informazioni sull'enumerazione ADS_User_Flag_Enum, vedere l'argomento relativo in MSDN Library all'indirizzo https://go.microsoft.com/fwlink/?LinkID=27252 (informazioni in lingua inglese).

Nell'esempio riportato di seguito viene illustrato come attivare un account utente.

DirectoryEntry usr = 
    new DirectoryEntry("LDAP://CN=New User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val & 
    ~(int)ActiveDs.ADS_USER_FLAG.ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();

Nell'esempio riportato di seguito viene illustrato come disattivare un account utente.

DirectoryEntry usr = 
    new DirectoryEntry("LDAP://CN=Old User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | 
    (int)ActiveDs.ADS_USER_FLAG.ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();

Vedere anche

Riferimenti

System.DirectoryServices

Concetti

Gestione di utenti

Send comments about this topic to Microsoft.

Copyright © 2007 Microsoft Corporation. Tutti i diritti riservati.