This commit is contained in:
ms
2018-11-22 16:52:25 +01:00
parent 85727a8e2f
commit 106f90ba07
70 changed files with 21133 additions and 2 deletions

View File

@@ -0,0 +1,85 @@
Imports System.Net.Dns
Public Class Login
Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Public Sub Login()
Timer1.Enabled = False
Try
Dim Addresslistcounts As Integer = Resolve("verag.ost.dmn").AddressList.Count
Abfrage(Environment.UserName)
'MsgBox(Addresslistcounts)
Catch
MsgBox("Fehler beim Anmelden!")
PasswortabfrageLogin.Show()
Catch ex As Exception
End Try
'Abfrage("ZollDE14")
End Sub
Public Function Abfrage(user As String)
Dim locGroups As List(Of String) = GetUserGroupMembership(user)
Dim gefunden As Boolean = False
For Each group As String In locGroups
' LblDebugInfo.Text &= group
If group = "CN=DokuGruppe" Then
'MsgBox("Benutzer " & Environment.UserName & " in Gruppe " & group & " gefunden!")
gefunden = True
Main.Show()
Me.Hide()
'Exit Function
End If
Next
If gefunden = True Then
Exit Function
Else
Me.WindowState = Me.WindowState.Normal
PanHilfe.Visible = True
LblInfo.Text = "Benutzer " & user & " hat keine Zugriffsrechte." & vbCrLf & vbCrLf &
"Temporäre Anmeldung mit privilegierten User mit " & vbCrLf &
">Rechtsklick< bei gedrückter >Shift<" & vbCrLf &
"Taste --> 'Als anderer Benutzer ausführen'" & vbCrLf & vbCrLf &
"Sonst bitte bei Sebastian melden..."
End If
End Function
Friend Function GetUserGroupMembership(ByVal locUsername As String) As List(Of String)
Dim locResult As New List(Of String)
Try
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry("LDAP://DC=VERAG,DC=OST,DC=DMN") ' ActiveDirectory-Pfad anpassen
Dim locDirectorySearcher As New DirectoryServices.DirectorySearcher(locDirectoryEntry, "sAMAccountName=" & locUsername)
Dim locSearchResult As DirectoryServices.SearchResult = locDirectorySearcher.FindOne
If locSearchResult IsNot Nothing Then
Dim locUserEntry As New DirectoryServices.DirectoryEntry(locSearchResult.Path)
Dim locGroups As Object = locUserEntry.Invoke("Groups")
For Each locGroupObj As Object In DirectCast(locGroups, IEnumerable)
Dim locGroupEntry As New DirectoryServices.DirectoryEntry(locGroupObj)
locResult.Add(locGroupEntry.Name)
Next
Else
Debug.WriteLine("User nicht gefunden!")
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "GetUserGroupMembership", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return locResult
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Login()
' Timer1.Enabled = False
End Sub
Private Sub CmdVerstanden_Click(sender As Object, e As EventArgs) Handles CmdVerstanden.Click
Application.Exit()
End Sub
End Class