Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6580 (closed enhancement: duplicate)

Opened 3 years ago

Last modified 3 years ago

[PATCH] Add Windows Authentication support to SQL Server adapter

Reported by: bsammon Assigned to: tomafro
Priority: normal Milestone: 1.x
Component: ActiveRecord Version:
Severity: normal Keywords: SQLServer adapter reviewed
Cc:

Description

This patch adds a patch to sqlserver_adapter.rb to enable you to authenticate to the database with Windows Authentication. It adds a new ":windows_auth" option to establish_connection.

Sample usage:

ActiveRecord::Base.establish_connection(:adapter => 'sqlserver',

:host => hostname, :database => database, :windows_auth => true )

Attachments

sqlserver_adapter.svn.patch (1.3 kB) - added by bsammon on 11/08/06 18:16:22.
sqlserver_adapter.svn.patch.v2 (1.6 kB) - added by bsammon on 11/09/06 22:34:10.
Replacement patch which has documentation of the added feature
sqlserver_adapter_trusted_connection.patch (3.8 kB) - added by catan512 on 11/10/06 23:17:50.
Updated patch with unittest
add_trusted_config_to_odbc_connection.diff (0.7 kB) - added by brandon.beacher on 03/06/07 16:28:12.
sqlserver_trusted_connection_complete_patch.diff (3.1 kB) - added by tomafro on 07/03/07 14:16:58.
Complete patch with tests working in both ADO and ODBC mode

Change History

11/08/06 18:16:22 changed by bsammon

  • attachment sqlserver_adapter.svn.patch added.

11/09/06 07:48:09 changed by tomafro

  • owner changed from David to tomafro.

11/09/06 22:34:10 changed by bsammon

  • attachment sqlserver_adapter.svn.patch.v2 added.

Replacement patch which has documentation of the added feature

11/09/06 22:36:24 changed by bsammon

The new attachment has both the windows authentication functionality addition, and an addition to the comments/rdoc documenting the added argument.

11/10/06 23:17:50 changed by catan512

  • attachment sqlserver_adapter_trusted_connection.patch added.

Updated patch with unittest

03/02/07 15:09:12 changed by tomafro

  • keywords changed from SQLServer adapter to SQLServer adapter reviewed.

03/02/07 15:10:36 changed by tomafro

This patch looks great. Simple, tested, with obvious benefits. I'll try and push for its acceptance

03/06/07 16:28:12 changed by brandon.beacher

  • attachment add_trusted_config_to_odbc_connection.diff added.

03/06/07 16:28:29 changed by brandon.beacher

I'm using this patch in ADO mode and it is super. However, I've noticed a side-effect when testing ODBC mode. The command "rake test_sqlserver_odbc" barfs up one of these:

  5) Error:
test_trusted_connection(SqlServerAdapterTest):
ActiveRecord::AdapterNotSpecified: arunit_trusted database is not configured
    ./test/../lib/active_record/connection_adapters/abstract/connection_specific
ation.rb:204:in `establish_connection'
    ./test/adapter_test_sqlserver.rb:25:in `test_trusted_connection'
    c:/ruby/lib/ruby/gems/1.8/gems/mocha-0.4.0/lib/mocha/test_case_adapter.rb:19
:in `__send__'
    c:/ruby/lib/ruby/gems/1.8/gems/mocha-0.4.0/lib/mocha/test_case_adapter.rb:19
:in `run'

I've attached a patch which adds a connection when testing in ODBC mode. It makes test_sqlserver_odbc happy again.

03/07/07 11:22:30 changed by tomafro

I've now tested the main patch and it seems to work great. As Brandon has mentioned, it breaks the tests in ODBC mode, but rather than adding another connection to the ODBC mode tests, I've altered it to only run the test in ADO mode.

I'm currently preparing a batch of minor fixes and this will be included, hopefully this weekend. Thanks for everyone's hard work.

07/03/07 14:16:58 changed by tomafro

  • attachment sqlserver_trusted_connection_complete_patch.diff added.

Complete patch with tests working in both ADO and ODBC mode

07/03/07 14:18:48 changed by tomafro

Sorry about the very long delay. I've realigned this patch to work against edge, and ensured the test only runs against ADO (as it doesn't apply to ODBC)

07/03/07 17:47:37 changed by tomafro

  • status changed from new to closed.
  • resolution set to duplicate.

Rolled up into #8862