Add Initial Support for OAuth2 / O365
This commit is contained in:
@@ -158,6 +158,24 @@ Public Class frmMain
|
||||
|
||||
_LoadInProgress = False
|
||||
End Sub
|
||||
|
||||
Private Sub Load_Email()
|
||||
SetEmailTextboxLabels()
|
||||
End Sub
|
||||
|
||||
Private Sub SetEmailTextboxLabels()
|
||||
Select Case AUTH_TYPEComboBox.Text
|
||||
Case "OAUTH2"
|
||||
EMAIL_SMTPLabel.Text = "Anwendungs-ID (Client):"
|
||||
EMAIL_PWLabel.Text = "Anwendungs-Geheimnnis:"
|
||||
ARCHIVE_FOLDERLabel.Text = "Verzeichnis-ID (Mandant):"
|
||||
Case Else
|
||||
EMAIL_SMTPLabel.Text = "Server:"
|
||||
EMAIL_PWLabel.Text = "Neues Passwort:"
|
||||
ARCHIVE_FOLDERLabel.Text = "Archive Ordner:"
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub ObjektTypenEintragen()
|
||||
Try
|
||||
If IsNothing(_windream) Then
|
||||
@@ -588,9 +606,12 @@ Public Class frmMain
|
||||
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
|
||||
tslblRefresh.BackColor = Color.Transparent
|
||||
tslblRefresh.Text = ""
|
||||
If TabControl1.SelectedIndex = 2 Then
|
||||
If TabControl1.SelectedTab.Equals(tabConfig) Then
|
||||
Load_Config()
|
||||
End If
|
||||
If TabControl1.SelectedTab.Equals(tabEmail) Then
|
||||
Load_Email()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Active_Color(pCheckBox As CheckBox)
|
||||
@@ -723,10 +744,27 @@ Public Class frmMain
|
||||
|
||||
If oDT.Rows.Count = 1 Then
|
||||
|
||||
Dim PWPlain = _Encryption.DecryptData(oDT.Rows(0).Item("EMAIL_PW"))
|
||||
Dim oRow As DataRow = oDT.Rows.Item(0)
|
||||
|
||||
Dim PWPlain = _Encryption.DecryptData(oRow.Item("EMAIL_PW"))
|
||||
Dim oServer = oRow.Item("EMAIL_SMTP")
|
||||
Dim oPortIn = oRow.Item("PORT_IN")
|
||||
Dim oUser = oRow.Item("EMAIL_USER")
|
||||
Dim oAuthType = oRow.Item("AUTH_TYPE")
|
||||
Dim oArchiveFolder = oRow.Item("ARCHIVE_FOLDER")
|
||||
|
||||
Dim oFetcher As New MailFetcher(LogConfig)
|
||||
Dim oSession = oFetcher.Connect(oDT.Rows(0).Item("EMAIL_SMTP"), oDT.Rows(0).Item("PORT_IN"), oDT.Rows(0).Item("EMAIL_USER"), PWPlain, oDT.Rows(0).Item("AUTH_TYPE"))
|
||||
Dim oSession As MailSession.SessionInfo
|
||||
|
||||
If oAuthType = MailSession.AUTH_OAUTH2 Then
|
||||
' These Variables from the DB are reused for the OAuth credentials
|
||||
Dim oClientId = oServer
|
||||
Dim oClientSecret = PWPlain
|
||||
Dim oTenantId = oArchiveFolder
|
||||
oSession = oFetcher.ConnectToO365(oUser, oClientId, oTenantId, oClientSecret)
|
||||
Else
|
||||
oSession = oFetcher.Connect(oServer, oPortIn, oUser, PWPlain, oAuthType)
|
||||
End If
|
||||
|
||||
If oSession.Connected = True Then
|
||||
' Unseen check will be done automatically
|
||||
@@ -858,6 +896,7 @@ Public Class frmMain
|
||||
PORT_INTextBox.Enabled = True
|
||||
End Select
|
||||
End If
|
||||
SetEmailTextboxLabels()
|
||||
End Sub
|
||||
|
||||
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
|
||||
@@ -888,4 +927,8 @@ Public Class frmMain
|
||||
Dim oCheckBox As CheckBox = sender
|
||||
Active_Color(oCheckBox)
|
||||
End Sub
|
||||
|
||||
Private Sub GridView6_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridView6.FocusedRowChanged
|
||||
SetEmailTextboxLabels()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user