I've set up a Windows Server 2019 box with IIS, PHP 8 and SQL Drivers, and SQL Server 2019 Express. I created a test PHP application and corresponding application pool, then set up a test database. When trying to connect using sqlsrv_connect, I get the following error:
Login failed for user 'NT AUTHORITY\IUSR'.
(There is more there in the SQL error but it's just the raw error array output and Stack Overflow doesn't like it.)
Now, I believe I have everything configured correctly to use the application pool identity instead of NT AUTHORITY\IUSR. I copied the setup from another older (Server 2012) web server. Screenshots of my setup:
Anonymous Authentication using App pool identity in IIS
App pool identity added on database in SQL Server
Am I missing a setting somewhere, or does Server 2019 handle application pool identities differently than server 2012? I've tried following instructions like on this excellent SO page:
IIS AppPool to SQL Server permissions (adding NT AUTHORITY\IUSR)
But it's like the server doesn't care that I've told it to use the application pool.
UPDATE EDIT: MYSTERY SOLVED
Apologies all, this was a case of extreme user error. I put the "test" directory under wwwroot, ala c:\inetpub\wwwroot\test. I was accessing it as www.domain.com/test, when what I needed to do was set it to run as test.domain.com. It was running under the wwwroot app pool (which in this case was using IUSR) because that is how I was accessing it. Thank you everyone who helped me troubleshoot this!
Apologies all; this was a case of extreme user error.
I put the test
directory under wwwroot
, i.e., c:\inetpub\wwwroot\test
. I was accessing it as www.domain.com/test
, when what I needed to do was set it to run as test.domain.com
. It was running under the wwwroot
application pool (which, in this case, was using IUSR
) because that is how I was accessing it.
Thank you everyone who helped me troubleshoot this!