如何将数据库的凭据传递给wcf服务? [英] How to pass credentials for database to wcf service?

查看:194
本文介绍了如何将数据库的凭据传递给wcf服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个连接到oracle数据库的WCF服务。必须使用调用服务的用户的凭据完成与数据库的连接。

We have a WCF service that connects to an oracle database. The connection to the database must be done using the credentials of the user that is calling the service.

如何进行设置,以便我可以访问用户名和密码在客户端的客户端凭证设置,以便我可以添加这些到连接字符串创建时,我想连接到数据库获取服务调用的数据?

How can I set it up so that I can get access to the username and password set in the client credentials at the client so that I can add these to the connections string created when I want to connect to the database to get the data for the service call?

还是有其他方法处理呢?

Or is there some other way that this should be handled?

如果有区别,我们将在oracle数据库中使用代理身份,所以所有用户将作为主用户连接,并且代理标识将被设置为通过的凭证,以确保在代理用户的上下文中执行查询。

If it makes a difference we will be using proxy identity in the oracle database, so all users will connect as a main user and the proxy identity will be set to be the passed credentials to ensure that the queries are executed in the context of the proxy user.

推荐答案

设置您的服务以使用模拟

Setup your service(s) to use Impersonation. This way they will take on the identity of the service client.

设置完成后,您可以像下面这样获得调用者的Windows身份:

Once this is setup, you can get the caller's Windows Identity like this:

WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;

查看这篇博客文章,看看它是否能帮助你。

Check out this blog post and see if it helps you out.

这篇关于如何将数据库的凭据传递给wcf服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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