Azure AD tests using ActiveDirectoryPassword
This commit is contained in:
parent
31fb19405b
commit
f38d57b7f7
|
@ -21,6 +21,11 @@ if (isset($_ENV['MSSQL_SERVER']) || isset($_ENV['MSSQL_USER']) || isset($_ENV['M
|
||||||
$DriverName = "ODBC Driver 11 for SQL Server";
|
$DriverName = "ODBC Driver 11 for SQL Server";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$adServer = 'TARGET_AD_SERVER';
|
||||||
|
$adDatabase = 'TARGET_AD_DATABASE';
|
||||||
|
$adUser = 'TARGET_AD_USERNAME';
|
||||||
|
$adPassword = 'TARGET_AD_PASSWORD';
|
||||||
|
|
||||||
$driverType = true;
|
$driverType = true;
|
||||||
$PhpDriver = "ODBC Driver 11 for SQL Server";
|
$PhpDriver = "ODBC Driver 11 for SQL Server";
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test the Authentication keyword with options SqlPassword and ActiveDirectoryIntegrated.
|
Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword.
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
|
<?php require('skipif.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once("MsSetup.inc");
|
require_once("MsSetup.inc");
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test Azure AD with Authentication=SqlPassword.
|
||||||
|
//
|
||||||
$connectionInfo = "Database = $databaseName; Authentication = SqlPassword; TrustServerCertificate = true;";
|
$connectionInfo = "Database = $databaseName; Authentication = SqlPassword; TrustServerCertificate = true;";
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -33,8 +36,10 @@ else
|
||||||
|
|
||||||
$conn = null;
|
$conn = null;
|
||||||
|
|
||||||
////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test Azure AD with integrated authentication. This should fail because
|
||||||
|
// we don't support it.
|
||||||
|
//
|
||||||
$connectionInfo = "Authentication = ActiveDirectoryIntegrated; TrustServerCertificate = true;";
|
$connectionInfo = "Authentication = ActiveDirectoryIntegrated; TrustServerCertificate = true;";
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -50,8 +55,37 @@ catch( PDOException $e )
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test Azure AD on an Azure database instance. Replace $azureServer, etc with
|
||||||
|
// your credentials to test, or this part is skipped.
|
||||||
|
//
|
||||||
|
$azureServer = $adServer;
|
||||||
|
$azureDatabase = $adDatabase;
|
||||||
|
$azureUsername = $adUser;
|
||||||
|
$azurePassword = $adPassword;
|
||||||
|
|
||||||
|
if ($azureServer != 'TARGET_AD_SERVER')
|
||||||
|
{
|
||||||
|
$connectionInfo = "Authentication = ActiveDirectoryPassword; TrustServerCertificate = false";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conn = new PDO( "sqlsrv:server = $azureServer ; $connectionInfo", $azureUsername, $azurePassword );
|
||||||
|
echo "Connected successfully with Authentication=ActiveDirectoryPassword.\n";
|
||||||
|
}
|
||||||
|
catch( PDOException $e )
|
||||||
|
{
|
||||||
|
echo "Could not connect with ActiveDirectoryPassword.\n";
|
||||||
|
print_r( $e->getMessage() );
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "Not testing with Authentication=ActiveDirectoryPassword.\n";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
Connected successfully with Authentication=SqlPassword.
|
Connected successfully with Authentication=SqlPassword.
|
||||||
array(2) {
|
array(2) {
|
||||||
[""]=>
|
[""]=>
|
||||||
|
@ -60,4 +94,6 @@ array(2) {
|
||||||
string(1) "7"
|
string(1) "7"
|
||||||
}
|
}
|
||||||
Could not connect with Authentication=ActiveDirectoryIntegrated.
|
Could not connect with Authentication=ActiveDirectoryIntegrated.
|
||||||
SQLSTATE[IMSSP]: Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
|
SQLSTATE[IMSSP]: Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
|
||||||
|
%s with Authentication=ActiveDirectoryPassword.
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,11 @@ $marsMode = true;
|
||||||
|
|
||||||
$traceEnabled = false;
|
$traceEnabled = false;
|
||||||
|
|
||||||
|
$adServer = 'TARGET_AD_SERVER';
|
||||||
|
$adDatabase = 'TARGET_AD_DATABASE';
|
||||||
|
$adUser = 'TARGET_AD_USERNAME';
|
||||||
|
$adPassword = 'TARGET_AD_PASSWORD';
|
||||||
|
|
||||||
if (isset($_ENV['MSSQL_SERVER']) || isset($_ENV['MSSQL_USER']) || isset($_ENV['MSSQL_PASSWORD'])) {
|
if (isset($_ENV['MSSQL_SERVER']) || isset($_ENV['MSSQL_USER']) || isset($_ENV['MSSQL_PASSWORD'])) {
|
||||||
$server = $_ENV['MSSQL_SERVER'];
|
$server = $_ENV['MSSQL_SERVER'];
|
||||||
$uid = $_ENV['MSSQL_USER'];
|
$uid = $_ENV['MSSQL_USER'];
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test the Authentication keyword with options SqlPassword and ActiveDirectoryIntegrated.
|
Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword.
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
|
<?php require('skipif.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once("MsSetup.inc");
|
require_once("MsSetup.inc");
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test Azure AD with Authentication=SqlPassword.
|
||||||
|
//
|
||||||
$connectionInfo = array( "Database"=>$databaseName, "UID"=>$uid, "PWD"=>$pwd,
|
$connectionInfo = array( "Database"=>$databaseName, "UID"=>$uid, "PWD"=>$pwd,
|
||||||
"Authentication"=>'SqlPassword', "TrustServerCertificate"=>true);
|
"Authentication"=>'SqlPassword', "TrustServerCertificate"=>true);
|
||||||
|
|
||||||
|
@ -35,8 +38,10 @@ else
|
||||||
sqlsrv_free_stmt( $stmt );
|
sqlsrv_free_stmt( $stmt );
|
||||||
sqlsrv_close( $conn );
|
sqlsrv_close( $conn );
|
||||||
|
|
||||||
////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test Azure AD with integrated authentication. This should fail because
|
||||||
|
// we don't support it.
|
||||||
|
//
|
||||||
$connectionInfo = array( "Authentication"=>"ActiveDirectoryIntegrated", "TrustServerCertificate"=>true );
|
$connectionInfo = array( "Authentication"=>"ActiveDirectoryIntegrated", "TrustServerCertificate"=>true );
|
||||||
|
|
||||||
$conn = sqlsrv_connect( $server, $connectionInfo );
|
$conn = sqlsrv_connect( $server, $connectionInfo );
|
||||||
|
@ -52,8 +57,38 @@ else
|
||||||
sqlsrv_close( $conn );
|
sqlsrv_close( $conn );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test Azure AD on an Azure database instance. Replace $azureServer, etc with
|
||||||
|
// your credentials to test, or this part is skipped.
|
||||||
|
//
|
||||||
|
$azureServer = $adServer;
|
||||||
|
$azureDatabase = $adDatabase;
|
||||||
|
$azureUsername = $adUser;
|
||||||
|
$azurePassword = $adPassword;
|
||||||
|
|
||||||
|
if ($azureServer != 'TARGET_AD_SERVER')
|
||||||
|
{
|
||||||
|
$connectionInfo = array( "UID"=>$azureUsername, "PWD"=>$azurePassword,
|
||||||
|
"Authentication"=>'ActiveDirectoryPassword', "TrustServerCertificate"=>true );
|
||||||
|
|
||||||
|
$conn = sqlsrv_connect( $azureServer, $connectionInfo );
|
||||||
|
if( $conn === false )
|
||||||
|
{
|
||||||
|
echo "Could not connect with ActiveDirectoryPassword.\n";
|
||||||
|
print_r( sqlsrv_errors() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "Connected successfully with Authentication=ActiveDirectoryPassword.\n";
|
||||||
|
sqlsrv_close( $conn );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "Not testing with Authentication=ActiveDirectoryPassword.\n";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
Connected successfully with Authentication=SqlPassword.
|
Connected successfully with Authentication=SqlPassword.
|
||||||
array(2) {
|
array(2) {
|
||||||
[0]=>
|
[0]=>
|
||||||
|
@ -70,4 +105,6 @@ Array
|
||||||
[code] => -62
|
[code] => -62
|
||||||
[2] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
|
[2] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
|
||||||
[message] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
|
[message] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
|
||||||
)
|
)
|
||||||
|
%s with Authentication=ActiveDirectoryPassword.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue