简体   繁体   English

在调用WCF的网站上模拟用户

[英]Impersonating a user over a website which calls a WCF

My service is a netTCP webservice and the site that hooks up to it is a windows authenticated Impersonated website. 我的服务是netTCP Web服务,连接到它的站点是Windows身份验证的模拟网站。 When I attempt to hit my service and the service and the site are on the same server, then this work right. 当我尝试访问我的服务并且该服务和站点位于同一台服务器上时,则可以正常使用。 When I attempt to hit the service from my development machine or from an IIS instance running on my local machine it works. 当我尝试从开发计算机或本地计算机上运行的IIS实例访问该服务时,它将起作用。 The only time it doesn't work is when my website is on another server from the website. 唯一不起作用的时间是我的网站位于该网站的另一台服务器上时。 Looking at the output of a WCF utility, we found out that an anonymous user is attempting to hit our service. 查看WCF实用程序的输出,我们发现一个匿名用户正在尝试访问我们的服务。 What is crazy though is that I have the username displayed in the upper right corner of the service. 疯狂的是,我的用户名显示在服务的右上角。

Page.User.Identity.Name

I guess I would like to find out if I am impersonating clients correctly. 我想我想知道我是否正确地模拟了客户。 My suspicion is that It works on those instances because there is not a specific handshake necessary when both application pools run on the local machine. 我猜想它可以在这些实例上运行,因为当两个应用程序池都在本地计算机上运行时,不需要进行特定的握手。 That would again be the case on my local machine (not sure why, but I am thinking that maybe there is some kind of implied security when I go from my logged in machine to a server). 我的本地计算机上也将再次出现这种情况(不知道为什么,但是我认为当我从登录的计算机转到服务器时,可能存在某种隐含的安全性)。 Here is how I impersonate a user... 这是我模拟用户的方式...

    client2.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

I think I have my IIS 7 windows 2008 setup correctly. 我认为我的IIS 7 Windows 2008安装正确。 I have aspnet impersonation enabled for the site in addition to windows authentication enabled for the site. 除了为站点启用了Windows身份验证之外,我还为站点启用了ASPNET模拟。 I have everything but windows authentication disabled for the service. 除了Windows身份验证已禁用该服务之外,我没有其他任何东西。 I have the application pool set to a specific id. 我已将应用程序池设置为特定的ID。 I am not exactly sure what I am missing. 我不确定我想念什么。 I am not yet a master of wcf services so I think I have limited knowledge in this area. 我还不是wcf服务的大师,所以我认为我在这方面的知识有限。 If you guys have any ideas or advice, please let me know. 如果您有任何想法或建议,请告诉我。

So it seems you have the issue below. 所以看来您有下面的问题。 I think this has to do with Machine B not trusting Machine A to pass on its credentials. 我认为这与机器B不信任机器A传递其凭据有关。 This manifests itself in different ways. 这以不同的方式表现出来。

You need to make changes in Active Directory from a constratined to trust Machine A for kerberos credentials delegation by doing the following (more here ) 您需要通过执行以下操作在Active Directory中进行更改,从Active Directory更改为信任机器A以进行kerberos凭证委派(更多信息

  • Click Start, click Administrative Tools, and then click Active Directory Users and Computers. 单击开始,单击管理工具,然后单击“ Active Directory用户和计算机”。
  • Expand domain, and expand the Computers folder. 展开域,然后展开“计算机”文件夹。
  • In the right pane, right-click the computer name for the Web server, select Properties, and then click the Delegation tab. 在右窗格中,右键单击Web服务器的计算机名称,选择“属性”,然后单击“委派”选项卡。
  • Click to select Trust this computer for delegation to any service (Kerberos only). 单击以选中“信任此计算机以委派任何服务(仅Kerberos)”。
  • Click OK. 单击确定。

It seems to me the crux of the issue is that while Machine B accepts the request, it doesn't trust Machine A to pass on the creds. 在我看来,问题的症结在于,当机器B接受请求时,它不信任机器A传递信誉。 This is the classic double hop problem it seems. 这似乎是经典的双跳问题。 This is typical especially when working with SQL server for a machine that is not delegated, you'll see errors like: Login failed for user '(null)'. 这是典型的情况,尤其是在为未委派的计算机使用SQL Server时,您将看到类似以下错误:用户'(null)'登录失败。 Reason: Not associated with a trusted SQL Server connection. 原因:不与受信任的SQL Server连接关联。 Anyhow, SQL isn't your problem here, just showing as an example since I've fought that one before. 无论如何,SQL并不是您的问题,这里只是作为示例,因为我之前已经尝试过。 I'm not up to date on the latest Win2k8 changes, but it may be possible to grant delegation privs at a more granular level as well. 我不是最新的Win2k8更新,但是也可以在更精细的级别上授予委派权限。 Also in the picture below the dashed line I meant to say "Machine B must trust Machine A to pass creds" 同样在虚线下方的图片中,我的意思是“机器B必须信任机器A才能通过信用”

代表团

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM