Benutzerberechtigungen eingebaut

This commit is contained in:
ms
2019-08-19 09:32:57 +02:00
parent 43c151d184
commit f470bce279
19 changed files with 610 additions and 154 deletions

View File

@@ -19,7 +19,7 @@ Public Class cBenutzer
Function FillWithLoggedOnUser(Optional ByVal dcabfrage As Boolean = False)
Function FillWithLoggedOnUser(Optional ByVal dcabfrage As Boolean = False, Optional ByVal LDAPa As String = "") '"LDAP://DC=VERAG,DC=OST,DC=DMN")
Try
userPrincipalName = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName
Name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.Name
@@ -29,18 +29,18 @@ Public Class cBenutzer
BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName
If dcabfrage = True Then
FillFromDC(userPrincipalName, "userPrincipalName")
'Class1.DebugText = userPrincipalName & LDAPa
FillFromDC(userPrincipalName, "userPrincipalName", LDAPa)
End If
End Function
Function FillFromDC(ByVal searchname As String, Optional ByVal searchfilter As String = "distinguishedName", Optional ByVal LDAP As String = "LDAP://DC=VERAG,DC=OST,DC=DMN")
Try
localdistinguishedName = searchname
Me.Domäne = "verag.ost.dmn"
If searchname.Contains("ForeignSecurityPrincipals") Then
'MsgBox("!")
Dim FSlocDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
Dim FSsearcher As New DirectoryServices.DirectorySearcher
With FSsearcher
@@ -49,7 +49,8 @@ Public Class cBenutzer
.PropertiesToLoad.Add("msDS-PrincipalName")
End With
Dim FSResult As DirectoryServices.SearchResult = FSsearcher.FindOne
searchname = blablabla(FSResult, "msDS-PrincipalName")
' MsgBox(FSResult.Properties("msDS-PrincipalName").Count)
searchname = FSResult.Properties("msDS-PrincipalName").Item(0)
Dim DomainName As String = searchname.Substring(0, searchname.IndexOf("\"))
' MsgBox(DomainName)
@@ -61,13 +62,19 @@ Public Class cBenutzer
Case "VERAGNEUHAUS"
Me.Domäne = "VERAGNEUHAUS.local"
LDAP = "LDAP://DC=VERAGNEUHAUS,DC=LOCAL"
Case "VERAGOST"
Me.Domäne = "verag.ost.dmn"
End Select
' MsgBox(searchname)
searchname = searchname.Substring((searchname.IndexOf("\") + 1), searchname.Length - searchname.IndexOf("\") - 1)
searchfilter = "sAMAccountName"
Else
'Me.Domäne = "verag.ost.dmn"
End If
If LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN" Then Me.Domäne = "verag.ost.dmn"
' MsgBox(searchname & vbCrLf & searchfilter & vbCrLf & Me.Domäne & vbCrLf & LDAP)
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
' Dim Searcher1 As New DirectoryServices.DirectorySearcher(locDirectoryEntry, searchfilter & "=" & searchname)
@@ -87,7 +94,7 @@ Public Class cBenutzer
.PropertiesToLoad.Add("userPrincipalName")
End With
Dim Result As DirectoryServices.SearchResult = Searcher.FindOne
Dim Result As DirectoryServices.SearchResult = searcher.FindOne
Me.Nachname = blablabla(Result, "sn")
@@ -158,5 +165,5 @@ End Class
Public Class cSharedClasses
Public Shared LoggedOnUser As New cBenutzer
' Public Shared LoggedOnUser As New cBenutzer
End Class