我將一個快速的C#win表單應用程序放在一起,以幫助解決重複性的文書工作。如何確定用戶帳戶是啓用還是禁用
我已在AD中爲所有用戶帳戶執行搜索,並將它們添加到帶有複選框的列表視圖中。
我想默認listviewitems的默認檢查狀態取決於帳戶的啓用/禁用狀態。
string path = "LDAP://dc=example,dc=local";
DirectoryEntry directoryRoot = new DirectoryEntry(path);
DirectorySearcher searcher = new DirectorySearcher(directoryRoot,
"(&(objectClass=User)(objectCategory=Person))");
SearchResultCollection results = searcher.FindAll();
foreach (SearchResult result in results)
{
DirectoryEntry de = result.GetDirectoryEntry();
ListViewItem lvi = new ListViewItem(
(string)de.Properties["SAMAccountName"][0]);
// lvi.Checked = (bool) de.Properties["AccountEnabled"]
lvwUsers.Items.Add(lvi);
}
我很努力地找到正確的屬性來解析從DirectoryEntry對象獲取帳戶的狀態。我搜索了AD User attributes,但沒有找到任何有用的東西。
任何人都可以提供任何指針?
完美謝謝。 – Bryan 2010-01-05 11:36:10
該死的,你快,但這是一個鏈接關於所有的標誌是什麼意思:http://msdn.microsoft.com/en-us/library/ms680832.aspx – Oliver 2010-01-05 11:47:47
thx您的評論:) +1 – 2010-01-05 11:48:48