Page 1 of 1

odbc_connect using NT AUTHENTICATION

Posted: Tue Mar 10, 2009 6:16 pm
by kcroning
Hi

I have a test server set up with APACHE and PHP on a windows machine and i also have MYSQL and normally grab data from a mysql database but i am wokring on another project which needs me to access data from a MS SQL database and at the moment im trying to connect to it.

So what im up to is i have set up the ODBC connection in data sources so that it uses a NT authentication to connect to the SQL Server and i have tested the connection when i created it and it works but when i write the code for it and run it, it comes up with this error.

Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DOMAINNAME\USERNAME$'., SQL state 28000 in SQLConnect in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\IT\Price List\PriceTest.php on line 4
ODBC Error:: 28000 :: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DOMAINNAME\USERNAME$'. :: DRIVER={SQL Server};SERVER=SERVERNAME;DATABASE=DSNNAME

Here is my code:

<?php
$virtual_dsn = 'DRIVER={SQL Server};SERVER=SERVERNAME;DATABASE=DSNNAME';
$connection = odbc_connect($virtual_dsn,'','') or die('ODBC Error:: '.odbc_error().' :: '.odbc_errormsg().' :: '.$virtual_dsn);
?>

I found this on a site but cant remember which one it was but obviously it seems to be getting to the server but wont log in becasue of the user name.

Also im not sure if i need to configure PHP for MS SQL.

So pretty much just need help to start from scratch.