System.Data and Micrsoft.Data SQLClient and MFA

Lee Taylor 31 Reputation points
2023-10-18T15:47:19.7333333+00:00

We are trying to figure out how to implement MFA with Azure SQL Server. Currently we are using Active Directory Password within the connection string, I have seen some references to Active Directory Interactive but using this in my System.Data.SQLClient in my .NET Framework application gives an error for unsupported authentication method. How would I go about implementing MFA with Azure SQL in my Winforms .NET Framework (Systeem.Data.SQLClient) and Core (Microsoft.Data.SQLClient) applications?

Azure SQL Database
Developer technologies .NET Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sreeju Nair 12,666 Reputation points
    2023-10-18T17:22:21.08+00:00

    The connection string does not support MFA. If you want to implement MFA for your application, you need to implement this in the application layer. MFA for windows forms application can be integrated in to your application flow. Another good idea is to implement your windows forms application with Azure AD. See the below reference video.

    e.g. https://www.youtube.com/watch?v=73UAncCA2QQ

    Hope this helps

    0 comments No comments

  2. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2023-10-18T19:48:09.3833333+00:00

    Hi, @Lee Taylor Thanks for posting your question in the Microsoft Q&A forum. 

    Microsoft.Data.SqlCleint has multi-target frameworks support, including .NET Framework. S.D.SqlClient doesn't extend the features and to take advantage of them, you should consume M.D.SqlCleint.

    Connect to Azure SQL with Azure AD authentication and SqlClient - ADO.NET Provider for SQL Server | Microsoft Learn

    You can also check this sample if you're bound to use System.Data.SqlClient with MFA authentication:

    https://github.com/cheenamalhotra/SampleSqlAuthProvider

    More info on SQLAuthentication provider:

    https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlauthenticationprovider?view=netframework-4.8.1

     Ideally, you should be migrating to Microsoft.Data.SqlClient as soon as possible.

    Regards

    Geetha


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.