2012-04-07 47 views
3

到目前爲止,我能夠在LDAP中找到用戶,但我不知道如何啓用或禁用它們。如何使用LDAP請求啓用或禁用AD用戶帳戶?

第二個問題,如果我的帳戶具有域管理員權限,我將能夠從LDAP啓用或禁用帳戶?

注:這是關於在Windows 2003上

運行Microsoft Active Directory的我知道,我可以檢查活動使用有:

(!(useraccountcontrol:1.2.840.113556.1.4.803:=2)) 

殘疾人useds:

(useraccountcontrol:1.2.840.113556.1.4.803:=2) 

問題是如何設置屬性,使其不會丟失其他二進制標誌。

回答

3

你需要在這裏使用一些邏輯。因此,要禁用用戶,請設置禁用位(2)。所以:

const long ADS_UF_ACCOUNTDISABLE = 0x00000002; 
long userAccountControl = //currentUacValue 
long newUserAccountControl = (userAccountControl | ADS_UF_ACCOUNTDISABLE); 

要啓用的帳戶,我們需要明確禁止位:

long userAccountControl = //currentUacValue 
long newUserAccountControl = (userAccountControl & ~ADS_UF_ACCOUNTDISABLE)