Welcome Guest, Not a member yet? Register   Sign In
Database classes for SQL Server 2005 and SQL Server 2008 (using php_sqlsrv.dll from the Microsoft Data Programmability t
#8

[eluser]JulianM[/eluser]
Hi again, I have resolved this a few days ago, and maybe you are interesting to know the simple modification I made to your sqlsrv database library, in order to work with Windows Authentication (not SQL Server mode only).

I only have changed the db_connect() function in database/drivers/sqlsrv/sqlsrv_driver.php for this:

Code:
function db_connect($pooling = false)
    {
        if (empty($this->username) )
        {
            $connection = array( 'Database' => $this->database );
        
        } else {
        
            $connection = array(
                'UID' => (empty($this->username)) ? '' : $this->username,
                'PWD' => (empty($this->password)) ? '' : $this->password,
                'Database' => $this->database,
                'ConnectionPooling' => ($pooling) ? 1 : 0
            );
        }
        
        $result =  sqlsrv_connect($this->hostname, $connection);
        if (!$result)
        {
            // print_r( sqlsrv_errors() );
        }

        return $result;
    }

Explanation:

The driver assumes to use Windows Authentication if USR and PWD are not specified.

Moreover, you can ever print sqlsrv_errors() in case of an error, to know why it was not able to connect.


[quote author="JulianM" date="1233211074"]
Now, I need to figure if is possible to connect to SQL Server 2005 using Windows Authentication only (not mixed mode).
[/quote][/quote]


Messages In This Thread
Database classes for SQL Server 2005 and SQL Server 2008 (using php_sqlsrv.dll from the Microsoft Data Programmability t - by El Forum - 02-02-2009, 07:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB