<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Authentication and Authorization</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/autz_auth_stuff/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/feed.xml</link>
    <description>This blog is about Authentication and authorization, in particular Kerberos on IIS 7.0 and later.</description>
    <lastBuildDate>Mon, 20 Jul 2015 19:09:16 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How to name a SPN (part 2)</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/how-to-name-a-spn-part-2</link>
      <pubDate>Fri, 03 Jun 2011 03:39:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/06/03/how-to-name-a-spn-part-2/</guid>
      <description><![CDATA[As you learned last time, the full syntax of SPN name is:
service class/host[:port[/service...]]></description>
      <content:encoded><![CDATA[<p>As you learned last time, the full syntax of SPN name is:</p>
<p><span style="color: #0000ff;">service class/host</span>[:<span style="color: #ff0000;">port</span>[/<span style="color: #0000ff;">service name</span>]]</p>
<p>Today I will be talking about port. Port number is an optional qualifier that you can use to ensure that the SPN is unique in the forest.</p>
<p>The default port number for a http request is 80 (and 443 for https). If you are using the default port number for you application, then you don't need to add the port number when you are registering SPN because Internet Explorer knows that the port number should be ignored when requesting a Kerberos ticket.</p>
<p>On the other hand, if you are using a different port number, e.g. 82, then everything becomes a bit trickier.</p>
<p>Let us for a moment ignore the fact that there is really no need for a special port on the HRWeb application because Internet Information Server can use host name in the binding and allow many applications to use port 80 side by side. Instead, let us assume that we are listening on port 82 and that we have registered the following two SPN's for the application (both are pointing to the correct domain account for the application pool and the web site is configured to not use Kernel mode authentication).</p>
<p style="padding-left: 30px;">http/hrweb:82<br />http/hrweb.mydomain.com:82</p>
<p>Next the user&nbsp;(Joe) is opening&nbsp;Internet Explorer on a domain joined Windows client to view his current salary.&nbsp;</p>
<p>Sorry, but&nbsp;that doesn't work. At least not out of the box.</p>
<p>If you try, you will see the following error in the Failed RequestTracing on IIS:</p>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<th style="text-align: left;">ModuleName</th>
<td class="event" style="text-align: left;">ManagedPipelineHandler</td>
</tr>
<tr class="alt">
<th style="text-align: left;">Notification</th>
<td class="event" style="text-align: left;">128</td>
</tr>
<tr>
<th style="text-align: left;">HttpStatus</th>
<td class="event" style="text-align: left;">500</td>
</tr>
<tr class="alt">
<th style="text-align: left;">HttpReason</th>
<td class="event" style="text-align: left;">Internal Server Error</td>
</tr>
<tr>
<th style="text-align: left;">HttpSubStatus</th>
<td class="event" style="text-align: left;">0</td>
</tr>
<tr class="alt">
<th style="text-align: left;">ErrorCode</th>
<td class="event" style="text-align: left;">0</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The reason is that the default configuration for Internet Explorer does not include the port number when it is requesting a Kerberos ticket.</p>
<p>There is several ways to solve this, but you need to select the option that works best for you:</p>
<ul>
<li>Register the SPN <span style="text-decoration: underline;">without </span>port number.&nbsp;<span style="text-decoration: underline;">Share </span>application pool account.&nbsp; Example: 
<ul>
<li>HRweb:82 is assigned application pool A (using mydomain\hrwebact as application pool identity)</li>
<li>HRweb:83 is assigned application pool B (also using mydomain\hrwebact as application pool identity)</li>
</ul>
</li>
<li>Use a load-balancer that translate hostname into port number.&nbsp;Use a <span style="text-decoration: underline;">dedicated hostname</span>&nbsp;for each application.&nbsp;Register the SPN <span style="text-decoration: underline;">without</span> port number. Example: 
<ul>
<li>HRweb:80 is translated by the load-balancer to *:82 on the web server (replace * with the actual IP address)</li>
<li>Training:80 is translated by the load-balancer to *:83 on the web server (replace * with the actual IP address)</li>
</ul>
</li>
<li><span style="text-decoration: underline;">Configure the Internet Explorer</span> to use port number when requesting a Kerberos ticket</li>
</ul>
<p>The last option is described in kb 908209&nbsp; (does also apply to IE8 and IE9)&nbsp;as a registry key. You need to think twice before doing this because it is an all-or-nothing change, you cannot specify that this change does only apply to some applications.</p>]]></content:encoded>
    </item>
    <item>
      <title>How to name a SPN</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/how-to-name-a-spn</link>
      <pubDate>Sun, 22 May 2011 01:55:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/05/22/how-to-name-a-spn/</guid>
      <description><![CDATA[As previously stated, a SPN is a kind of alias for a domain account. You can have many SPN for a...]]></description>
      <content:encoded><![CDATA[<p>As previously stated, a SPN is a kind of alias for a domain account. You can have many SPN for a single domain account, but the SPN must be unique in the forest.</p>
<p>The name consists of two mandatory parts (<span style="color: #ff0000;">service class </span>and <span style="color: #ff0000;">host</span>) and two optional parts (<span style="color: #0000ff;">port </span>and <span style="color: #0000ff;">service name</span>).</p>
<p>The full syntax is:</p>
<p style="padding-left: 30px;"><span style="color: #ff0000;">service class</span>/<span style="color: #ff0000;">host</span>[:<span style="color: #0000ff;">port</span>[/<span style="color: #0000ff;">service name</span>]]</p>
<p>Today I will&nbsp; be talking about service class and host.</p>
<p><span style="color: #ff0000;"><strong>Host </strong></span>name is reasonable obviously: it is the host name that the <span style="text-decoration: underline;">client </span>is using when accessing the service.</p>
<p>In the&nbsp;simples form, host name is the name of the server, e.g.</p>
<ul>
<li>MYSERVER</li>
<li>MYSERVER.MYDOMAIN.COM</li>
</ul>
<p>While servername appears to be an attractive choice, it has a&nbsp;major disadvantage when it comes to the scalability (or high-availability) of your application: you can only host the application on a single server.</p>
<p>Scaling the application to multiple servers can be achieved in many ways, e.g. using DNS Round robin, a hardware load balancer or using Network Load Balancing (NLB). In all cases the client is resolving a hostname to an IP-address and is then initiating a conversation with that IP address. The client does not know what server it is connected to - it could be a server with more than one IP-address or it could be a random server in a huge web farm with many hundreds servers. In all case you need a virtual hostname that is shared between all the servers. </p>
<p>The name resolution from the virtual hostname to IP-address is managed by the DNS server where you can make either an A-record (one or more fixed IP-addresses) or a CNAME (an alias for a hostname). If possible you should always use an A-record, as some applications (e.g. older Internet Explorer versions) does not like the combination of Kerberos and CNAME.</p>
<p>To prepare for scalability in the future where the demand of the HRWEB application exceeds one server you&nbsp;must therefore register (in DNS) an A-record for the HRWEB application</p>
<ul>
<li>HRWEB.MYDOMAIN.COM</li>
</ul>
<p>and tell the users to access the application using the url&nbsp;<a href="https://hrweb">https://hrweb</a>. </p>
<p>It is recommended to register the SPN for both the NetBIOS name of the server&nbsp;(HRWEB) and the&nbsp; Fully Qualified Domain Name (FQDN) of the server (HRWEB.MYDOMAIN.COM) to ensure that the client can get a ticket no matter what syntax the client is using.</p>
<p><strong><span style="color: #ff0000;">Service class</span></strong> is&nbsp;trickier to understand.</p>
<p>If you search for SPN registration you may find many examples where the service class is HTTP, but in reality the service class is just a random name that you chose when you are designing your client/server application.&nbsp;</p>
<p>If your client is a web browser, then the developer of the web browser&nbsp;made that choice for you, and yes - in that case the service class it is always&nbsp;<strong>HTTP</strong>.</p>
<p>Other well-known samples is <strong>MSSQLSvc&nbsp;</strong>that is used by SQL Server and <strong>HOST </strong>that is a common service class used by many Windows services like File and Print.</p>
<p>For solutions where you are writing both the client and server applications (e.g. using WCF)&nbsp;you will have more freedom to choose the Service class name. The only limitation is that you must ensure that the combination of service class and hostname is unique in the Active Directory forest.</p>
<p>I will come back to service class in a future post about <span style="text-decoration: underline;">constrained </span>delegation.</p>]]></content:encoded>
    </item>
    <item>
      <title>System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITYANONYMOUS LOGIN'</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/system-data-sqlclient-sqlexception-login-failed-for-user-nt-authorityanonymous-login</link>
      <pubDate>Tue, 17 May 2011 04:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/05/17/system-data-sqlclient-sqlexception-login-failed-for-user-nt-authorityanonymous-login/</guid>
      <description><![CDATA[Depending on how you installed SQL Server you may receve an SqlException -2146232060 when you are...]]></description>
      <content:encoded><![CDATA[<p>Depending on how you installed SQL Server you may receve an SqlException -2146232060 when you are connecting to SQL Server from the web server using the credentials of the end user.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/7607.SqlException.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/7607.SqlException.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/7607.SqlException.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/7607.SqlException.PNG" border="0" /></a></p>
<p>One probably&nbsp;reason could be an error in the SPN&nbsp;registration.</p>
<p>During installation of SQL Server you need to decide what service account you are going to use for the SQL Server service. If you are using one of the built-in accounts (Local System, Local Service, Network Service) then the SQL Server service is able to maintain the SPN registration on your behalf because the SPN is registred on the computer account.</p>
<p>If you are using a service account (e.g. MYDOMAIN\SqlUser) for the SQL Server service, then the SPN must be registered on that account. If the SQL Server is installed by the domain administrator, then the installation will make that registration for you. But if you are installing the SQL Server as a local administrator on the Windows Server, then SPN registration may not work.</p>
<p>Start SQL Server Configuration manager to view the account name used for MSSQLSERVER:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/5123.SqlServerConfigManager.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/5123.SqlServerConfigManager.PNG"><img height="274" width="374" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/5123.SqlServerConfigManager.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/5123.SqlServerConfigManager.PNG" border="0" /></a></p>
<p>Next check if there is registrered a SPN for that account. You can use either of the following two tools:</p>
<ul>
<li>Command line tool: SetSPN.exe mydomain\sqluser</li>
<li>ADSI Edit: Open ADSIEdit.msc, connect to the domain, navigate to the&nbsp;account in Active Directory, view properties, select the servicePrincipalName attribute</li>
</ul>
<p>In both cases you should find the following 3 registered SPN</p>
<p>MSSQLSvc/MYSQLSERVER<br />MSSQLSvc/MYSQLSERVER.mydomain.com<br />MSSQLSvc/MYSQLSERVER.mydomain.com:1433</p>
<p>Replace servername (MYSQLSERVER) and domain name (mydomain.com) with your own value.</p>
<p>Pay attention to not having duplicate SPN - you can check with setspn.exe -X. If the SPN is registered on the computer account and the SQL Server service is executed in the context of a user account, then remove the SPN on the computer account before you are registering on the user account. You may need to restart both web server and SQL server after changing the registration.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>WindowsImpersonationContext</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/windowsimpersonationcontext</link>
      <pubDate>Sat, 14 May 2011 07:39:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/05/14/windowsimpersonationcontext/</guid>
      <description><![CDATA[Connecting to a database on a remote SQL Server with the end-user credentials requires that you are...]]></description>
      <content:encoded><![CDATA[<p>Connecting to a database on a remote SQL Server with the end-user credentials requires that you are impersonating the user in code.</p>
<p>Start by ensuring that your web.config does <span style="text-decoration: underline;">not&nbsp;</span>include impersonation:</p>
<p><span style="color: #993300;"><span style="color: #3366ff;">&lt;</span>system.web<span style="color: #3366ff;">&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&nbsp;&nbsp; &lt;</span>authentication <span style="color: #ff0000;">mode</span>=<span style="color: #3366ff;">"Windows"/&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&nbsp;&nbsp; &lt;</span>identity <span style="color: #ff0000;">impersonate</span>=<span style="background-color: #ffffff; color: #3366ff;">"</span><span style="color: #3366ff;"><span style="background-color: #ffffff;">false"</span>/&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&lt;/</span>system.web<span style="color: #3366ff;">&gt;</span></span></p>
<p>Next modify the section of your code where you are accessing ressources on behalf of the end-user.</p>
<p>The concept to the solution is described <a href="https://msdn.microsoft.com/en-us/library/ms998351.aspx" title="here">here&nbsp;</a>but to make the sample&nbsp;more&nbsp;relevant for the described scenario I have extended the sample with a few more lines of code:</p>
<p style="padding-left: 30px;"><span style="color: #33cccc;"><span style="color: #33cccc;">String <span style="color: #000000;">connectionString = <span style="color: #33cccc;">WebConfigurationManager</span>.ConnectionStrings[<span style="color: #ff0000;">"HrWeb"</span>].ConnectionString;<br /></span></span></span><span style="color: #33cccc;">WindowsIdentity </span>wi =&nbsp; (<span style="color: #33cccc;">WindowsIdentity</span>)<span style="color: #33cccc;">HttpContext</span>.Current.User.Identity;<br /><span style="color: #33cccc;">WindowsImpersonationContext </span>ctx = null;<br /><span style="color: #3366ff;">using </span>(<span style="color: #33cccc;">SqlConnection </span>connection = <span style="color: #3366ff;">new </span><span style="color: #33cccc;">SqlConnection</span>(connectionString))<br />{<br />&nbsp;&nbsp; <span style="color: #3366ff;">try</span><br /><span style="color: #3366ff;">&nbsp;&nbsp; </span>{<br />&nbsp;&nbsp;&nbsp;&nbsp; ctx = wi.Impersonate();<br />&nbsp;&nbsp;&nbsp;&nbsp; connection.Open();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #339966;">// use the connection to&nbsp;the database on behalf of the end-user</span><br /><br />&nbsp;&nbsp;&nbsp;&nbsp; connection.Close();<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <span style="color: #3366ff;">finally</span><br /><span style="color: #3366ff;">&nbsp;&nbsp;&nbsp; </span>{<br />&nbsp;&nbsp;&nbsp;&nbsp; ctx.Undo();<br />&nbsp;&nbsp;&nbsp;&nbsp; ctx.Dispose();<br />&nbsp;&nbsp;&nbsp;&nbsp; ctx = <span style="color: #3366ff;">null</span>;<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>(Make sure that you are completing the errorhandling before going into production with this code.)</p>
<p>To make the solution as secure as possible you should seek to limit the scope where you impersonating the end-user, and you should also ensure that any input from the end-user is properly validated to avoid SQL Injection.</p>]]></content:encoded>
    </item>
    <item>
      <title>Impersonation</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/impersonation</link>
      <pubDate>Fri, 06 May 2011 04:23:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/05/06/impersonation/</guid>
      <description><![CDATA[The next hurdle to solve is to connect to the database with the correct user.
Without doing...]]></description>
      <content:encoded><![CDATA[<p>The next hurdle to solve is to connect to the database with the correct user.</p>
<p>Without doing anything, your connection will be made by the application pool account - in&nbsp;the described&nbsp;scenario that would be the&nbsp;<strong>mydomain\hrwebact</strong> account.</p>
<p>That was not what&nbsp;you wanted. The business requirement were that "<em>all authorization should be managed on the SQL Server"</em>, and that would require that the connection to SQL Server is made with the end-user credentials.</p>
<p>To fix this,&nbsp;you need to ensure that the application is <em>impersonating </em>the end-user when the connection to the&nbsp;SQL Server&nbsp;is made. </p>
<p>If you search for "ASP.NET" and&nbsp;"impersonation" in your favorite search engine, then it is likely that you would find guidance on how to enable ASP.NET impersonation in this way:</p>
<p><span style="color: #993300;"><span style="color: #3366ff;">&lt;</span>system.web<span style="color: #3366ff;">&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&nbsp; &lt;</span>authentication <span style="color: #ff0000;">mode</span>=<span style="color: #3366ff;">"Windows"/&gt;</span></span><br /><span style="color: #993300;">&nbsp; <span style="color: #3366ff;">&lt;</span>identity <span style="color: #ff0000;">impersonate</span>=<span style="background-color: #ffffff; color: #3366ff;">"</span><span style="color: #3366ff;"><span style="background-color: #ffffff;">true"</span>/&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&lt;/</span>system.web<span style="color: #3366ff;">&gt;</span></span></p>
<p>Before going into explaining why this is not the correct answere, just be warned that this will not work in IIS 7.0 or IIS 7.5 where you you will get&nbsp;a HTTP Error 500.24:</p>
<p style="padding-left: 30px;">ModuleName ConfigurationValidationModule <br />Notification 1 <br />HttpStatus 500 <br />HttpReason Internal Server Error <br />HttpSubStatus 24 <br />ErrorCode 2147942450 <br />ConfigExceptionInfo&nbsp; <br />Notification BEGIN_REQUEST <br />ErrorCode The request is not supported. (0x80070032) </p>
<p><br />You can solve this in two ways, either&nbsp;by adding the following parameter to the web.config:</p>
<p><samp><span style="color: #993300;"><span style="color: #3366ff;">&lt;</span>system.webServer<span style="color: #3366ff;">&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&nbsp;&nbsp; &lt;<span style="color: #993300;">validation</span></span> <span style="color: #ff0000;">validateIntegratedModeConfiguration</span>=<span style="color: #3366ff;">"<span style="background-color: #ffffff;">false</span>"/&gt;</span></span><br /><span style="color: #993300;"><span style="color: #3366ff;">&lt;/</span>system.weSserver<span style="color: #3366ff;">&gt;</span></span></samp></p>
<p><samp></samp></p>
<p>or by changing the application pool to use the "Clasic"&nbsp;Managed Pipeline&nbsp;Mode.</p>
<p>Howerver, the answer is still not correct. ASP.NET impersonation will only allow your application to access ressources locally on the web server in the context of the end-user. This could be a local instance of a SQL Server or it could be the file system. If the ressource is located on a different server - and we must assume that this is the case,&nbsp;otherwise we had no reason to enable delegation - then the database connection will still&nbsp;be made in the context of the application pool account.</p>
<p>We need to do something else. That is the topic for the next blog post.</p>]]></content:encoded>
    </item>
    <item>
      <title>Kernel-mode authentication</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/kernel-mode-authentication</link>
      <pubDate>Fri, 06 May 2011 01:37:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/05/06/kernel-mode-authentication/</guid>
      <description><![CDATA[First a short explanaition on how the Kerberos ticket is encrypted:

The client application (e.g....]]></description>
      <content:encoded><![CDATA[<p>First a short explanaition on how the Kerberos ticket is encrypted:</p>
<ul>
<li>The client application (e.g. a web browser) is requesting a Kerberos ticket from the Domain Controller (KDC). As part of the communication with the DC, the client is sending the SPN for the service</li>
<li>The DC find the domain account that matches the SPN, and create a ticket for the user.</li>
<li>The ticket&nbsp;is encrypted with the password for the domain account of the <span style="text-decoration: underline;">receiving</span> application.&nbsp;(To be more accurate: encrypted with the <span style="text-decoration: underline;">hash</span> of the password for the domain account).</li>
<li>The encrypted ticket is then sendt back to the client</li>
<li>The client is sending the ticket to the web application in&nbsp;the authentication header&nbsp;to prove the&nbsp;identity of the user</li>
<li>IIS is decrypting the ticket to get the identity of the user</li>
</ul>
<p>To decrypt the ticket, the IIS must know to the password of the domain account. The password is stored (encrypted) in the applicationHost.config, e.g.</p>
<p style="padding-left: 30px;">&lt;applicationPools&gt;<br />&nbsp;&nbsp; &lt;add name="HRWeb"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp; &lt;processModel identityType="SpecificUser" userName="mydomain\hrwebact" password="[enc:IISWASOnlyAesProvider:qu/80DmhQaUFn4DnDWsFF/uVty+WVR8WapGLJ77clKE=:enc]" /&gt;<br />&nbsp; &lt;/add&gt;<br />&lt;/applicationPools&gt;</p>
<p>That should therefore not be a problem. But&nbsp;a change were made in IIS 7.0 (and later) that in some cases breaks the Kerberos configuration when the IIS is trying to decrypt the ticket using the&nbsp;password of the computer account.&nbsp;Read here for more info: <a href="https://blogs.msdn.com/b/sudeepg/archive/2009/02/08/iis-7-kernel-mode-authentication.aspx">https://blogs.msdn.com/b/sudeepg/archive/2009/02/08/iis-7-kernel-mode-authentication.aspx</a></p>
<p>In our HRWeb application&nbsp;the application pool account is configured to use a domain account as identity with a matching&nbsp;SPN.</p>
<p>When a user is visiting the page he will be prompted for username and password, but even if he enters the corect credentials, the request will still fail with HTTP Error 401: Not Authorized. </p>
<p>A Failed Request Tracing log will show the following error:</p>
<p style="padding-left: 30px;">ModuleName IIS Web Core <br />Notification 2 <br />HttpStatus 401 <br />HttpReason Unauthorized <br />HttpSubStatus 2 <br />ErrorCode 2147942405 <br />ConfigExceptionInfo&nbsp; <br />Notification AUTHENTICATE_REQUEST <br />ErrorCode Access is denied. (0x80070005)</p>
<p>To make this work in IIS 7.5 you have two choices:</p>
<ol>
<li>Disable Kernel-mode authentication for this application, or</li>
<li>Configure&nbsp;IIS to use the application pool account when the the ticket is decrypted in Kernel mode</li>
</ol>
<p>You can easily disable Kernel-mode autentication in the GUI. Select the application in the IIS Manger, open the authentication feature, select Windows authentication, select Advanced Settings in the right panel, and uncheck Kernel-mode authentication:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/1145.KernelMode.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/1145.KernelMode.JPG"><img height="329" width="429" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/1145.KernelMode.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/1145.KernelMode.JPG" border="0" /></a></p>
<p>While this configuration will fix the issue, it may not be the best option. A better approach would be to keep Kernel-mode autentication but tell IIS to use the password of the application pool account to decrypt the ticket.</p>
<p>I wish that there were a GUI for changing that parameter but it does not exist.</p>
<p>Instead you have to tweak the applicationHost.config file that usually is located in c:\windows\system32\inetsrv\config, and you need to add the attribute: <strong>useAppPoolCredentials="true"</strong> to the windowsAuthentication node of the configuration for the application.</p>
<p>See sample:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/5736.useAppPoolCredentials.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/5736.useAppPoolCredentials.PNG"><img height="225" width="620" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/5736.useAppPoolCredentials.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/5736.useAppPoolCredentials.PNG" border="0" /></a></p>
<p>&nbsp;You can also use the Appcmd.exe command tool to set this parameter instead of tweaking the xml by hand.&nbsp;I have used the following command line a couple of time where the customer wanted this parameter to be default for&nbsp;<span style="text-decoration: underline;">all </span>applications on the server::</p>
<p style="padding-left: 30px;">%windir%\system32\inetsrv\appcmd.exe set config -section:windowsAuthentication /useAppPoolCredentials:"True" /commit:apphost</p>
<p>It should also be possible to&nbsp;do the&nbsp;a change for a single application, but I don't have a working sample to show you.</p>]]></content:encoded>
    </item>
    <item>
      <title>Kerberos Delegation</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/kerberos-delegation</link>
      <pubDate>Tue, 03 May 2011 01:26:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/05/03/kerberos-delegation/</guid>
      <description><![CDATA[Kerberos Delegation is a feature that allows an application to reuse the end-user credentials to...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">Kerberos Delegation is a feature that allows an application to reuse the end-user credentials to access recourses hosted on a different server. You should only allow that if you really trust the application server, otherwise the application may use your credentials to purposes that you didn't think of, like sending e-mails on your behalf or changing data in a mission critical application&nbsp;pretending that <strong><span style="font-family: 'Arial','sans-serif';">you </span></strong>made that change.<o:p></o:p></span></p>
<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">For that reason, delegation is not enabled by default in Active Directory. You - or more likely the domain administrator - must explicit make the decision that this particular application is trusted for delegation. This is also a <span style="text-decoration: underline;"><span>partial </span></span>answer to the quiz in the previous post: <strong><span style="font-family: 'Arial','sans-serif';">no</span></strong>, the list of task was not sufficient to satisfy the business requirements because the list did not include any task related to Kerberos delegation.<o:p></o:p></span></p>
<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">The Kerberos Delegation is configured as a property for the <span style="text-decoration: underline;"><span>domain account </span></span>that is used by the application as a service account. For an IIS application that is the application pool account configured for that particular application. That is the also the <span style="text-decoration: underline;"><span>same </span></span>domain account that you used when you configured the SPN.<o:p></o:p></span></p>
<p>Kerberos Delegation comes in different flavors. The first implementation of Kerberos delegation that was introduced in Windows 2000 was an all or nothing implementation: you allowed that the domain account could use your credentials to connect to any server in the world. (Or more exactly at least any server that were reachable in the <a href="https://technet.microsoft.com/en-us/library/cc772808(WS.10).aspx" title="current Domain, the current Forrest or any domain in any forest&amp;nbsp;with a forest trust">current Domain, the current Forrest or any domain in any forest&nbsp;with a forest trust</a>).</p>
<p>When you are configuring Active Directory in Windows Server 2003, the default <a href="https://technet.microsoft.com/en-us/library/cc787290(WS.10).aspx" title="Domain Functional Level">Domain Functional Level</a> <span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">is Windows 2000 mixed mode. In that mode, the configuration of delegation is different for a computer account (Local System) compared to a user account.<o:p></o:p></span></p>
<p>To configure the delegation for a Local System account, put a check mark in "Trust computer for delegation" on the General tab page.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/3566.ComputerProperties.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/3566.ComputerProperties.JPG"><img height="515" width="452" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/3566.ComputerProperties.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/3566.ComputerProperties.JPG" border="0" /></a></p>
<p>For user account, you must put a checkmark on the "Account is trusted for delegation" option on the Account tab for the account.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/6433.UserProperties.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/6433.UserProperties.JPG"><img height="608" width="460" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/6433.UserProperties.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/6433.UserProperties.JPG" border="0" /></a></p>
<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">If you have raised the Domain Functional level to Windows Server 2003, the Delegation property is moved for both computer accounts and user accounts to a dedicated tab page "Delegation" and you are also giving more options to control the scope of the delegation. I will come back to constrained delegation in a future post.<o:p></o:p></span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/3021.UserProperties2.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/3021.UserProperties2.JPG"><img height="598" width="461" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/44/94/3021.UserProperties2.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-44-94/3021.UserProperties2.JPG" border="0" /></a></p>
<p>The delegation tab is only visible on the user account when you have created a SPN for that account.</p>
<p><span style="font-family: 'Arial','sans-serif'; color: black; font-size: 9pt;">As mentioned, the delegation was only a partial answer to the question from the last post. In addition to that, you must also configure Kernel mode authentication in IIS 7.x. That is a topic for my next post.<o:p></o:p></span></p>]]></content:encoded>
    </item>
    <item>
      <title>What is a SPN and why should you care?</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/what-is-a-spn-and-why-should-you-care</link>
      <pubDate>Thu, 28 Apr 2011 07:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/04/28/what-is-a-spn-and-why-should-you-care/</guid>
      <description><![CDATA[I remember the first time I saw the acronym SPN when I were introduced to WCF some years ago.
After...]]></description>
      <content:encoded><![CDATA[<p>I remember the first time I saw the acronym SPN when I were introduced to WCF some years ago.</p>
<p>After reading&nbsp;the article in <a target="_blank" href="https://msdn.microsoft.com/en-us/library/ms677949(v=vs.85).aspx" title="https://msdn.microsoft.com/en-us/library/ms677949(v=vs.85).aspx">MSDN</a> I didn't feel better. What&nbsp;<em>is</em> a ServicePrincipalName?</p>
<p>The way I usually think now&nbsp;(and I apologize for you that don't know the DNS lingo) is that it is conceptually the same as a <a target="_blank" href="https://en.wikipedia.org/wiki/CNAME_record" title="https://en.wikipedia.org/wiki/CNAME_record">CNAME</a> record.</p>
<p>A SPN is nothing more fancy than an&nbsp;alias&nbsp;(or pointer) for a domain account, e.g.</p>
<p style="PADDING-LEFT: 30px"><strong>HTTP/HRWeb</strong> is an alias for the domain account&nbsp; <strong>MyDomain\HRWebAct</strong></p>
<p>You can have more than one SPN pointing to the <span style="text-decoration: underline;">same</span> domain account:</p>
<p style="PADDING-LEFT: 30px"><strong>HTTP/HRWeb2</strong> is&nbsp;<span style="text-decoration: underline;">also</span> an alias for the domain account <strong>MyDomain\HRWebAct</strong></p>
<p>In fact, the SPN: "HTTP/HRWeb<strong>"</strong>&nbsp;is an entry in&nbsp;the attribute servicePrincipalName&nbsp;for the account <strong>HRWebAct</strong> in the Windows Active Directory Domain <strong>MyDomain.com </strong><span style="font-size: medium;"><span style="font-size: xx-small;"><span style="color: #ff0000;">&sect;</span></span></span></p>
<p>The next obviously question would be: why do you need an alias?</p>
<p>The answer to that is a bit longer, and this is the beginning of the <span style="line-height: 115%; font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">journey </span>into the mystery of Kerberos.</p>
<p>Let me start with a little quiz that illustrates the complexity of Kerberos and the reason why people shy away from&nbsp;using Kerberos. The&nbsp;quiz is based on a real customer experience but&nbsp;sanitized to protect the customer identity.</p>
<p>&nbsp;(The following could also be a question in a certification test in Windows and Kerberos).</p>
<ul>
<li>You have a&nbsp;Windows Server 2008&nbsp;R2 server called&nbsp;<strong>MyWebServer</strong> that is member of the Active Directory domain&nbsp;<strong>MyDomain.com</strong></li>
<li>The Active Directory is configured on Windows Server 2003 server using the default options during installation.</li>
<li>On the web server you have&nbsp;several web sites including an HR Application:&nbsp;<strong>HRWeb</strong> </li>
<li>You prefer that your users is navigating to the application using a simple url like&nbsp;<span style="color: #3366ff;">https://HRWeb</span>&nbsp;</li>
<li>The HRWeb application need to connect to a SQL Server 2008 R2 database using <strong>"<span class="cs_k">Integrated Security</span>=</strong><span class="cs_v"><strong>SSPI"</strong> in the connection string</span></li>
<li>Only authorized people may use the HRWeb application</li>
<li>You want to manage permission on the database</li>
</ul>
<p>Then (as usual for this kind of certification test) a list of what you are doing to solve this requirement:</p>
<ul>
<li>Create&nbsp;a DNS Alias for HRWeb that refer to MyWebServer.MyDomain.com</li>
<li>Configure binding for the site with hostname <strong>HRWeb</strong> and port <strong>80</strong></li>
<li>Create an application pool with the identity of a domain account <strong>MyDomain\HRWebAct</strong></li>
<li>Configure the web site to use impersonation</li>
<li>Create a SPN using the command line to setspn.exe with the following parameters: <strong>HTTP/HRWeb</strong> <strong>MyDomain\HRWebAct</strong></li>
<li>Grant users the appopriate permissions on the SQL Server to access the HRWeb database</li>
</ul>
<p>Will this list of action satisfy the requirement? [Yes / No ]&nbsp;</p>
<p>I will supply the answer and <span style="line-height: 115%; font-family: 'Arial','sans-serif'; color: black; font-size: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">explanations </span>to&nbsp;the question in my next post. Feel free to comment with your answer and explanation.</p>
<p><span style="font-size: xx-small;"><span style="color: #ff0000;">&sect; <span style="color: #000000;">I am very well aware that you can use Kerberos in other environment that Windows. I may come back to that topic another day.</span></span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Introduction</title>
      <link>https://docs.microsoft.com/archive/blogs/autz_auth_stuff/introduction</link>
      <pubDate>Thu, 28 Apr 2011 04:47:32 GMT</pubDate>
      <dc:creator><![CDATA[Per Nygaard]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/autz_auth_stuff/2011/04/28/introduction/</guid>
      <description><![CDATA[Hi everyone
Finally got around to setting up my blog.
For those who don't know me - I'm Per...]]></description>
      <content:encoded><![CDATA[<p>Hi everyone</p>
<p>Finally got around to setting up my blog.</p>
<p>For those who don't know me - I'm Per Nygaard, an Architect in Microsoft Services, Denmark. I joined Microsoft in 1999 as consultant, and I have assisted many customer with both platform related areas (e.g. Windows, IIS and Active Directory) as well as developer related areas (e.g. .NET, WCF&nbsp;and SQL Server). </p>
<p>During my time as consultant I have&nbsp;helped IT Professionals to configure and understand Kerberos and other authentication/authorization related stuff on Windows and IIS.</p>
<p>Some of these people have had a really hard&nbsp; time searching for meaningfull documentation on how to configure and troubleshoot Windows authentication, and the idea to start a blog with this content have emerged. </p>
<p>Now I'm here ....</p>
<p>/Per</p>]]></content:encoded>
    </item>
  </channel>
</rss>