Language

ActiveDirectoryAuthenticationProvider Constructors

Definition

Overloads

Name Description
ActiveDirectoryAuthenticationProvider()

Initializes the ActiveDirectoryAuthenticationProvider class.

ActiveDirectoryAuthenticationProvider(ActiveDirectoryAuthenticationProviderOptions)

Initializes the ActiveDirectoryAuthenticationProvider class from a ActiveDirectoryAuthenticationProviderOptions bag. This is the recommended constructor for new code because new options can be added to ActiveDirectoryAuthenticationProviderOptions without forcing breaking changes on callers.

ActiveDirectoryAuthenticationProvider(String)

Initializes the ActiveDirectoryAuthenticationProvider class with the provided application client id.

ActiveDirectoryAuthenticationProvider(Func<DeviceCodeResult,Task>, String)

Initializes the ActiveDirectoryAuthenticationProvider class with the provided device code flow callback method and application client id.

ActiveDirectoryAuthenticationProvider()

Source:
ActiveDirectoryAuthenticationProvider.cs
Source:
ActiveDirectoryAuthenticationProvider.cs
Source:
ActiveDirectoryAuthenticationProvider.cs

Initializes the ActiveDirectoryAuthenticationProvider class.

public:
 ActiveDirectoryAuthenticationProvider();
public ActiveDirectoryAuthenticationProvider();
Public Sub New ()

Remarks

New code should prefer the ActiveDirectoryAuthenticationProvider(ActiveDirectoryAuthenticationProviderOptions) overload to avoid adding more constructor overloads as new options are introduced.

Applies to

ActiveDirectoryAuthenticationProvider(ActiveDirectoryAuthenticationProviderOptions)

Initializes the ActiveDirectoryAuthenticationProvider class from a ActiveDirectoryAuthenticationProviderOptions bag. This is the recommended constructor for new code because new options can be added to ActiveDirectoryAuthenticationProviderOptions without forcing breaking changes on callers.

public:
 ActiveDirectoryAuthenticationProvider(Microsoft::Data::SqlClient::ActiveDirectoryAuthenticationProviderOptions ^ options);
public ActiveDirectoryAuthenticationProvider(Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProviderOptions options);
new Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider : Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProviderOptions -> Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider
Public Sub New (options As ActiveDirectoryAuthenticationProviderOptions)

Parameters

options
ActiveDirectoryAuthenticationProviderOptions

A ActiveDirectoryAuthenticationProviderOptions instance whose properties initialize the provider. Must not be null.

Exceptions

Thrown when options is null.

Applies to

ActiveDirectoryAuthenticationProvider(String)

Source:
ActiveDirectoryAuthenticationProvider.cs
Source:
ActiveDirectoryAuthenticationProvider.cs
Source:
ActiveDirectoryAuthenticationProvider.cs

Initializes the ActiveDirectoryAuthenticationProvider class with the provided application client id.

public:
 ActiveDirectoryAuthenticationProvider(System::String ^ applicationClientId);
public ActiveDirectoryAuthenticationProvider(string applicationClientId);
new Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider : string -> Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider
Public Sub New (applicationClientId As String)

Parameters

applicationClientId
String

Client Application Id to be used for acquiring an access token for federated authentication. The driver uses its own application client id by default.

Examples

The following example demonstrates providing a user-defined application client id to SqlClient for the "Active Directory Interactive" authentication method:

using System;
using Microsoft.Data.SqlClient;

namespace CustomAuthenticationProviderExamples
{
  public class Program
  {
    public static void Main()
    {
      // Supported for all authentication modes supported by ActiveDirectoryAuthenticationProvider
      ActiveDirectoryAuthenticationProvider provider = new ActiveDirectoryAuthenticationProvider("<application_client_id>");
      if (provider.IsSupported(SqlAuthenticationMethod.ActiveDirectoryInteractive))
      {
        SqlAuthenticationProvider.SetProvider(SqlAuthenticationMethod.ActiveDirectoryInteractive, provider);
      }

      using (SqlConnection sqlConnection = new SqlConnection("Server=<myserver>.database.windows.net;Authentication=Active Directory Interactive;Database=>db<;"))
      {
        sqlConnection.Open();
        Console.WriteLine("Connected successfully!");
      }
    }
  }
}

Remarks

New code should prefer the ActiveDirectoryAuthenticationProvider(ActiveDirectoryAuthenticationProviderOptions) overload to avoid adding more constructor overloads as new options are introduced.

Applies to

ActiveDirectoryAuthenticationProvider(Func<DeviceCodeResult,Task>, String)

Source:
ActiveDirectoryAuthenticationProvider.cs
Source:
ActiveDirectoryAuthenticationProvider.cs
Source:
ActiveDirectoryAuthenticationProvider.cs

Initializes the ActiveDirectoryAuthenticationProvider class with the provided device code flow callback method and application client id.

public ActiveDirectoryAuthenticationProvider(Func<Microsoft.Identity.Client.DeviceCodeResult,System.Threading.Tasks.Task> deviceCodeFlowCallbackMethod, string applicationClientId = default);
public ActiveDirectoryAuthenticationProvider(Func<Microsoft.Identity.Client.DeviceCodeResult,System.Threading.Tasks.Task> deviceCodeFlowCallbackMethod, string? applicationClientId = default);
new Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider : Func<Microsoft.Identity.Client.DeviceCodeResult, System.Threading.Tasks.Task> * string -> Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider
Public Sub New (deviceCodeFlowCallbackMethod As Func(Of DeviceCodeResult, Task), Optional applicationClientId As String = Nothing)

Parameters

deviceCodeFlowCallbackMethod
Func<DeviceCodeResult,Task>

The callback method to be used with 'Active Directory Device Code Flow' authentication.

applicationClientId
String

(Optional) Client Application Id to be used for acquiring an access token for federated authentication. The driver uses its own application client id by default.

Remarks

New code should prefer the ActiveDirectoryAuthenticationProvider(ActiveDirectoryAuthenticationProviderOptions) overload to avoid adding more constructor overloads as new options are introduced.

Applies to