dotConnect for SQL Server Documentation
Devart.Data.SqlServer Namespace / ActiveDirectoryAuthenticationProvider Class
Members Example

On this page
    ActiveDirectoryAuthenticationProvider Class
    On this page
    Implements SqlAuthenticationProvider and is used for federated Active Directory authentication.
    Syntax
    'Declaration
     
    Public NotInheritable Class ActiveDirectoryAuthenticationProvider 
       Inherits SqlAuthenticationProvider
    public sealed class ActiveDirectoryAuthenticationProvider : SqlAuthenticationProvider 
    Example
    This is a code example.
    void Connect()
    {
            var authProvider = new ActiveDirectoryAuthenticationProvider(CustomDeviceFlowCallback);
            SqlAuthenticationProvider.SetProvider(SqlAuthenticationMethod.ActiveDirectoryDeviceCodeFlow, authProvider);
    
            var connection = new SqlConnection("Data Source=myServer.database.windows.net,1433;Authentication=Active Directory Device Code Flow;Connection Timeout=120");
            connection.Open();
    }
    
    private static Task CustomDeviceFlowCallback(Devart.Data.SqlServer.DeviceCodeResult result)
    {
            // Provide custom logic to process result information and read device code.
            Console.WriteLine(result.Message);
            return Task.FromResult(0);
    }
    Inheritance Hierarchy

    System.Object
       Devart.Data.SqlServer.SqlAuthenticationProvider
          Devart.Data.SqlServer.ActiveDirectoryAuthenticationProvider

    See Also