Webbstackar
PHP to MSSQL (Windows 7, PHP 5.4.22 nts, SQL SERVER 2008 R2 SP 2)
Install this:- IIS 7
- PHP 5.4.22 nts
- SQL SERVER 2008 R2 SP 2 (with tools/management studio)
- SQLSRV 3.0
- Microsoft SQL Server 2012 Native Client
The problem:
[SQL Server]Login failed for user 'NT instans\IUSR'.
The solution:
(SQL Server 2008 R2 SP2 NT instance\IUSR login howto)
SQLSRV 3.0 / IIS 7 uses the NT instance\IUSR login as default login
In Object Explorer in SQL Server Management Studio:
- Expand Security directory
- Right click Logins
- Click New Login... in the menu
- Click the Search... button
- Click the Advanced... button
- Click Search now button
- In the login/user list, click IUSR to select that login/user
- Click OK
- Click OK
The login/user is displayed as PCNAME/IUSR in the Login name field
- Rename the login/user to NT instance/IUSR
- Click OK. The login/user is added to the Logins list as NT INSTANCE/IUSR
- To change INSTANS part of the login/user name to lowercase, right click the name of NT INSTANCE/IUSR and click on Rename in the menu
- Change the name to NT instance\IUSR
Create a MSSQL user that uses the NT instance\IUSR login:
In Object Explorer in SQL Server Management Studio:
- Expand Databases directory
- Expand the database you want to access using PHP
- Expand the database subdirectory Security
- Right click the Users directory
- Click New User... in the menu
- Type in a user name (this can be any name you want) in the User name: field
- Click the browse button that is just to the right of the Login name: field
- Make sure the Select these object types: textarea only contains the word(object type) Logins
- Click the Browse... button
- Click in the NT instance\IUSR checkbox in the Matching objects: list to select the object type
- Click OK
- NT instans\IUSR is added to the Enter the object names to select (examples): textarea
- Click OK
- NT instans\IUSR is added to the Login name: field
- In the Database role membership / Role Members options list, click the db_datareader and db_datawriter checkboxes to select those options
- Click OK