加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 尝试检索授权组时,发生错误(5)

发布时间:2020-12-15 06:51:59 所属栏目:百科 来源:网络整理
导读:如果我在服务器上运行应用程序,而不是在本地运行,我会得到这个错误.为什么这种情况发生在服务器上而不是本地? ListGroupPrincipal result = new ListGroupPrincipal();// establish domain contextPrincipalContext yourDomain = new PrincipalContext(Cont
如果我在服务器上运行应用程序,而不是在本地运行,我会得到这个错误.为什么这种情况发生在服务器上而不是本地?
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();

请帮帮我.

堆栈跟踪:

[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 SettingsmtaMy DocumentsIntegrationAppIntegrationAppApp_Code3-TierDALActiveDir.cs:54
   IntegrationApp.App_Code._3_Tier.BAL.DatabaseBAL.BepaalDefaultNiveau2(String melder) in C:Documents and SettingsmtaMy DocumentsIntegrationAppIntegrationAppApp_Code3-TierBALDatabaseBAL.cs:75
   IntegrationApp.Detailscherm.VulLijsten() in C:Documents and SettingsmtaMy DocumentsIntegrationAppIntegrationAppDetailscherm.aspx.cs:89
   IntegrationApp.Detailscherm.Page_Load(Object sender,EventArgs e) in C:Documents and SettingsmtaMy DocumentsIntegrationAppIntegrationAppDetailscherm.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

解决方法

我找到另一个解决方案来访问GROUPS:
PrincipalSearchResult<Principal> groups = user.GetGroups();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读