0

I am trying to connect a Django application from local laptop to Azure SQL Managed Instance with AD authentication in place. I have the necessary permissions for the SQL as I have been configured to connect it from SSMS with same credentials.

I am trying to use ActiveDirectoryPassword as mentioned here. django-pyodbc-azure 2.1.0.0 docs and microsoft/mssql-django docs. Microsoft docs to connect to Azure MI. My db settings in settings.py is as follows:

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'XXXX/db name',
        'USER': 'xxxx.xxxx@xxxx.com',
        'PASSWORD': 'XXXXXX',
        'HOST': 'tcp:XXX.public.XXXX.database.windows.net',
        'PORT': '3342',
        'OPTIONS': {'driver':'ODBC Driver 17 for SQL Server',
                    'extra_params': 'Authentication=ActiveDirectoryPassword',
                    },},}

Getting below error:

django.db.utils.Error: ('FA004', "[FA004] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Failed to authenticate the user 'XXXX.XXXX@XXXXXXXX.com' in Active Directory (Authentication option is 'ActiveDirectoryPassword').\r\nError code 0xCAA2000C; state 10\r\nAADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access

Similar issue has been discussed here.

Dale K
  • 25,246
  • 15
  • 42
  • 71

1 Answers1

0

AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access

This can be because your tenant's Security Defaults has been activated**. You may turn it off by going to

Azure Portal >> Azure Active Directory >> Properties >> Select Manage Security Defaults >> Change the value of the Enable Security Defaults button to NO.

Refer this Microsofts official document for more information about Security Defaults

Pratik Lad
  • 4,343
  • 2
  • 3
  • 11