2012-03-05 43 views
2

我有一些代碼,retreive目前在Active Directory不同組的用戶。Active Directory中的域用戶無法獲得用戶?

string sADPath = "LDAP://" + tbDomain.Text; 
string username = tbUsername.Text; 
string password = tbPassword.Text; 
DirectorySearcher mySearcher = new DirectorySearcher(directoryEntry); 


int MaxResults = Int32.MaxValue - 1; 


ComboBoxItem selectItem = (ComboBoxItem)ddlGroups.SelectedItem; 
String value = selectItem.Value; 

mySearcher.Filter = ("(&(objectCategory=person)(objectClass=User)(memberOf=" + value + "))"); 

mySearcher.SearchScope = SearchScope.Subtree; 


foreach (SearchResult temp in mySearcher.FindAll()) 
{ 
} 

此代碼工作正常對某些羣體,但不是所有的。

例如,它讓我獲得域管理員的價值,而不是域用戶中的用戶。

它也不會讓我的用戶在Users文件夾組中?

我在FindAll()獲得域值用戶的0值。

回答

3

您遇到不同的問題。

您無法找到Domain Users的任何用戶成員這一事實可以通過以下事實來解釋:Domain Users是您創建的每個新用戶的默認主要組。 primarygroup不存在於memberof Attribute中,但在primaryGroupID屬性中。更多primaryGroupID不是一個區分名稱,而是主要組的相對標識符(RID)。你會發現在我寫答案C#代碼:How to retrieve Users in a Group, including primary group users