Megosztás a következőn keresztül:


ActiveDirectoryAuthenticationProvider Constructors

Definition

Overloads

ActiveDirectoryAuthenticationProvider()

Initializes the ActiveDirectoryAuthenticationProvider class.

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()

Initializes the ActiveDirectoryAuthenticationProvider class.

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

Applies to

ActiveDirectoryAuthenticationProvider(String)

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!");
            }
        }
    }
}

Applies to

ActiveDirectoryAuthenticationProvider(Func<DeviceCodeResult,Task>, String)

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);
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.

Applies to