{"id":1613,"date":"2017-09-19T11:02:24","date_gmt":"2017-09-19T16:02:24","guid":{"rendered":"http:\/\/lisa.rushworth.us\/?p=1613"},"modified":"2017-09-19T11:02:24","modified_gmt":"2017-09-19T16:02:24","slug":"php-windows-authentication-to-ms-sql-database","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=1613","title":{"rendered":"PHP: Windows Authentication to MS SQL Database"},"content":{"rendered":"<p>I&#8217;ve encountered several people now how have followed &#8220;the directions&#8221; to allow their IIS-hosted PHP code to authenticate to a MS SQL server using Windows authentication &#8230; only to get an error indicating some unexpected ID is unable to log into the SQL server.<\/p>\n<p>Create your application pool and add an identity. Turn off\u00a0fastcgi.impersonate in your php.ini file. Create web site, use custom application pool &#8230; FAIL.<\/p>\n<pre>C:\\Users\\administrator.RUSHWORTH&lt;%windir%\\system32\\inetsrv\\appcmd.exe list config \"Exchange Back End\" \/section:anonymousAuthentication\r\n&lt;system.webServer&gt;\r\n  &lt;security&gt;\r\n    &lt;authentication&gt;\r\n      &lt;anonymousAuthentication enabled=\"true\" userName=\"IUSR\" \/&gt;\r\n    &lt;\/authentication&gt;\r\n  &lt;\/security&gt;\r\n&lt;\/system.webServer&gt;<\/pre>\n<p>The web site still doesn&#8217;t pick up the user from the application pool. Click on Anonymous Authentication, then click &#8220;Edit&#8221; over in the actions pane. Change it to use the application pool identity\u00a0<em>here<\/em> too (why wouldn&#8217;t it automatically do so when an identity is provided?? no idea!).<br \/>\n<a href=\"http:\/\/lisa.rushworth.us\/?attachment_id=1614\" rel=\"attachment wp-att-1614\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1614\" src=\"http:\/\/lisa.rushworth.us\/wp-content\/uploads\/2017\/09\/SettingAnonymousAuthToUseAppPoolIdentity.png\" alt=\"\" width=\"1023\" height=\"528\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2017\/09\/SettingAnonymousAuthToUseAppPoolIdentity.png 1023w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2017\/09\/SettingAnonymousAuthToUseAppPoolIdentity-300x155.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2017\/09\/SettingAnonymousAuthToUseAppPoolIdentity-768x396.png 768w\" sizes=\"auto, (max-width: 1023px) 100vw, 1023px\" \/><\/a><\/p>\n<pre>C:\\Users\\administrator.RUSHWORTH&lt;%windir%\\system32\\inetsrv\\appcmd.exe list config \"Exchange Back End\" \/section:anonymousAuthentication\r\n&lt;system.webServer&gt;\r\n  &lt;security&gt;\r\n    &lt;authentication&gt;\r\n      &lt;anonymousAuthentication enabled=\"true\" userName=\"\" \/&gt;\r\n    &lt;\/authentication&gt;\r\n  &lt;\/security&gt;\r\n&lt;\/system.webServer&gt;<\/pre>\n<p>I&#8217;ve always seen the null string in userName, although I&#8217;ve read that the element may be omitted entirely. Once the site is actually using the pool identity, PHP can authenticate to SQL accounts using Windows authentication.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve encountered several people now how have followed &#8220;the directions&#8221; to allow their IIS-hosted PHP code to authenticate to a MS SQL server using Windows authentication &#8230; only to get an error indicating some unexpected ID is unable to log into the SQL server. Create your application pool and add an identity. Turn off\u00a0fastcgi.impersonate in &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[338,337,35],"class_list":["post-1613","post","type-post","status-publish","format-standard","hentry","category-system-administration","tag-iis","tag-ms-sql","tag-php"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/1613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1613"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/1613\/revisions"}],"predecessor-version":[{"id":1615,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/1613\/revisions\/1615"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}