WCF 服务、Windows 身份验证

发布于 2024-08-03 10:38:42 字数 202 浏览 2 评论 0原文

我们编写了一个WCF服务,部署在IIS上。我们选择集成 Windows 身份验证。在这种情况下无法使用服务,但如果我们可以将 WCF 服务的 IIS 虚拟目录的身份验证方法设置为“匿名”,那么错误就会消失。但我们的 WCF 服务不接受“匿名”。我们必须使用集成 Windows 身份验证来对客户端进行身份验证。有人知道如何解决这个问题吗?

预先感谢,

阿什什

we wrote a WCF service, deployed on IIS. we chose Integrated Windows Authentication. service can not be used in this case but if we can set the authentication method of the IIS virtual directory to "Anonymous" for WCF services, then the error will go away. But "Anonymous" is not acceptable for our WCF service. We have to use Integrated Windows Authentication to authenticate the client. Any one knows how to fix this problem?

Thanks in advance,

Ashish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心房敞 2024-08-10 10:38:42

您必须做一些事情:

  • 取消选中虚拟文件夹的匿名访问并选中集成 Windows 安全性。
  • 创建以下绑定配置:

     ;
     <绑定名称=“Binding1”>
        <安全模式=“TransportCredentialOnly”>
            <传输 clientCredentialType="Windows" />
        
     
     
    
  • 将上述配置应用到您的服务和 mex:

     <端点地址=“”绑定=“basicHttpBinding”绑定配置=“Binding1”契约=“IService”>
    
    
    
       <端点地址=“mex”绑定=“basicHttpBinding”绑定配置=“Binding1”合约=“IMetadataExchange”>
    
    
    • 创建客户端并使用 NetworkCredential 传递您的凭据:

       ServiceReference.MyClient proxy = new ServiceReference.MyClient();
             proxy.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("MACHINENAME\\USERACCOUNT", "passwrd");
             proxy.YourServiceOperation();
      

还有其他方法可以设置用户名和密码。单独的密码,但它在.Net 4.0中不起作用。
USERACCOUNT 是您的 WCF 主计算机加入的域帐户或 LDAP。
如果服务器未加入域,则通过运行“lusrmgr.msc”在本地创建一个帐户

You have to do a few things:

  • Uncheck the anonymous access from your Virtual forlder and check Integrated windows security.
  • Create the following binding configuration:

      <basicHttpBinding>
     <binding name="Binding1">
        <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows"  />
        </security>
     </binding>
     </basicHttpBinding>
    
  • Apply the above configuration to your service and mex:

       <endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="IService">
    </endpoint>
    
    
       <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="IMetadataExchange">
    </endpoint>
    
    • Create a client and use NetworkCredential to pass your credentials:

             ServiceReference.MyClient proxy = new ServiceReference.MyClient();
             proxy.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("MACHINENAME\\USERACCOUNT", "passwrd");
             proxy.YourServiceOperation();
      

There are other ways to set username & password indivdually but it didn't work in .Net 4.0.
USERACCOUNT is a domain account or LDAP to which your WCF host computer is joined to.
If server isnt joined to a domain then create an account locally by running "lusrmgr.msc"

廻憶裏菂餘溫 2024-08-10 10:38:42

您需要注意两个主要事项:

  1. 您的配置是否一致:IIS、web.config(system.web 和 WCF)
  2. 您的客户端是否随请求发送 Windows 身份验证信息

可能是第二个问题给您带来了问题。 IIS 日志应包含正在进行调用的用户。

There are two main things that you need to watch out for:

  1. Is your configuration aligned: IIS, web.config (system.web and WCF)
  2. Is your client sending windows authentication information with the request

It is probably the second that is giving you problems. The IIS log should contain which user is making the call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文