gpt4 book ai didi

c# - 无法让用户出现在 Active Directory 的域用户中?

转载 作者:行者123 更新时间:2023-11-30 21:08:36 25 4
gpt4 key购买 nike

我有一些代码可以检索 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())
{
}

此代码适用于某些组,但不适用于所有组。

例如,它为我提供了域管理员的值,但没有为域用户中的用户提供值。

它也不会让我的用户进入用户文件夹组吗?

我在 FindAll() 中得到域用户的 0 值。

最佳答案

您遇到了不同的问题。

您找不到 Domain Users 的任何用户成员的事实可以解释为 Domain Users 是您创建的每个新用户的默认主要组。 primarygroup 不存在于 memberof 属性中,而是存在于 primaryGroupID 属性中。甚至更多 primaryGroupID 不是专有名称,而只是主要组的相对标识符 (RID)。您将在我写给的答案中找到 C# 代码:How to retrieve Users in a Group, including primary group users

关于c# - 无法让用户出现在 Active Directory 的域用户中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9574646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com