简体   繁体   English

设置IIS以运行应用程序,并使用用户凭据打开SQL连接

[英]Set IIS to run apps as and open SQL connections with user credentials

For those of you who have been doing this for a while this will be a brisk type of question and answer. 对于已经进行了一段时间的您来说,这将是一种轻快的问答方式。 I just switched to webforms from winforms. 我只是从winforms切换到了webforms。 Currently my ASP apps on IIS server open connections to SQL server using IIS server's credentials. 目前,我在IIS服务器上的ASP应用程序使用IIS服务器的凭据打开与SQL Server的连接。 I added IIS server name to SQL server security so SQL integrated authentication would work well. 我将IIS服务器名称添加到SQL Server安全性中,因此SQL集成身份验证可以很好地工作。 As such all my LinqDataSources work well too. 因此,我所有的LinqDataSources都可以正常工作。 When I use SqlDataSource however, user's credentials are passed to the SQL server. 但是,当我使用SqlDataSource时,用户的凭据将传递到SQL Server。 As long as I access ASP application from computer on the domain with domain user logged in (with SQL premissions) the SqlDataSource works well. 只要我从域上已登录域用户(具有SQL权限)的计算机访问域中的计算机上的ASP应用程序,SqlDataSource就能正常工作。 If I open that same ASP application from a browser that is not on a domain computer with domain user logged in SQL fails authentication. 如果我从不在域计算机上的浏览器中打开了同一个ASP应用程序,并且域用户登录了SQL,则身份验证将失败。 I could provide user's credentials in connection string but SQL server is not set to sa authentication (only integrated authentication) and I don't want to change it now. 我可以在连接字符串中提供用户的凭据,但是SQL Server未设置为sa身份验证(仅集成身份验证),并且我现在不想更改它。 How can I set IIS to authenticate ASP apps as user to SQL or how can I forcefeen into connection string despite Integrated Authentication. 我如何设置IIS来以SQL用户身份验证ASP应用程序,或者尽管集成了身份验证又如何强制进入连接字符串。

your correct with webforms and datasource controls it will use the logged on user if you have intergrated auth enabled, the fact that it works in the same domain as the server and not in another domain, indicates its working ok from a config point of view, perhaps a trust relationship issue, can you access any resource from the other domain, can they connect to the webserver at all outside of your sql ? 如果您启用了集成身份验证,则您对Web窗体和数据源控件的正确使用将使用登录的用户,并且它在与服务器相同的域中工作,而在另一个域中工作,这表明从配置的角度来看它可以正常工作,也许是信任关系问题,您可以从其他域访问任何资源吗,它们可以连接到sql之外的所有Web服务器吗? if so IIS must be working and perhaps the credintials don't have permissions on the SQL server consider using a Stored procedure and setting up a role db_executor and assing that role execute permission on the SP, it's much more secure anyway 如果是这样,则IIS必须正常工作,并且也许该凭证在SQL Server上没有权限,请考虑使用存储过程并设置角色db_executor并在SP上授予该角色执行权限,无论如何它都更加安全。

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

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