Not able to login through Azure Active Directory through C# .Net Core Application

I need to want to use Azure Active Directory User to login to the DB instead of SQL Login. The user should have access as per the privileges that are provided to him e.g. read/write, readonly, etc. I have written the code below but I am getting an exception:

  string ConnectionString = @";" +
                                      @" Authentication=Active Directory Integrated; Encrypt=True;  User Id=UserId; ";                
            using (SqlConnection conn = new SqlConnection(ConnectionString)) 

The user has read/write access.


Microsoft.Data.SqlClient.SqlException (0x80131904): Failed to authenticate the user UserId in Active Directory (Authentication=ActiveDirectoryIntegrated).
Error code 0xunknown_user_type
Unsupported User Type 'Unknown'. Please see

Can I please get some help on this. Thanks.

Read more here: Source link