代码之家  ›  专栏  ›  技术社区  ›  DevX

无法解析目标主体的SID。

  •  0
  • DevX  · 技术社区  · 7 年前

    我在windows server 2016上delpoyed了我的web应用程序(使用LDAP)。它正在抛出以下错误。尽管我可以使用ADSI或C#控制台应用程序(创建实用程序以测试连接)访问相同的ADLDS实例。但不知道为什么web应用程序会抛出错误。请提出建议。

    Server Error in '/' Application.
    
    **While trying to resolve a cross-store reference, the SID of the target principal could not be resolved.  The error code is 1722.**
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.DirectoryServices.AccountManagement.PrincipalOperationException: While trying to resolve a cross-store reference, the SID of the target principal could not be resolved.  The error code is 1722.
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace: 
    
    [PrincipalOperationException: While trying to resolve a cross-store reference, the SID of the target principal could not be resolved.  The error code is 1722.]
       System.DirectoryServices.AccountManagement.ADStoreCtx.ResolveCrossStoreRefToPrincipal(Object o) +570
       System.DirectoryServices.AccountManagement.ADUtils.DirectoryEntryAsPrincipal(DirectoryEntry de, ADStoreCtx storeCtx) +133
       System.DirectoryServices.AccountManagement.ADDNLinkedAttrSet.get_CurrentAsPrincipal() +86
       System.DirectoryServices.AccountManagement.PrincipalCollectionEnumerator.MoveNext() +252
       System.DirectoryServices.AccountManagement.PrincipalCollectionEnumerator.System.Collections.IEnumerator.MoveNext() +9
       System.Linq.<SelectManyIterator>d__22`3.MoveNext() +65
       System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +264
       System.Linq.GroupedEnumerable`3.GetEnumerator() +72
       System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +63
       System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) +392
       System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection) +15
       Plastin.Common.Security.ADLDSClaimsProvider.SetApplicationClaims() +1012
       Plastin.Common.Security.ADLDSClaimsProvider.Initialise() +174
       Plastin.Common.Security.ADLDSClaimsProvider..cctor() +238
    
    [TypeInitializationException: The type initializer for 'Plastin.Common.Security.ADLDSClaimsProvider' threw an exception.]
       lambda_method(Closure , IBuilderContext ) +81
       Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +35
       Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +10
       Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +198
       Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +209
       Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +165
    
    [ResolutionFailedException: Resolution of the dependency failed, type = "Plastin.Common.Security.IClaimsProvider", name = "(none)".
    Exception occurred while: Calling constructor Plastin.Common.Security.ADLDSClaimsProvider().
    Exception is: TypeInitializationException - The type initializer for 'Plastin.Common.Security.ADLDSClaimsProvider' threw an exception.
    -----------------------------------------------
    At the time of the exception, the container was:
    
      Resolving Plastin.Common.Security.ADLDSClaimsProvider,(none) (mapped from Plastin.Common.Security.IClaimsProvider, (none))
      Calling constructor Plastin.Common.Security.ADLDSClaimsProvider()
    ]
       Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +329
       Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides) +15
       Microsoft.Practices.Unity.UnityContainerExtensions.Resolve(IUnityContainer container, ResolverOverride[] overrides) +72
       Plastin.Common.Security.AuthenticationManager.Authenticate(String resourceName, ClaimsPrincipal incomingPrincipal) +149
       Plastin.Portal.MvcApplication.Application_PostAuthenticateRequest() +70
    
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
       System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +87
       System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
       System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +21
       System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +56
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   DevX    7 年前

    最后,我们解决了这个问题,很抱歉,我来不及回答这个问题。经过大量调试,我们发现web应用程序在获取ADLDS组成员时抛出了此错误。这是不寻常的,因为同一个应用程序正在其他服务器上工作。因此,我们决定使用Wireshark捕获网络流量。Wireshark捕获表明LDAP服务器和应用程序服务器之间的连接在SMB端口445上被阻止。所以我们让我们的网络团队打开445端口,解决了这个问题。

    此错误似乎是非常常见的错误,可能是您场景中出现此错误的其他原因,但在调查的早期阶段使用网络流量捕获工具(如wireshark)可能有助于您快速解决此类问题。