An Haufen Zeug
This commit is contained in:
@@ -11,6 +11,13 @@ Public Class Class1
|
||||
'Public Shared FilePath As String = "\\192.168.0.253\backup\temp_Sebastian\Spielwiese\Doku"
|
||||
Public Shared FilePath As String ' = "\\192.168.0.90\f\EDV-Wartung\Dokumentation"
|
||||
Public Shared Absender As String = "Absender Standard"
|
||||
'Public Shared sAppPath As String = Application.StartupPath
|
||||
Public Shared Standorte As New List(Of String)
|
||||
Public Shared AlleStandorte As New List(Of String)
|
||||
Public Shared LoggedOnUser As New cBenutzer
|
||||
Public Shared LoggedOnUserRights As New List(Of cBerechtigungen)
|
||||
Public Shared DebugMode As Boolean = False
|
||||
Public Shared GroupUsers As List(Of cBenutzer)
|
||||
|
||||
Public Shared Sub EnableDoubleBuffered(ByVal dgv As DataGridView)
|
||||
Dim dgvType As Type = dgv.[GetType]()
|
||||
@@ -19,6 +26,30 @@ Public Class Class1
|
||||
pi.SetValue(dgv, True, Nothing)
|
||||
End Sub
|
||||
|
||||
Public Shared Function CheckDebug()
|
||||
Dim Startparameter As String = ""
|
||||
Dim i As Integer
|
||||
For Each s As String In Environment.GetCommandLineArgs
|
||||
If i > 0 Then
|
||||
If s = "/d" Or s = "-d" Then
|
||||
Startparameter = "debug"
|
||||
Else
|
||||
End If
|
||||
End If
|
||||
i += 1
|
||||
Next
|
||||
|
||||
If Main.sAppPath Like "*\bin\Debug" Or Startparameter = "debug" Then
|
||||
DebugMode = True
|
||||
|
||||
Class1.DBConString = "Server=DEVELOPER\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
|
||||
Class1.FilePath = "\\192.168.0.253\backup\temp_Sebastian\DokuTest"
|
||||
Else
|
||||
Class1.DBConString = "Server=192.168.0.94\SQLEXPRESS;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
|
||||
Class1.FilePath = "\\192.168.0.90\f\EDV-Wartung\Dokumentation"
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Public Shared Function SQLnQ(command As String)
|
||||
|
||||
@@ -58,7 +58,7 @@ Public Class SQLVariable
|
||||
Private prim As Boolean
|
||||
|
||||
Public Sub New(ByVal btext As String, ByVal bvalue As String, Optional bprim As Boolean = False)
|
||||
Me.value = bvalue
|
||||
Me.Value = bvalue
|
||||
Me.Text = btext
|
||||
|
||||
End Sub
|
||||
|
||||
162
Dokumentation/Classes/cBenutzer.vb
Normal file
162
Dokumentation/Classes/cBenutzer.vb
Normal file
@@ -0,0 +1,162 @@
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class cBenutzer
|
||||
|
||||
|
||||
Property Name As String = ""
|
||||
Property userPrincipalName As String = ""
|
||||
Property Domäne As String = ""
|
||||
Property BenutzeranmeldeName As String = ""
|
||||
Property Nachname As String = ""
|
||||
Property Vorname As String = ""
|
||||
Property Mail As String = ""
|
||||
Property distinguishedName As String = ""
|
||||
Property cn As String = ""
|
||||
Property msDSPrincipalName As String = ""
|
||||
Property localdistinguishedName As String = ""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Function FillWithLoggedOnUser(Optional ByVal dcabfrage As Boolean = False)
|
||||
Try
|
||||
userPrincipalName = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName
|
||||
Name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.Name
|
||||
Catch
|
||||
End Try
|
||||
Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString
|
||||
BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName
|
||||
|
||||
If dcabfrage = True Then
|
||||
FillFromDC(userPrincipalName, "userPrincipalName")
|
||||
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
|
||||
|
||||
Dim FSlocDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
|
||||
Dim FSsearcher As New DirectoryServices.DirectorySearcher
|
||||
With FSsearcher
|
||||
.SearchRoot = FSlocDirectoryEntry
|
||||
.Filter = searchfilter & "=" & searchname
|
||||
.PropertiesToLoad.Add("msDS-PrincipalName")
|
||||
End With
|
||||
Dim FSResult As DirectoryServices.SearchResult = FSsearcher.FindOne
|
||||
searchname = blablabla(FSResult, "msDS-PrincipalName")
|
||||
Dim DomainName As String = searchname.Substring(0, searchname.IndexOf("\"))
|
||||
' MsgBox(DomainName)
|
||||
|
||||
Select Case DomainName
|
||||
Case "IMEX"
|
||||
Me.Domäne = "imex.local"
|
||||
LDAP = "LDAP://DC=IMEX,DC=LOCAL"
|
||||
'MsgBox("Me.Domäne = imex.local")
|
||||
Case "VERAGNEUHAUS"
|
||||
Me.Domäne = "VERAGNEUHAUS.local"
|
||||
LDAP = "LDAP://DC=VERAGNEUHAUS,DC=LOCAL"
|
||||
End Select
|
||||
searchname = searchname.Substring((searchname.IndexOf("\") + 1), searchname.Length - searchname.IndexOf("\") - 1)
|
||||
searchfilter = "sAMAccountName"
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
|
||||
' Dim Searcher1 As New DirectoryServices.DirectorySearcher(locDirectoryEntry, searchfilter & "=" & searchname)
|
||||
Dim searcher As New DirectoryServices.DirectorySearcher
|
||||
With searcher
|
||||
.SearchRoot = locDirectoryEntry
|
||||
.Filter = searchfilter & "=" & searchname
|
||||
' .ExtendedDN = True
|
||||
|
||||
.PropertiesToLoad.Add("sn")
|
||||
.PropertiesToLoad.Add("givenName")
|
||||
.PropertiesToLoad.Add("mail")
|
||||
.PropertiesToLoad.Add("distinguishedName")
|
||||
.PropertiesToLoad.Add("cn")
|
||||
.PropertiesToLoad.Add("distinguishedName")
|
||||
.PropertiesToLoad.Add("msDS-PrincipalName")
|
||||
.PropertiesToLoad.Add("userPrincipalName")
|
||||
|
||||
End With
|
||||
Dim Result As DirectoryServices.SearchResult = Searcher.FindOne
|
||||
|
||||
|
||||
Me.Nachname = blablabla(Result, "sn")
|
||||
Me.Vorname = blablabla(Result, "givenName")
|
||||
Me.Mail = blablabla(Result, "mail")
|
||||
Me.distinguishedName = blablabla(Result, "distinguishedName")
|
||||
Me.cn = blablabla(Result, "cn")
|
||||
Me.Name = blablabla(Result, "cn")
|
||||
Me.BenutzeranmeldeName = blablabla(Result, "msDS-PrincipalName")
|
||||
Me.msDSPrincipalName = blablabla(Result, "msDS-PrincipalName")
|
||||
Me.userPrincipalName = blablabla(Result, "userPrincipalName")
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("FillFromDC: " & ex.Message)
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Function isDokuAdmin() As Boolean
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("select * from TbL_Berechtigungen where Benutzeranmeldename = '" & Me.BenutzeranmeldeName & "' AND Standort = 'DokuAdmin'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
Function blablabla(result As DirectoryServices.SearchResult, Prop As String) As String
|
||||
|
||||
If result.Properties(Prop).Count = 0 Then
|
||||
Return ""
|
||||
Else
|
||||
Return result.Properties(Prop)(0)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Function emptyreturn(ByVal ding As String)
|
||||
If ding Is Nothing Then
|
||||
Return ""
|
||||
Else
|
||||
Return ding
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Class cBenutzergruppe
|
||||
|
||||
Public Shared Function GetUsersInGroup(ByVal groupname As String, Optional ByVal LDAP As String = "LDAP://DC=VERAG,DC=OST,DC=DMN") As List(Of String)
|
||||
Dim Userlist As New List(Of String)
|
||||
|
||||
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
|
||||
Dim Searcher As New DirectoryServices.DirectorySearcher(locDirectoryEntry, "sAMAccountName=" & groupname)
|
||||
Dim Result As DirectoryServices.SearchResult = Searcher.FindOne
|
||||
|
||||
If Result IsNot Nothing Then
|
||||
For Each User In Result.Properties("Member")
|
||||
Userlist.Add(User)
|
||||
Next
|
||||
End If
|
||||
Return Userlist
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
Public Class cSharedClasses
|
||||
Public Shared LoggedOnUser As New cBenutzer
|
||||
End Class
|
||||
124
Dokumentation/Classes/cBerechtigungen.vb
Normal file
124
Dokumentation/Classes/cBerechtigungen.vb
Normal file
@@ -0,0 +1,124 @@
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class cBerechtigungen
|
||||
|
||||
|
||||
Property Benutzeranmeldename As String = ""
|
||||
Property Standort As String = ""
|
||||
Property Zugriff As String = ""
|
||||
Property MeExist As Boolean = False
|
||||
Property ID As String = ""
|
||||
Property StandardZugriff = "0"
|
||||
|
||||
|
||||
Function getparameterlist() As List(Of SQLVariable)
|
||||
Dim list As New List(Of SQLVariable)
|
||||
list.Add(New SQLVariable("Benutzeranmeldename", Benutzeranmeldename))
|
||||
list.Add(New SQLVariable("Standort", Standort))
|
||||
list.Add(New SQLVariable("Zugriff", Zugriff))
|
||||
list.Add(New SQLVariable("ID", ID))
|
||||
Return list
|
||||
End Function
|
||||
|
||||
Public Function getFromSQL() '(ip As String)
|
||||
Dim ds As New DataSet
|
||||
Dim test As String = ""
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Berechtigungen WHERE BENUTZERANMELDENAME = '" & Benutzeranmeldename & "' AND Standort = '" & Standort & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
For Each c As DataColumn In ds.Tables(0).Columns
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
|
||||
If propInfo IsNot Nothing Then
|
||||
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
|
||||
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
Me.Zugriff = StandardZugriff
|
||||
End If
|
||||
|
||||
' MsgBox("hier")
|
||||
End Function
|
||||
|
||||
Function checkExist() '(ByVal ip As String)
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Berechtigungen WHERE BENUTZERANMELDENAME = '" & Benutzeranmeldename & "' AND Standort = '" & Standort & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
MeExist = True
|
||||
Return True
|
||||
Else
|
||||
MeExist = False
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function SaveToSQL()
|
||||
checkExist()
|
||||
If MeExist = True Then
|
||||
Dim update As String = ""
|
||||
Dim where As String = ""
|
||||
Dim list As List(Of SQLVariable) = getparameterlist()
|
||||
|
||||
For Each i In list ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''dieser Host
|
||||
If Not i.SQLText = "ID" Then
|
||||
update &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
Else
|
||||
where &= "ID = '" & i.SQLValue & "'"
|
||||
End If
|
||||
Next
|
||||
update = update.Substring(0, update.Length - 1)
|
||||
SQL.UpdateSQL("TbL_Berechtigungen", update, where)
|
||||
Else
|
||||
Me.ID = Guid.NewGuid().ToString("N")
|
||||
Dim Spalten As String = ""
|
||||
Dim Werte As String = ""
|
||||
Dim InsertString As String = ""
|
||||
Dim List As List(Of SQLVariable) = getparameterlist()
|
||||
For Each i In List
|
||||
' If Not i.SQLText = "Erstelldatum" Then
|
||||
Spalten &= i.SQLText & ","
|
||||
Werte &= "'" & i.SQLValue & "',"
|
||||
' End If
|
||||
Next
|
||||
Spalten = Spalten.Substring(0, Spalten.Length - 1)
|
||||
Werte = Werte.Substring(0, Werte.Length - 1)
|
||||
|
||||
SQL.InsertSQL("TbL_Berechtigungen", "(" & Spalten & ") VALUES (" & Werte & ")")
|
||||
MeExist = True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function ReadAll(ByVal Benutzeranmeldename As String) As List(Of cBerechtigungen)
|
||||
Try
|
||||
Dim ToR As New List(Of cBerechtigungen) ' ToR -> Table of Rights *Badum Tss*
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Berechtigungen WHERE BENUTZERANMELDENAME = '" & Benutzeranmeldename & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
For Each row As DataRow In ds.Tables(0).Rows
|
||||
Dim R As New cBerechtigungen
|
||||
R.Benutzeranmeldename = Benutzeranmeldename
|
||||
R.Standort = row.Item("Standort").ToString
|
||||
R.Zugriff = row.Item("Zugriff").ToString
|
||||
R.ID = row.Item("ID").ToString
|
||||
ToR.Add(R)
|
||||
Next
|
||||
End If
|
||||
Return ToR
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function BenutzerBerechtigungfuerStandort(ByVal Benutzer As String, ByVal Standort As String)
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("SELECT ZUGRIFF FROM TbL_Berechtigungen WHERE BENUTZERANMELDENAME = '" & Benutzer & "' AND Standort = '" & Standort & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
Return ds.Tables(0).Rows(0).Item(0).ToString
|
||||
Else
|
||||
MsgBox("Keine Berechtigung gefunden")
|
||||
Return "0"
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
121
Dokumentation/Classes/cEintrag.vb
Normal file
121
Dokumentation/Classes/cEintrag.vb
Normal file
@@ -0,0 +1,121 @@
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class cEintrag
|
||||
|
||||
Property rubrik As String = ""
|
||||
Property Titel As String = ""
|
||||
Property Info As String = ""
|
||||
Property Link As String = ""
|
||||
Property Benutzer As String = ""
|
||||
Property Passwort As String = ""
|
||||
Property Linked As Boolean = False
|
||||
Property LinkedWith As String = ""
|
||||
Property ID As String = ""
|
||||
|
||||
Property NewID As Boolean = False
|
||||
|
||||
Function getparameterlist() As List(Of SQLVariable)
|
||||
Dim list As New List(Of SQLVariable)
|
||||
list.Add(New SQLVariable("rubrik", rubrik))
|
||||
list.Add(New SQLVariable("Titel", Titel))
|
||||
list.Add(New SQLVariable("Info", Info))
|
||||
list.Add(New SQLVariable("Link", Link))
|
||||
list.Add(New SQLVariable("Benutzer", Benutzer))
|
||||
list.Add(New SQLVariable("Passwort", Passwort))
|
||||
list.Add(New SQLVariable("Linked", Linked))
|
||||
list.Add(New SQLVariable("LinkedWith", LinkedWith))
|
||||
list.Add(New SQLVariable("ID", ID))
|
||||
Return list
|
||||
End Function
|
||||
|
||||
Public Function getFromSQL() '(ip As String)
|
||||
Dim ds As New DataSet
|
||||
Dim test As String = ""
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Allgemein WHERE ID = '" & Me.ID & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
For Each c As DataColumn In ds.Tables(0).Columns
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
|
||||
If propInfo IsNot Nothing Then
|
||||
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
|
||||
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
ds.Clear()
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Allgemein WHERE Rubrik = '" & rubrik & "' AND Titel = '" & Titel & "'", ds)
|
||||
For Each c As DataColumn In ds.Tables(0).Columns
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
|
||||
If propInfo IsNot Nothing Then
|
||||
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
|
||||
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Me.ID = Guid.NewGuid().ToString("N") : NewID = True
|
||||
End If
|
||||
|
||||
' MsgBox("hier")
|
||||
End Function
|
||||
|
||||
Public Function Save()
|
||||
If checkExist() = False Then '----------------------------------------neuer Eintrag
|
||||
'' (Spalten, Spalten, ...) VALUES (Werte, Werte, ...)
|
||||
Me.ID = Guid.NewGuid().ToString("N")
|
||||
Dim Spalten As String = ""
|
||||
Dim Werte As String = ""
|
||||
Dim InsertString As String = ""
|
||||
Dim List As List(Of SQLVariable) = getparameterlist()
|
||||
For Each i In List
|
||||
Spalten &= i.SQLText & ","
|
||||
Werte &= "'" & i.SQLValue & "',"
|
||||
Next
|
||||
Spalten = Spalten.Substring(0, Spalten.Length - 1)
|
||||
Werte = Werte.Substring(0, Werte.Length - 1)
|
||||
|
||||
SQL.InsertSQL("TbL_Allgemein", "(" & Spalten & ") VALUES (" & Werte & ")")
|
||||
ElseIf checkExist() And NewID = True Then ''----------------------------------------bestehender Eintrag ohne ID
|
||||
Dim UpdateString As String = ""
|
||||
Dim WhereString As String = ""
|
||||
Dim list As List(Of SQLVariable) = getparameterlist()
|
||||
For Each i In list
|
||||
'If Not i.SQLText = "EssenCreateDate" Then
|
||||
UpdateString &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
'End If
|
||||
Next
|
||||
UpdateString = UpdateString.Substring(0, UpdateString.Length - 1) 'wg. ','
|
||||
|
||||
SQL.UpdateSQL("TbL_Allgemein", UpdateString, "Rubrik = '" & rubrik & "' AND Titel = '" & Titel & "'")
|
||||
NewID = False
|
||||
ElseIf checkExist() And NewID = False Then ''----------------------------------------bestehender Eintrag mit bestehender ID
|
||||
Dim UpdateString As String = ""
|
||||
Dim WhereString As String = ""
|
||||
Dim list As List(Of SQLVariable) = getparameterlist()
|
||||
For Each i In list
|
||||
If Not i.SQLText = "ID" Then
|
||||
UpdateString &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
|
||||
End If
|
||||
Next
|
||||
UpdateString = UpdateString.Substring(0, UpdateString.Length - 1) 'wg. ','
|
||||
|
||||
SQL.UpdateSQL("TbL_Allgemein", UpdateString, "ID = '" & ID & "'")
|
||||
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function checkExist() '(ByVal ip As String)
|
||||
Dim ds As New DataSet
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Allgemein WHERE ID = '" & Me.ID & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
Return True
|
||||
Else
|
||||
ds.Clear()
|
||||
SQL.SQL2DS("SELECT * FROM TbL_Allgemein WHERE Rubrik = '" & rubrik & "' AND Titel = '" & Titel & "'", ds)
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
3
Dokumentation/Classes/cGlobalVariables.vb
Normal file
3
Dokumentation/Classes/cGlobalVariables.vb
Normal file
@@ -0,0 +1,3 @@
|
||||
Public Class cGlobalVariables
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user