Questions tagged «directoryservices»

5
如何确定用户帐户是启用还是禁用
我正在整理一个快速的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用户属性,但没有发现任何有用的东西。 谁能提供任何指针?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.