询问者
代码中枚举用户所在所有群组时,提示错误:An error occurred while enumerating the groups. The group could not be found

问题
-
在通过System.DirectoryServices.AccountManagement下的PrincipalContext调用GetAuthorizationGroups时,抛出异常:An error occurred while enumerating the groups. The group could not be found.但只是一部分用户在访问时会出现异常,不是所有的。请问该问题是什么原因引发的,寻求解决方案,谢谢! 代码:PrincipalContext principalContext = new PrincipalContext(ContextType.Domain); UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext,IdentityType.SamAccountName,"userLoginName"); PrincipalSearchResult<Principal> list = userPrincipal.GetAuthorizationGroups();
全部回复
-
Hi,
>>" 但只是一部分用户在访问时会出现异常 ".
会不会是这部分用户的权限导致这样问题。你有尝试过赋予相同的用户权限吗? 这个Domain,应该就是涉及到权限的问题。
如果有什么最新的情况,请随时联系我们。
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
这个用户和其他用户有什么不同的地方吗? 这种问题最难定位了,因为有的好使,有的不好使。
你有debug你的程序吗?具体在哪里出现错误。
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Hi,
从这些错误信息,我们就可以知道,是这个群组没有找到,所以先确认能找到你的群组信息。是不是这个群组有特殊的权限吗?
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.