使用System.DirectoryServices.AccountManagement鎖定Active Directory用戶對象的最佳方式是什麼?我可以確定一個帳戶是否被鎖定使用..Active Directory LDAP - 鎖定用戶帳戶
UserPrincipal principal = new UserPrincipal(context);
bool locked = principal.IsAccountLockedOut();
如何鎖定帳戶?有沒有辦法做這樣的事情的替代...
UserPrincipal principal = new UserPrincipal(context);
DirectoryEntry entry = (DirectoryEntry)principal.GetUnderlyingObject();
int val = (int)entry.Properties["userAccountControl"].Value;
entry.Properties["userAccountControl"].Value = val | 0x0010;
entry.CommitChanges();