Problem/Motivation

SQLSRV should support Windows authentication from the very beginning when installing Drupal.

Proposed resolution

Modify the Drupal installation form to allow a blank username when installing to SQL Server. By using an empty string for the username, the driver falls back to Windows authentication. Also, add a description which explains that leaving the username blank enables Windows authentication.

Remaining tasks

  1. Write patch
  2. Community to test patch #1
  3. Commit patch
  4. Update installation documentation?

User interface changes

Slightly modified form in installation process.

API changes

None.

Comments

Akaoni’s picture

StatusFileSize
new732 bytes

Here's a patch.

Akaoni’s picture

Status: Active » Needs review

CNR.
Updated summary.

Akaoni’s picture

Issue summary: View changes

Update remaining tasks

artusamak’s picture

Status: Needs review » Needs work

With your patch the connection form to the database won't be required but nothing is implementing the connection through Windows authentication.
The problem is not limited to the installation phase, you potentialy have to connect to the database on every query and just removing required fields is not enough, there is no automatic fallback on windows auth.
I'm not sure that it's compatible with Drupal.

Akaoni’s picture

Issue summary: View changes

Added to remaining tasks

Akaoni’s picture

Status: Needs work » Needs review

@Artusamak: Sorry mate, I probably should have put more info in the issue summary about how this works.

By default, the PHP SQLSRV driver uses Windows authentication.
Drupal passes a username and password to the connect function which makes it use SQL Server authentication.
If you use an empty string for username and password however, it falls back to Windows authentication.

Doco here:
http://msdn.microsoft.com/en-us/library/cc296198.aspx

By making the username not required in the install form (password is already not required), this setup is stored in settings.php and therefore used for every query run by Drupal.
For example, here's the settings in my instance of Drupal 7.10 running this patch and Windows authentication:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal',
      'username' => '',
      'password' => '',
      'host' => 'vasqld01\\sql01',
      'port' => '',
      'driver' => 'sqlsrv',
      'prefix' => '',
    ),
  ),
);

I haven't done exhaustive testing, but it works just fine for me. ;)

Edit: I did some more testing and it seems that only username needs to be empty for the driver to fall back to Windows authentication.

damien tournoud’s picture

Status: Needs review » Fixed

Sounds reasonable. Merged into 7.x-1.x. Thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added more info about how this works.