Skip to content

Commit

Permalink
[Release 1.1] Allow username with Active Directory Interactive Authen…
Browse files Browse the repository at this point in the history
…tication (#493)
  • Loading branch information
cheenamalhotra authored Mar 30, 2020
1 parent 2c27549 commit ed113ac
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public override Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthentication
{
result = await app.AcquireTokenInteractive(scopes)
.WithUseEmbeddedWebView(true)
.WithLoginHint(parameters.UserId)
.ExecuteAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
throw SQL.IntegratedWithUserIDAndPassword();
}

if (Authentication == SqlAuthenticationMethod.ActiveDirectoryInteractive && (HasUserIdKeyword || HasPasswordKeyword))
if (Authentication == SqlAuthenticationMethod.ActiveDirectoryInteractive && (HasPasswordKeyword))
{
throw SQL.InteractiveWithUserIDAndPassword();
throw SQL.InteractiveWithPassword();
}

#if ADONET_CERT_AUTH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ static internal Exception IntegratedWithUserIDAndPassword()
return ADP.Argument(StringsHelper.GetString(Strings.SQL_IntegratedWithUserIDAndPassword));
}

static internal Exception InteractiveWithUserIDAndPassword()
static internal Exception InteractiveWithPassword()
{
return ADP.Argument(StringsHelper.GetString(Strings.SQL_InteractiveWithUserIDAndPassword));
return ADP.Argument(StringsHelper.GetString(Strings.SQL_InteractiveWithPassword));
}

static internal Exception SettingIntegratedWithCredential()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2496,8 +2496,8 @@
<data name="SQL_IntegratedWithUserIDAndPassword" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Integrated' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords.</value>
</data>
<data name="SQL_InteractiveWithUserIDAndPassword" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Interactive' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords.</value>
<data name="SQL_InteractiveWithPassword" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Interactive' with 'Password' or 'PWD' connection string keywords.</value>
</data>
<data name="SQL_SettingIntegratedWithCredential" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Integrated', if the Credential property has been set.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ public static void IntegratedAuthWithCred()

[ConditionalFact(nameof(IsAADConnStringsSetup))]
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)]
public static void MFAAuthWithCred()
public static void MFAAuthWithPassword()
{
// connection fails with expected error message.
string[] AuthKey = { "Authentication" };
string connStr = RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, AuthKey) + "Authentication=Active Directory Interactive;";
ArgumentException e = Assert.Throws<ArgumentException>(() => ConnectAndDisconnect(connStr));

string expectedMessage = "Cannot use 'Authentication=Active Directory Interactive' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords.";
string expectedMessage = "Cannot use 'Authentication=Active Directory Interactive' with 'Password' or 'PWD' connection string keywords.";
Assert.Contains(expectedMessage, e.Message);
}

Expand Down

0 comments on commit ed113ac

Please sign in to comment.