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

WCF windows身份验证安全错误

  •  7
  • Tom  · 技术社区  · 16 年前

    WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;
    using (callerWindowsIdentity.Impersonate())
    {
        NetTcpBinding binding = new NetTcpBinding();
        binding.Security.Mode = SecurityMode.Message;
        binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
        EndpointAddress endpoint = new EndpointAddress(new Uri("net.tcp://serverName:9990/TestService1"));
        ChannelFactory<WCFTest.ConsoleHost.IService1> channel = new ChannelFactory<WCFTest.ConsoleHost.IService1>(binding, endpoint);
        WCFTest.ConsoleHost.IService1 service = channel.CreateChannel();
        return service.PrintMessage(msg);
    }
    

    知道为什么吗?

    4 回复  |  直到 16 年前
        1
  •  3
  •   John Saunders    16 年前

    为了支持您的场景,您需要了解如何 Protocol Transition Constrained Delegation 工作。您需要配置Active Directory和WCF服务端点以支持此功能。请注意服务主体名称(SPN)的使用。请查看以下链接,看看它们是否对您有所帮助。本文有一个示例来演示实现此功能所需的完整端到端配置。

    How To: Impersonate the Original Caller in WCF Calling from a Web Application

        2
  •  1
  •   kenny    16 年前

    同意marc_s的观点,这就是双跳问题。

    • 必须允许您的应用程序池所运行的用户模拟用户。这是发生双跳问题的常见地方。

    有一种权利叫做“身份验证后冒充客户端”

    http://blogs.technet.com/askperf/archive/2007/10/16/wmi-troubleshooting-impersonation-rights.aspx

        3
  •  0
  •   marc_s MisterSmith    16 年前

    我对此没有最终答案(我通常通过为需要调用另一个服务的服务使用显式服务帐户来避免这种情况)。

    WCF Security Guidance

        4
  •  0
  •   Daniel Auger    16 年前

    可以

    DnsEndpointIdentity identity = new DnsEndpointIdentity("localhost"); // localhost is default. Change if your service uses a different value in the service's config.
    Uri uri = new Uri("net.tcp://serverName:9990/TestService1");
    endpoint = new EndpointAddress(uri, identity, new AddressHeaderCollection());