我無法從LDAP顯示一些用戶。我不知道爲什麼。這裏是我的代碼LDAP查詢不顯示某些用戶
try
{
string path = "LDAP://" + Program.domain;
DirectoryEntry dEntry = new DirectoryEntry(path);
DirectorySearcher dSearcher = new DirectorySearcher(dEntry);
dSearcher.Filter = "(&(objectClass=user)(objectCategory=person))";
//perform search on active directory
sResults = dSearcher.FindAll();
//loop through results of search
foreach (SearchResult searchResult in sResults)
{
//string view = searchResult.Properties["samaccountname"][0].ToString();
// Console.WriteLine(searchResult.Properties["userprincipalname"][0].ToString());
if (searchResult.Properties["samaccountname"][0].ToString() == Program.username)
{
Console.WriteLine("**********UserDetails******************");
foreach (Object propertyName in searchResult.Properties.PropertyNames)
{
ResultPropertyValueCollection valueCollection =
searchResult.Properties[(string)propertyName];
foreach (Object propertyvalue in valueCollection)
{
Console.WriteLine((string)propertyName + " : " + propertyvalue);
result = true;
}
}
Console.WriteLine("************************************");
}
}
這顯示誰在AD中存在不顯示用戶少但很少有其他用戶。 他們也是域管理員和域用戶。我沒有看到任何權限問題也尚未... 我認真地需要一些help.Can有人幫助我嗎?
感謝
這並不意味着要回答你的問題,但如果你正在運行的.NET 3.5或更好的,你可能會發現[System.DirectoryServices.AccountManagement API(http://msdn.microsoft.com/en- us/library/bb299745.aspx)優於舊的搜索Active Directory的方式。 –
我同意dj。直到切換到主體對象之前,我經歷了一段悲慘的經歷。 –
Program.domain的價值是什麼? – Hans