c#GroupPrincipal.FindByIdentity查找组,但使用GetMembers getting error时,服务器上没有此类对象
在过去的一年里,该代码一直运行良好, 现在它仍在工作,但我只有4个组生成此错误 代码很简单:c#GroupPrincipal.FindByIdentity查找组,但使用GetMembers getting error时,服务器上没有此类对象,c#,active-directory,ldap-query,principalcontext,groupprincipal,C#,Active Directory,Ldap Query,Principalcontext,Groupprincipal,在过去的一年里,该代码一直运行良好, 现在它仍在工作,但我只有4个组生成此错误 代码很简单: using (var context = new PrincipalContext(ContextType.Domain, domName)) { foreach (string grp in myGroups) { using (var group =
using (var context = new PrincipalContext(ContextType.Domain, domName))
{
foreach (string grp in myGroups)
{
using (var group = GroupPrincipal.FindByIdentity(context, IdentityType.Name, grp))
{
PrincipalSearchResult<Principal> usersList;
usersList = group.GetMembers(true);
int usersListCount = usersList.Count();
}}}
使用(var context=newprincipalcontext(ContextType.Domain,domName))
{
foreach(myGroups中的字符串grp)
{
使用(var group=GroupPrincipal.FindByIdentity(context,IdentityType.Name,grp))
{
PrincipalSearchResult用户列表;
usersList=group.GetMembers(true);
int usersListCount=usersList.Count();
}}}
当这些特定的组来搜索时,我会得到该组,并可以在组对象变量中看到它的描述,但是当得到其成员时,我会得到一个错误消息:
base:“服务器上没有这样的对象。\r\n”
错误代码:-2147016656
同样,这种情况只发生在同一领域和同一OU的4个特定组中。
这几天前刚开始,我没有修改任何内容,没有权限,代码中没有任何内容,非常奇怪
有什么想法吗?我发现了这个问题,
问题组包含来自不同域的用户,
一旦将这些用户从组中删除,一切都恢复正常。
谢谢。不,没有。。。。。。