How do I configure IIS so that the user's domain credentials are used when connecting to SQL server?

怎甘沉沦 提交于 2019-11-30 20:12:32

This is called the Double-Hop Problem and prohibits the forwarding of user's credentials to third parties. This occurs when they browse from one machine, against a site on another (first hop), and forwarding the credentials to a third machine (second hop).

The problem will not appear if you host IIS and SQL Server on the same machine.

There's alot more technical details published on this at How to use the System.DirectoryServices namespace in ASP.NET, which explains the double-hop issue, and primary and secondary tokens.

To run your application under the user's Active Directory or Windows credentials, ensure these:

  • the IIS application is set to NOT allow anonymous access
  • the IIS application uses Integrated Windows authentication
  • your connection string should have Integrated Security=SSPI to ensure the user's Windows/AD credentials are passed to SQL Server.

    i.e. Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

You state you're not sure "how to go about investigating if it's set up or how to go about setting it up".

For this I'd heartily recommend a tool called DelegConfig. It's a very handy app that you can tell you if kerberos is setup properly.

Unzip it into a directory, configure a virtual directory in IIS to point to it. Browse to the main page and you tell it which backend server you want to allow access to (e.g. UNC, SQL, HTTP etc..) and it tell you its setup correctly or not and explain why.

It even has the abilty to recongiure the kerberos to fix the issue if you so desire (although I've not used this - I'd rather reconfiguire it myself to understand what I've done in future)

I realise this comes too late for your particular problem but thought it worth sharing for others that follow - especially the tools ability to explain why delegation is or is not working. I've found it invaluble.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!