C# 在chlild应用程序中重写/添加标识配置

C# 在chlild应用程序中重写/添加标识配置,c#,web-services,wcf,saml,C#,Web Services,Wcf,Saml,我正在创建一个自定义STS(使用.NET 4.5),它使用issuedTokenAuthentication(SAML 1.0和SAML 2.0)令牌进行身份验证,并发布二进制令牌。 自定义STS是另一个使用WIF的.NET 4.5 web应用程序的子应用程序,父应用程序具有。 这会阻止我在自定义STS中添加,尽管我指定了名称。我在STS启动期间收到错误- Parser Error Message: ID1024: The configuration property value is not

我正在创建一个自定义STS(使用.NET 4.5),它使用issuedTokenAuthentication(SAML 1.0和SAML 2.0)令牌进行身份验证,并发布二进制令牌。 自定义STS是另一个使用WIF的.NET 4.5 web应用程序的子应用程序,父应用程序具有
。 这会阻止我在自定义STS中添加
,尽管我指定了名称。我在STS启动期间收到错误-

Parser Error Message: ID1024: The configuration property value is not valid.
Property name: ''
Error: 'An item with the same key has already been added.'
在没有
的情况下,STS启动,但在WCF
System.ServiceModel tokenValidation
中SAML令牌验证失败,甚至在RST到达自定义STS逻辑之前,错误与
audienceUris
、颁发者、证书验证等有关

以下是web.config文件中的片段-

  <system.identityModel>
    <identityConfiguration name="idConf" >
      <certificateValidation certificateValidationMode="None" />
      <securityTokenHandlers name="STSTokenHandlers" >
        <clear/>
        <securityTokenHandlerConfiguration>
          <certificateValidation certificateValidationMode="None" />
          <audienceUris mode="Never" />
        </securityTokenHandlerConfiguration>
        <remove type="System.IdentityModel.Tokens.Saml2SecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add type="CustomHandler.CustSaml2SecurityTokenHandler, CustomSTS.Business" />
      </securityTokenHandlers>
    </identityConfiguration>
  </system.identityModel>
...
<system.serviceModel>
...
<behavior name="WSTrustServiceBehaviour">
  <serviceCredentials identityConfiguration="idConf" >
    <issuedTokenAuthentication audienceUriMode="Never" certificateValidationMode="None" >
    </issuedTokenAuthentication>
  </serviceCredentials>
  <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
  <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
  <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
  <serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
...
    <services>
      <service behaviorConfiguration="WSTrustServiceBehaviour" name="CustomSecurityTokenService">
        <endpoint name="WSTrust13HttpEndpoint" address="" binding="ws2007FederationHttpBinding" bindingConfiguration="WS2007FedttpBinding" contract="System.ServiceModel.Security.IWSTrust13SyncContract" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
如何在子应用程序中添加
,而不与父应用程序冲突


谢谢

在尝试了多个选项之后,声明多个identityConfiguration的选项似乎仅限于一个应用程序(父应用程序或子应用程序)。如果父web.config在web.config中有,则子应用程序无法清除或覆盖它。
但是,如果父应用程序以编程方式创建identityConfiguration,则子应用程序web.config可以创建自己的identityConfiguration

在尝试了多个选项之后,声明多个identityConfiguration的选项似乎仅限于一个应用程序(父应用程序或子应用程序)。如果父web.config在web.config中有,则子应用程序无法清除或覆盖它。 但是,如果父应用程序以编程方式创建identityConfiguration,则子应用程序web.config可以创建自己的identityConfiguration

ID7012: No <identityConfiguration> element with the name 'idConf' was found in the <system.identityModel> configuration section.