使用WCF服务基本身份验证的用户 [英] Use WCF Service with basic authentication user

查看:168
本文介绍了使用WCF服务基本身份验证的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在研究使用WCF服务从数据库中检索数据pretty标准的网站。

We are working on a pretty standard website that uses a WCF service to retrieve data from a database.

该网站(ASP.Net MVC)有一个服务参考WCF服务
WCF服务具有访问数据库

The Website (ASP.Net MVC) has a Service reference to the WCF Service The WCF Service has access to the database

我们需要启用网站上基本身份验证作为我们的需求的一部分。

We need to enable basic authentication on the site as part of our requirements.

当我们启用它在网站上,并把它留在WCF服务禁用,该网站要求提供凭据,但SQL Server将引发一个错误,指出登录失败的用户NT AUTHORITY \\ IUSR。

When we enable it on the site, and leave it disabled on the WCF service, the site asks for the credentials but the SQL Server throws an error saying that the login failed for the user 'NT AUTHORITY\IUSR'.

如果我们在网站和服务都启用它,当我们试图创建服务的客户实例后执行查询时,它抛出一个异常说不提供的用户名。在ClientCredentials指定的用户名。

If we enable it on both the site and the service, when we try to execute a query after creating a "Client" instance of the service, it throws an exception saying "The username is not provided. Specify username in ClientCredentials.".

我知道我可以只配置为能够访问数据库或硬code在创建服务客户端的凭据特定用户运行服务,但逻辑中的一些存储过程(我们不控制)依靠知道谁正在执行查询。

I know I could just configure the service to run as a particular user that has access to the database or "hard code" the credentials in the creation of the service client, but the logic in some of the stored procedures (that we don't control) rely on knowing who is executing the query.

什么是在这种情况下,最好的办法?有没有一种方法来自动传递用于登录到该网站的WCF服务?

What is the best approach in this case? Is there a way to automatically pass the credentials used to log into the site to the WCF service?

非常感谢!

推荐答案

我认为这又主要取决于托管您正在使用的类型。

I think it again basically depends on hosting type you are using.

这篇关于使用WCF服务基本身份验证的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆