简体   繁体   English

如何使用客户端Windows凭据连接到Web中的SQL Server数据库

[英]How to connect to SQL Server database in web using client windows credentials

Scenario: instead of using the server Windows credentials to connect to database, I want to use the Windows credentials from which the person is accessing website. 场景:我不想使用服务器Windows凭据连接到数据库,而是要使用该人正在从中访问网站的Windows凭据。

  • IIS hosted Server IP: : 10.10.10.10 IIS托管的服务器IP:10.10.10.10
  • Website Accessing from client machine : 10.10.10.11 从客户端计算机访问网站:10.10.10.11

I want to use the credentials from logged in user of 10.10.10.11 for accessing the database. 我想使用10.10.10.11登录用户的凭据访问数据库。

Is there any way to do that? 有什么办法吗? I tried searching in google extensively and failed to get a proper answer. 我尝试在Google中进行广泛搜索,但未能获得正确的答案。 Please let me know how to achieve this or give me a lead so as to get this done. 请让我知道如何实现这一目标,或者给我带头以完成此任务。

If using Windows Authentication, you can simply use Impersonation to make the web worker process' current thread use the client's user credentials 如果使用Windows身份验证,则可以仅使用模拟来使Web Worker进程的当前线程使用客户端的用户凭据

In web.config: 在web.config中:

<configuration>
  <system.web>
    <identity impersonate="true" />
  </system.web>
</configuration>

and make the ado.net connection use the same user by adding this property to the connection string (assuming you use SQL Server or any other DBMS supporting this option) 并将此属性添加到连接字符串中,从而使ado.net连接使用同一用户(假设您使用SQL Server或任何其他支持此选项的DBMS)

Integrated Security=sspi

Change the configuration to 将配置更改为

<configuration>
  <system.web>
    <authentication mode="Windows"/>
    <identity impersonate="true" />
  </system.web>
</configuration>

And Go to IIS Server >> Sites >> Website>> Authentication 并转到IIS服务器>>站点>>网站>>身份验证

Anonymous Authentication >> Disabled
ASP.Net Impersonation    >> Enabled
Basic Authentication     >> Enabled
Forms Authentication     >> Disabled
Windows Authentication   >> Disabled

This will generate a popup for credentials. 这将为凭据生成一个弹出窗口。 When credentials are entered, it will be used to connect to the database. 输入凭据后,它将用于连接数据库。

暂无
暂无

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

相关问题 如何使用Windows身份验证远程连接到SQL Server数据库? - How to connect to SQL Server database using windows authentication remotely? 将基于Windows的应用程序连接到基于Web的数据库SQL Server - Connect Windows-based application to web based database SQL Server 如何使用Windows Phone 8连接到服务器上已托管的SQL Server数据库 - How to connect to a SQL Server database already hosted on server with windows phone 8 Windows应用程序使用公共IP连接到SQL Server数据库 - Windows Application connect using Public IP to SQL Server Database SQL Server重新启动后,C#Windows Service Sql Client无法连接到数据库 - C# Windows Service Sql Client unable to connect to database after SQL Server Restart 远程连接到SQL Server-可信连接,Windows凭据 - Remote connect to SQL server - trusted connection, windows credentials 如何从 Windows 10 UWP 应用程序连接到 SQL 服务器数据库 - How to connect to SQL server database from a Windows 10 UWP app 如何在VS Express 2012 for Web中连接到SQL Server数据库 - How to connect to SQL Server database in VS Express 2012 for Web 网站管理工具:无法连接到 SQL Server 数据库(使用 SQL Server 开发版) - Web Site Administration Tool: Unable to connect to SQL Server database (using SQL Server Development Edition) 如何通过当前的Windows用户凭据连接到Exchange Server? - How connect to Exchange Server via current Windows user credentials?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM