Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:12:13+00:00 2026-06-06T01:12:13+00:00

I am attempting to connect to a Microsoft SQL server db using PHP (in

  • 0

I am attempting to connect to a Microsoft SQL server db using PHP (in IIS). The user/pass provided in the code is an AD account that can access the database via ODBC in Access just fine.

$serverName = "servername";
$connectionInfo = array( "Database"=>"dbname", "UID"=>"myuser", "PWD"=>"mypass");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br /><pre>";
     die( print_r( sqlsrv_errors(), true));
}

The username and password are valid, as are the server name and database name. But this is returning the error:

[Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user ‘myuser’.

For the username (which is a valid user in AD, and I can connect/link to this database using Access) I’ve also tried:

  • DOMAIN.ORG\myuser
  • DOMAIN.ORG\\myuser
  • myuser@DOMAIN.ORG

My domain user (myuser) has admin privileges to that server via AD. But that returns the same Login failed error. Is there something I’m missing? I can connect to this same db using Access without a problem (under the same user).

The way I connect in Access is an ODBC Data Source for the local user. The Data Source is set to authenticate “With Windows NT authentication using the network login ID”. How can I do that in PHP?

Is this impersonation configuration the possible cause?

PHP is running under the user nt authority\iusr

If it was trying to login using iusr wouldn’t the error message say so?

I’ve tried creating a Data Source on this machine called “TestDS” and using the code:

$conn = odbc_connect("TestDS", "", "");

But that gives me:

The specified DSN contains an architecture mismatch between the Driver and Application, SQL state IM014 in SQLConnect

Machine1 is a client trying to access a webpage (where the PHP code is on Machine2) and the code on Machine2 is making the SQL connection to Machine3 (servername).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:12:15+00:00Added an answer on June 6, 2026 at 1:12 am

    “Windows Security” in SQL Server connections is enabled by specifying “Trusted Connection=SSPI” in the connection string. No username or password is stored in the connection string (that’s only for “SQL Server Security”). The process running PHP (presumably php_cgi.exe itself) must run under a Windows (either local or AD) that has a Windows login registered on the SQL Server.

    Under IIS php_cgi.exe runs under the user identity of the application pool. If you have a heterogenous security environment I suggest creating an IIS application pool just for this single website.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to connect to Microsoft SQL Server 2008 R2 from within Microsoft
When attempting to connect to a SQL Server 2008 Instance using Management Studio, I
I'm attempting to connect to our exchange server using Mail::IMAPClient but a script that
First off, I can connect to both databases with SQL Server Enterprise Manager, so
I am attempting to connect to a SQL Server 2008 R2 instance from another
I attempting to connect to a server via PHP fsockopen to initially get a
I am attempting to connect to a local HTTPS server using the apache DefaultHttpClient
I have some code written that is attempting to connect to a mysql db.
I am attempting to connect to my local MySQL server with the following code:
I'm attempting to connect to a MySQL server using C++ with the MySQL ODBC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.