I have a VB.NET application that has 2 routines to open databases in SQL which all worked fine until we migrated databases to an SQL Azure Instance with MFA.
The first sequence works fine with MFA and gets authenticated to show the list of databases to choose from. However, when i pick the database from the selection in the application, i cannot get the MFA prompt to authenticate again
Any help appreciated
Private connection2 As SqlConnection
Private Sub ImageComboBoxDatabase_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ImageComboBoxDatabase.SelectedIndexChanged
TreeList1.Visible = False
WindowsIdentity.GetCurrent()
Dim listDataBases As New List(Of String)()
server = ImageComboBoxDatabase.EditValue.ToString
Dim connectString As String = "Data Source=" & server & " ; Authentication=Active Directory Interactive; Encrypt=True; Initial Catalog=master; User Id=" & User
connection2 = New SqlConnection(connectString) ' Store the connection
connection2.Open()
Dim selectSQL As String = "Select name from sys.databases where name Like 'cw_%';"
'Using con As New SqlConnection(connectString)
Using com As New SqlCommand(selectSQL, connection2)
Using dr As SqlDataReader = com.ExecuteReader()
While dr.Read()
listDataBases.Add(dr(0).ToString())
End While
End Using
End Using
GridLookUpEditDropDown.Properties.DataSource = listDataBases
End Sub
Public Cnstring As String
Private connection As New SqlConnection(Cnstring)
Private Sub SimpleButtonProjectSwitch_Click(sender As Object, e As EventArgs) Handles SimpleButtonProjectSwitch.Click
CnString = "Data Source=" & server & " ; Authentication=Active Directory Interactive; Encrypt=True; Initial Catalog=master; User Id=" & UserNameVariable
'Treelist
TreeListTableAdapter.Connection.ConnectionString = Cnstring
Me.TreeListTableAdapter.Fill(Me.Ds_TreeList.TreeList)
End Sub
I can get it to work if i use an SQL Login username but not an authenticated user which i need