Moodle 2.8.2 w/ sqlsrv - Attempting to use an NT account name with SQL Server Authentication.

Re: Moodle 2.8.2 w/ sqlsrv - Attempting to use an NT account name with SQL Server Authentication.

by Nils Finnsson -
Number of replies: 2
Thanks for the reply Howard. I think I'm in a territory where most people decide to go with local SQL authentication instead of making the required changes to use NT auth.

This post has a bunch of interesting information - https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d8bb596c-9f30-41fb-b136-2abc2a60ac6b/connection-to-sql-server-2008-login-failed-for-user  Essentially it's the same problem, just pared down to the PHP required to make an SQL connection. From what I'm reading, the application pool needs to run in the context of the user I want to connect to the database as. If that's correct, I'd simply remove the $CFG->dbuser and $CFG->dbpass options from config.php. However I'm not sure that will work.

http://php.net/manual/en/function.sqlsrv-connect.php has the following comments...

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.

But lib\dml\sqlsrv_native_moodle_database.php has the following connection string..

        $this->sqlsrv = sqlsrv_connect($this->dbhost, array
         (
          'UID' => $this->dbuser,
          'PWD' => $this->dbpass,
          'Database' => $this->dbname,
          'CharacterSet' => 'UTF-8',
          'MultipleActiveResultSets' => true,
          'ConnectionPooling' => !empty($this->dboptions['dbpersist']),
          'ReturnDatesAsStrings' => true,
         ));

So it's passing UID and PWD, even if they're empty. I'll have to do some more testing over the next few days. And unfortunately, I might fall into the group that ends up using SQL authentication anyways. Hopefully I can at least get this sorted for other people that want to do the same thing.

-nils

In reply to Nils Finnsson

Re: Moodle 2.8.2 w/ sqlsrv - Attempting to use an NT account name with SQL Server Authentication.

by Rui Santos -

Hi Nils Finnsson,

Did you manage to get it working with Windows Authentication?

I'm trying to do the same, but with no success.

Thanks.

In reply to Rui Santos

Re: Moodle 2.8.2 w/ sqlsrv - Attempting to use an NT account name with SQL Server Authentication.

by Nils Finnsson -
No. mixed

After a couple more days experimenting and testing, I couldn't get it working properly. Other priorities made me decide to stick with SQL auth and move onto other projects.