本文介绍了而试图检索授权组,(5)发生了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此错误是我所得到的,如果我在服务器上运行的应用,而不是在本地。这究竟是为什么在服务器上,而不是本地???

 名单,其中,GroupPrincipal>结果=新名单,其中,GroupPrincipal>();

//建立域上下文
PrincipalContext YOURDOMAIN =新PrincipalContext(ContextType.Domain);

//找到你的用户
UserPrincipal用户= UserPrincipal.FindByIdentity(您的域,用户名);

//如果找到了 - 抓住它的群体
如果(用户!= NULL)
{
//这里发生在服务器上的错误。
PrincipalSearchResult<主>基团= user.GetAuthorizationGroups();
 

请帮我。

堆栈跟踪:

  [PrincipalOperationException:虽然试图检索授权组,(5)发生错误]
   System.DirectoryServices.AccountManagement.AuthZSet..ctor(字节[] userSid,NetCred凭据,ContextOptions contextOptions,串flatUserAuthority,StoreCtx userStoreCtx,对象userCtxBase)317263
   System.DirectoryServices.AccountManagement.ADStoreCtx.GetGroupsMemberOfAZ(首席P)441
   System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroupsHelper()+78
   System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroups()+11
   IntegrationApp.App_ code.ActiveDir.GetGroups(用户名字符串)在C:\ Documents和Settings \ MTA \我的文档\ IntegrationApp \ IntegrationApp \ APP_ code \ 3层\ DAL \ ActiveDir.cs:54
   IntegrationApp.App_ code._3_Tier.BAL.DatabaseBAL.BepaalDefaultNiveau2(字符串melder)在C:\ Documents和Settings \ MTA \我的文档\ IntegrationApp \ IntegrationApp \ APP_ code \ 3层\ BAL \ DatabaseBAL。 CS:75
   IntegrationApp.Detailscherm.VulLijsten()在C:\ Documents和Settings \ MTA \我的文档\ IntegrationApp \ IntegrationApp \ Detailscherm.aspx.cs:89
   IntegrationApp.Detailscherm.Page_Load(对象发件人,EventArgs e)在C:\ Documents和Settings \ MTA \我的文档\ IntegrationApp \ IntegrationApp \ Detailscherm.aspx.cs:30
   错误帮助(IntPtr的FP,对象o,对象T,EventArgs的)+25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发件人,EventArgs的)+42
   System.Web.UI.Control.OnLoad(EventArgs的五)+132
   System.Web.UI.Control.LoadRecursive()+66
   System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)2428
 

解决方案

我发现了另一种解决方案来获得访问组:

  PrincipalSearchResult<主>基团= user.GetGroups();
 

This error is what I get if I run the application on the server, but not locally. Why is this happening on the server and not locally???

List<GroupPrincipal> result = new List<GroupPrincipal>();

// establish domain context
PrincipalContext yourDomain = new PrincipalContext(ContextType.Domain);

// find your user
UserPrincipal user = UserPrincipal.FindByIdentity(yourDomain, userName);

// if found - grab its groups
if (user != null)
{
//here happens the error on server.
PrincipalSearchResult<Principal> groups = user.GetAuthorizationGroups();

Please help me.

stack trace:

   [PrincipalOperationException: While trying to retrieve the authorization groups, an error (5) occurred.]
   System.DirectoryServices.AccountManagement.AuthZSet..ctor(Byte[] userSid, NetCred credentials, ContextOptions contextOptions, String flatUserAuthority, StoreCtx userStoreCtx, Object userCtxBase) +317263
   System.DirectoryServices.AccountManagement.ADStoreCtx.GetGroupsMemberOfAZ(Principal p) +441
   System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroupsHelper() +78
   System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroups() +11
   IntegrationApp.App_Code.ActiveDir.GetGroups(String userName) in C:\Documents and Settings\mta\My Documents\IntegrationApp\IntegrationApp\App_Code\3-Tier\DAL\ActiveDir.cs:54
   IntegrationApp.App_Code._3_Tier.BAL.DatabaseBAL.BepaalDefaultNiveau2(String melder) in C:\Documents and Settings\mta\My Documents\IntegrationApp\IntegrationApp\App_Code\3-Tier\BAL\DatabaseBAL.cs:75
   IntegrationApp.Detailscherm.VulLijsten() in C:\Documents and Settings\mta\My Documents\IntegrationApp\IntegrationApp\Detailscherm.aspx.cs:89
   IntegrationApp.Detailscherm.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\mta\My Documents\IntegrationApp\IntegrationApp\Detailscherm.aspx.cs:30
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
解决方案

I found another solution to get access to the GROUPS:

PrincipalSearchResult<Principal> groups = user.GetGroups();

这篇关于而试图检索授权组,(5)发生了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 13:14
查看更多