<p>I have an  asp.NET webapplication running in our datacenter in which we want the customer to logon with single sign-on. This would be very easy if we could use the IIS integrated security. However we can't do this. We don't have a trust to the domain controller of the customer. ANd we want to website to be available to the general internet. Only when people are connecting from within the clients network they should automatically login.</p>

<p>What we have is a list of domain accounts and a way to query the DC via LDAP in asp.net code. When anonymous access is allowed in IIS, IIS never challenges the browser for credentials. And thus our application never gets the users credentials.</p>

<p>Is there a way to force the browser into sending the credentials (and thus be able to use single sign-on) with IIS accepting anonymous request.</p>

<p><strong>Update:</strong> </p>

<p>I tried sending 401: unauthorized, www-authenticate: NTLM headers by myself. What happens next (as Fiddler tells me) is that IIS takes complete control and handles the complete chain of request. As I understand from various sources is that IIS takes the username, sends a challenge back to the browser. The browser returns with encrypted reponse and IIS connects to the domain controller to authenticate the user with this response.</p>

<p>However in my scenario IIS is in a different windows domain than the clients and have no way to authenticate the users. For that reason building a seperate site with windows authenticaion enabaled isn't going to work either.</p>

<p>For now I have to options left which I'm researching:</p>

<ol>
<li>Creating a domain trust between our hosting domain and the clients domain (our IT department isn'tto happy with this)</li>
<li>Using a NTML proxy to forward the IIS authentication requests to the clients domain controller (we have a VPN connection available to connect via LDAP) </li>
</ol>

[{'answer_id': 81441, 'author': 'stephbu', 'author_id': 12702, 'author_profile': 'https://Stackoverflow.com/users/12702', 'pm_score': 0, 'selected': False, 'text': "<p>Not sure that you'll easily get this to work.  Unlike basic where the 401 challenge happens in-band of the user request - such that the creds appear in the headers, NTLM handshakes are done on a separate port - then forced onto the thread context by unmanaged code.</p>\n\n<p>You tried pulling apart the ASP.NET NTLM module in VS2008 (or reflector) to see what it does to extract the creds?</p>\n\n<p>Not really an answer - sorry...</p>\n"}, {'answer_id': 84715, 'author': 'Greg', 'author_id': 12601, 'author_profile': 'https://Stackoverflow.com/users/12601', 'pm_score': -1, 'selected': False, 'text': '<p><a href="http://www.pluralsight.com/community/blogs/craig/archive/2006/06/19/28435.aspx" rel="nofollow noreferrer">This solution</a> is about forms authentication, but it details the 401 issue.</p>\n\n<blockquote>\n  <p>The solution was simply to attach a\n  handler to the Application\'s\n  EndRequest event by putting the\n  following in Global.asax:   </p>\n</blockquote>\n\n<pre><code>protected void Application_EndRequest(object sender, EventArgs e) {\n    if (Context.Items["Send401"] != null)\n    {\n         Response.StatusCode = 401;\n         Response.StatusDescription = "Unauthorized";\n    } }\n</code></pre>\n\n<blockquote>\n  <p>Then, in order to trigger this code, all you have to do is put a  </p>\n</blockquote>\n\n<pre><code>Context.Items["Send401"] = true;\n</code></pre>\n\n<p>Edit:<br>\nI\'ve used this method with Anonymous and Integrated turned on to get the user\'s domain credentials.  I\'m not sure if it\'ll work in your situation, but I thought I was worth a shot.</p>\n'}, {'answer_id': 88445, 'author': 'jansokoly', 'author_id': 12111, 'author_profile': 'https://Stackoverflow.com/users/12111', 'pm_score': 2, 'selected': False, 'text': '<p>What you\'re asking for is called mixed mode authentication. I\'ve recently used a <a href="http://www.15seconds.com/issue/050203.htm" rel="nofollow noreferrer">two entry-point mechanism from Paul Glavich</a> and it works perfectly. I guess it\'s the most elegant solution for this problem.</p>\n'}]
['https://Stackoverflow.com/questions/81347', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11548/']