【问题标题】:Calling Net Tcp WCF Service from Claims based SharePoint从基于声明的 SharePoint 调用 Net Tcp WCF 服务
【发布时间】:2011-06-03 16:59:08
【问题描述】:

我有一个运行 WCF Net Tcp 绑定服务的 Windows 服务。所有绑定和端点信息都以编程方式设置。

_host.AddServiceEndpoint(typeof(IService), new NetTcpBinding(), serviceName);

在 sharepoint 中,我使用通道工厂访问此服务:

var channelFactory = new ChannelFactory<IService>(
  new NetTcpBinding(),
  new EndpointAddress(new Uri(connectionUrl))
);
 return channelFactory.CreateChannel();

此代码使用 SharePoint 2007 运行良好。现在我们正在将 SharePoint 网站升级到 2010,基于表单的新声明身份不会发送客户端凭据。我收到此错误。

System.IdentityModel.Tokens.SecurityTokenValidationException, System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
The service does not allow you to log on anonymously.

有谁知道如何让 Channel Factory 发送应用程序池的凭据?现在我已经通过使用 RunWithElevatedPrivileges 解决了我的问题,但我并不热衷于这样做,除非我别无选择。

【问题讨论】:

    标签: wcf sharepoint-2010 claims-based-identity claims net-tcp


    【解决方案1】:

    我们使用这种方法解决了它:

    using(WindowsIdentity.Impersonate(IntPtr.Zero))
    {
      var result = channel.ServiceMethod();
    }
    

    在我看来,这比使用 RunWithElevatedPrivileges 不必要地提升 SharePoint 凭据要好。

    【讨论】:

      猜你喜欢
      • 2011-07-15
      • 2011-03-02
      • 2015-03-14
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-16
      • 2013-06-23
      相关资源
      最近更新 更多