clean up, add config module, use logger module, use database module
This commit is contained in:
parent
c6f839bef8
commit
4f77749c9a
@ -9,12 +9,10 @@
|
|||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<add name="DDUserManager.My.MySettings.DD_ECMConnectionString"
|
<add name="DDUserManager.My.MySettings.DD_ECMConnectionString" connectionString="Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd" providerName="System.Data.SqlClient"/>
|
||||||
connectionString="Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd"
|
|
||||||
providerName="System.Data.SqlClient" />
|
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||||
</startup>
|
</startup>
|
||||||
<userSettings>
|
<userSettings>
|
||||||
<DDUserManager.My.MySettings>
|
<DDUserManager.My.MySettings>
|
||||||
|
|||||||
@ -1,67 +1,72 @@
|
|||||||
Imports DD_LIB_Standards
|
Imports DigitalData.Modules.Database
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
Public Class ClassData
|
Public Class ClassData
|
||||||
Public Sub New()
|
Private _logger As Logger
|
||||||
|
Private _database As MSSQLServer
|
||||||
|
|
||||||
|
Public Sub New(LogConfig As LogConfig, Database As MSSQLServer)
|
||||||
|
_logger = LogConfig.GetLogger()
|
||||||
|
_database = Database
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Shared Function IntToBool(int As Integer) As Boolean
|
Private Function IntToBool(int As Integer) As Boolean
|
||||||
Return int >= 1
|
Return int >= 1
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Shared Function BoolToInt(bool As Boolean) As Integer
|
Private Function BoolToInt(bool As Boolean) As Integer
|
||||||
Return IIf(bool, 1, 0)
|
Return IIf(bool, 1, 0)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function GroupExists(groupName As String) As Boolean
|
Public Function GroupExists(groupName As String) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim sql As String = $"SELECT COUNT(GUID) FROM TBDD_GROUPS WHERE NAME = '{groupName}'"
|
Dim sql As String = $"SELECT COUNT(GUID) FROM TBDD_GROUPS WHERE NAME = '{groupName}'"
|
||||||
Dim result = clsDatabase.Execute_Scalar(sql)
|
Dim result = _database.GetScalarValue(sql)
|
||||||
|
|
||||||
Return IntToBool(result)
|
Return IntToBool(result)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
clsLogger.Add($"Error in GroupExists: {ex.Message}")
|
_logger.Error($"Error in GroupExists: {ex.Message}")
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function UserExists(userName As String) As Boolean
|
Public Function UserExists(userName As String) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim sql As String = $"SELECT COUNT(GUID) FROM TBDD_USER WHERE USERNAME = '{userName}'"
|
Dim sql As String = $"SELECT COUNT(GUID) FROM TBDD_USER WHERE USERNAME = '{userName}'"
|
||||||
Dim result = clsDatabase.Execute_Scalar(sql)
|
Dim result = _database.GetScalarValue(sql)
|
||||||
|
|
||||||
Return IntToBool(result)
|
Return IntToBool(result)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
clsLogger.Add($"Error in UserExists: {ex.Message}")
|
_logger.Error($"Error in UserExists: {ex.Message}")
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function InsertUser(username As String, prename As String, name As String, email As String)
|
Public Function InsertUser(username As String, prename As String, name As String, email As String)
|
||||||
Try
|
Try
|
||||||
Dim addedWho As String = Environment.UserName
|
Dim addedWho As String = Environment.UserName
|
||||||
|
|
||||||
Dim sql As String = $"INSERT INTO TBDD_USER (PRENAME, NAME, USERNAME, EMAIL, ADDED_WHO)
|
Dim sql As String = $"INSERT INTO TBDD_USER (PRENAME, NAME, USERNAME, EMAIL, ADDED_WHO)
|
||||||
VALUES ('{prename}','{name}','{username}','{email}','{addedWho}')"
|
VALUES ('{prename}','{name}','{username}','{email}','{addedWho}')"
|
||||||
Dim result = clsDatabase.Execute_non_Query(sql)
|
Dim result = _database.ExecuteNonQuery(sql)
|
||||||
|
|
||||||
Return True
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
clsLogger.Add($"Error in InsertUser: {ex.Message}")
|
_logger.Error(ex)
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function InsertGroup(name As String, Optional ECM_FK_ID As Integer = 1, Optional adSync As Boolean = True, Optional internal As Boolean = False, Optional active As Boolean = True)
|
Public Function InsertGroup(name As String, Optional ECM_FK_ID As Integer = 1, Optional adSync As Boolean = True, Optional internal As Boolean = False, Optional active As Boolean = True)
|
||||||
Try
|
Try
|
||||||
Dim addedWho As String = Environment.UserName
|
Dim addedWho As String = Environment.UserName
|
||||||
Dim sql As String = $"INSERT INTO TBDD_GROUPS (NAME, ADDED_WHO, ECM_FK_ID, AD_SYNC, INTERNAL, ACTIVE)
|
Dim sql As String = $"INSERT INTO TBDD_GROUPS (NAME, ADDED_WHO, ECM_FK_ID, AD_SYNC, INTERNAL, ACTIVE)
|
||||||
VALUES ('{name}', '{addedWho}', {ECM_FK_ID}, {BoolToInt(adSync)}, {BoolToInt(internal)}, {BoolToInt(active)} )"
|
VALUES ('{name}', '{addedWho}', {ECM_FK_ID}, {BoolToInt(adSync)}, {BoolToInt(internal)}, {BoolToInt(active)} )"
|
||||||
Dim result = clsDatabase.Execute_non_Query(sql)
|
Dim result = _database.ExecuteNonQuery(sql)
|
||||||
|
|
||||||
Return True
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
clsLogger.Add($"Error in InsertGroup: {ex.Message}")
|
_logger.Error(ex)
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
<AssemblyName>DDUserManager</AssemblyName>
|
<AssemblyName>DDUserManager</AssemblyName>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<MyType>WindowsForms</MyType>
|
<MyType>WindowsForms</MyType>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -51,9 +51,6 @@
|
|||||||
<ApplicationIcon>user.ico</ApplicationIcon>
|
<ApplicationIcon>user.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="DD_LIB_Standards">
|
|
||||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\DD_LIB_Standards.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="DevExpress.Data.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
<Reference Include="DevExpress.Data.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||||
<Reference Include="DevExpress.Printing.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
<Reference Include="DevExpress.Printing.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||||
<Reference Include="DevExpress.Sparkline.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
<Reference Include="DevExpress.Sparkline.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||||
@ -62,6 +59,21 @@
|
|||||||
<Reference Include="DevExpress.XtraGrid.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
<Reference Include="DevExpress.XtraGrid.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||||
<Reference Include="DevExpress.XtraLayout.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
<Reference Include="DevExpress.XtraLayout.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||||
<Reference Include="DevExpress.XtraPrinting.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
<Reference Include="DevExpress.XtraPrinting.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||||
|
<Reference Include="DigitalData.Modules.Config">
|
||||||
|
<HintPath>..\..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="DigitalData.Modules.Database">
|
||||||
|
<HintPath>..\..\..\DDMonorepo\Modules.Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="DigitalData.Modules.Filesystem">
|
||||||
|
<HintPath>..\..\..\DDMonorepo\Modules.Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="DigitalData.Modules.Interfaces">
|
||||||
|
<HintPath>..\..\..\DDMonorepo\Modules.Interfaces\bin\Debug\DigitalData.Modules.Interfaces.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="DigitalData.Modules.Logging">
|
||||||
|
<HintPath>..\..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NLog">
|
<Reference Include="NLog">
|
||||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\NLog\NLog.dll</HintPath>
|
<HintPath>P:\Visual Studio Projekte\Bibliotheken\NLog\NLog.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -152,6 +164,7 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UserConfig.vb" />
|
||||||
<Compile Include="UserDataSet.Designer.vb">
|
<Compile Include="UserDataSet.Designer.vb">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|||||||
@ -1,160 +1,17 @@
|
|||||||
Imports System.IO
|
Imports System.IO
|
||||||
Imports DD_LIB_Standards
|
Imports DigitalData.Modules.Config
|
||||||
|
Imports DigitalData.Modules.Database
|
||||||
|
Imports DigitalData.Modules.Filesystem
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
Module ModuleRuntime
|
Module ModuleRuntime
|
||||||
Public MyConnectionString As String
|
Public MyConnectionString As String
|
||||||
|
Public MyDatabase As MSSQLServer
|
||||||
|
Public MyLogConfig As LogConfig
|
||||||
|
Public MyLogger As Logger
|
||||||
|
Public MyConfig As ConfigManager(Of UserConfig)
|
||||||
|
|
||||||
Public LogErrorsOnly As Boolean = True
|
Public LogErrorsOnly As Boolean = True
|
||||||
Public ConfigPath As String = Path.Combine(Application.UserAppDataPath, "UserConfig.xml")
|
Public ConfigPath As String = Path.Combine(Application.UserAppDataPath, "UserConfig.xml")
|
||||||
Public ActiveDirectoryRootNode As String = $"LDAP://{Environment.UserDomainName}"
|
Public ActiveDirectoryRootNode As String = $"LDAP://{Environment.UserDomainName}"
|
||||||
|
|
||||||
Public Function SaveMySettingsValue(name As String, value As String, type As String)
|
|
||||||
Try
|
|
||||||
Dim DT As DataTable = Nothing
|
|
||||||
If type = "ConfigMain" Then
|
|
||||||
DT = GetTablefromXML(ConfigPath)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not IsNothing(DT) Then
|
|
||||||
For Each Row As DataRow In DT.Rows
|
|
||||||
If Row.Item("ConfigName") = name Then
|
|
||||||
Row.Item("Value") = value
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
DT.AcceptChanges()
|
|
||||||
DT.WriteXml(ConfigPath)
|
|
||||||
Else
|
|
||||||
MsgBox("Setting could not be saved! Check logfile.", MsgBoxStyle.Critical)
|
|
||||||
End If
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
MsgBox("Error in SaveConfigValue" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
Return True
|
|
||||||
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function GetTablefromXML(path As String) As DataTable
|
|
||||||
Try
|
|
||||||
Dim DS As New DataSet
|
|
||||||
DS.ReadXml(path)
|
|
||||||
Return DS.Tables(0)
|
|
||||||
Catch ex As Exception
|
|
||||||
MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message & vbNewLine & "ConfigPath: " & vbNewLine & path, MsgBoxStyle.Critical)
|
|
||||||
clsLogger.Add("Error in GetTablefromXML: " & ex.Message, True)
|
|
||||||
clsLogger.Add(">> ConfigPath: " & ConfigPath, False)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function MySettings_Load()
|
|
||||||
Try
|
|
||||||
Dim DT As DataTable
|
|
||||||
'if file doesn't exist, create the file with its default xml table
|
|
||||||
If Not File.Exists(ConfigPath) Then
|
|
||||||
clsLogger.Add(">> ConfigFile was created in: " & ConfigPath, False)
|
|
||||||
DT = CreateConfigTable()
|
|
||||||
DT.WriteXml(ConfigPath)
|
|
||||||
clsLogger.Add(">> Defaultvalues were saved.", False)
|
|
||||||
End If
|
|
||||||
DT = GetTablefromXML(ConfigPath)
|
|
||||||
If DT Is Nothing Then
|
|
||||||
MsgBox("Configuration could not be loaded!! Check LogFile!", MsgBoxStyle.Critical)
|
|
||||||
Return False
|
|
||||||
End If
|
|
||||||
For Each Row As DataRow In DT.Rows
|
|
||||||
Select Case Row.Item("ConfigName")
|
|
||||||
Case "MyConnectionString"
|
|
||||||
Dim connstring As String
|
|
||||||
'Den ConnectonString mit verschlüsseltem PW laden
|
|
||||||
Dim csb As New SqlClient.SqlConnectionStringBuilder
|
|
||||||
csb.ConnectionString = Row.Item("Value")
|
|
||||||
If Not csb.ConnectionString = "" Then
|
|
||||||
If csb.ConnectionString.Contains("Password=") Then
|
|
||||||
'sa-
|
|
||||||
'Jetzt das Passwort entschlüsseln
|
|
||||||
Dim PWplainText As String
|
|
||||||
Dim wrapper As New clsEncryption("!35452didalog=")
|
|
||||||
' DecryptData throws if the wrong password is used.
|
|
||||||
Try
|
|
||||||
PWplainText = wrapper.DecryptData(csb.Password)
|
|
||||||
connstring = Row.Item("Value").ToString.Replace(csb.Password, PWplainText)
|
|
||||||
Catch ex As Exception
|
|
||||||
clsLogger.Add("- the Password '" & csb.Password & "' could not be decrypted", False)
|
|
||||||
connstring = ""
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Else
|
|
||||||
'Windows-Auth
|
|
||||||
connstring = Row.Item("Value").ToString
|
|
||||||
End If
|
|
||||||
|
|
||||||
MyConnectionString = connstring
|
|
||||||
Else
|
|
||||||
MyConnectionString = ""
|
|
||||||
End If
|
|
||||||
Case "LogErrorsOnly"
|
|
||||||
LogErrorsOnly = CBool(Row.Item("Value"))
|
|
||||||
Case "ActiveDirectoryRootNode"
|
|
||||||
Dim rootNode As String = Row.Item("Value")
|
|
||||||
|
|
||||||
If rootNode <> String.Empty Then
|
|
||||||
ActiveDirectoryRootNode = rootNode
|
|
||||||
End If
|
|
||||||
End Select
|
|
||||||
Next
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
MsgBox("Error in LoadMyConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
|
||||||
clsLogger.Add("Error in LoadMyConfig: " & ex.Message, True)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
Return True
|
|
||||||
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function CreateConfigTable() As DataTable
|
|
||||||
Try
|
|
||||||
' Create sample Customers table, in order
|
|
||||||
' to demonstrate the behavior of the DataTableReader.
|
|
||||||
Dim table As New DataTable
|
|
||||||
table.TableName = "MyConfig"
|
|
||||||
|
|
||||||
' Create two columns, ID and Name.
|
|
||||||
Dim idColumn As DataColumn = table.Columns.Add("ID",
|
|
||||||
GetType(System.Int32))
|
|
||||||
|
|
||||||
idColumn.AutoIncrement = True
|
|
||||||
idColumn.AutoIncrementSeed = 0
|
|
||||||
idColumn.AutoIncrementStep = 1
|
|
||||||
table.Columns.Add("ConfigName", GetType(System.String))
|
|
||||||
table.Columns.Add("Value", GetType(System.String))
|
|
||||||
'Set the ID column as the primary key column.
|
|
||||||
table.PrimaryKey = New DataColumn() {idColumn}
|
|
||||||
|
|
||||||
Dim newRow As DataRow
|
|
||||||
|
|
||||||
newRow = table.NewRow()
|
|
||||||
newRow.Item("ConfigName") = "MyConnectionString"
|
|
||||||
newRow.Item("Value") = ""
|
|
||||||
table.Rows.Add(newRow)
|
|
||||||
|
|
||||||
newRow = table.NewRow()
|
|
||||||
newRow.Item("ConfigName") = "LogErrorsOnly"
|
|
||||||
newRow.Item("Value") = "True"
|
|
||||||
table.Rows.Add(newRow)
|
|
||||||
|
|
||||||
newRow = table.NewRow()
|
|
||||||
newRow.Item("ConfigName") = "ActiveDirectoryRootNode"
|
|
||||||
newRow.Item("Value") = ""
|
|
||||||
table.Rows.Add(newRow)
|
|
||||||
|
|
||||||
table.AcceptChanges()
|
|
||||||
clsLogger.Add(">> CreateConfigTable su...", False)
|
|
||||||
Return table
|
|
||||||
Catch ex As Exception
|
|
||||||
MsgBox("Error in CreateConfigTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Module
|
End Module
|
||||||
|
|||||||
11
DDUserManager/DDUserManager/UserConfig.vb
Normal file
11
DDUserManager/DDUserManager/UserConfig.vb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Imports DigitalData.Modules.Config
|
||||||
|
Imports DigitalData.Modules.Filesystem
|
||||||
|
|
||||||
|
Public Class UserConfig
|
||||||
|
<ConfigAttributes.ConnectionString>
|
||||||
|
Public Property ConnectionString As String = ""
|
||||||
|
Public Property LogErrorsOnly As Boolean = True
|
||||||
|
Public Property AdGroupFilter As String = "(&(objectClass=group) (samAccountName=*))"
|
||||||
|
Public Property AdUserFilter As String = ""
|
||||||
|
Public Property ActiveDirectoryRootNode As String = $"LDAP://{Environment.UserDomainName}"
|
||||||
|
End Class
|
||||||
@ -1,10 +1,15 @@
|
|||||||
Imports DevExpress.XtraGrid.Views.Grid
|
Imports DevExpress.XtraGrid.Views.Grid
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
Public Class frmADImport_Groups
|
Public Class frmADImport_Groups
|
||||||
Private Shared logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger()
|
Private logger As Logger
|
||||||
|
Private data As ClassData
|
||||||
|
|
||||||
Private Sub frmADImport_Groups_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub frmADImport_Groups_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
Try
|
Try
|
||||||
|
logger = MyLogConfig.GetLogger()
|
||||||
|
data = New ClassData(MyLogConfig, MyDatabase)
|
||||||
|
|
||||||
Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(My.Settings.AD_GROUP_QUERY)
|
Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(My.Settings.AD_GROUP_QUERY)
|
||||||
|
|
||||||
logger.Info("Found {0} groups", groups.Count)
|
logger.Info("Found {0} groups", groups.Count)
|
||||||
@ -36,8 +41,8 @@ Public Class frmADImport_Groups
|
|||||||
Dim internal As Boolean = False
|
Dim internal As Boolean = False
|
||||||
Dim sync As Boolean = True
|
Dim sync As Boolean = True
|
||||||
|
|
||||||
If Not ClassData.GroupExists(groupRow.GROUPNAME) Then
|
If Not data.GroupExists(groupRow.GROUPNAME) Then
|
||||||
ClassData.InsertGroup(groupRow.GROUPNAME)
|
data.InsertGroup(groupRow.GROUPNAME)
|
||||||
importedGroups = importedGroups + 1
|
importedGroups = importedGroups + 1
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|||||||
@ -1,15 +1,18 @@
|
|||||||
Imports System.DirectoryServices
|
Imports DDUserManager.UserDataSet
|
||||||
Imports System.DirectoryServices.AccountManagement
|
|
||||||
Imports DDUserManager.UserDataSet
|
|
||||||
Imports DevExpress.XtraGrid.Views.Grid
|
Imports DevExpress.XtraGrid.Views.Grid
|
||||||
Imports DD_LIB_Standards
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
Public Class frmADImport_Users
|
Public Class frmADImport_Users
|
||||||
|
|
||||||
Private Shared logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger()
|
Private logger As Logger
|
||||||
|
Private data As ClassData
|
||||||
|
|
||||||
|
|
||||||
Private Sub frmADImport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub frmADImport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
Try
|
Try
|
||||||
|
logger = MyLogConfig.GetLogger()
|
||||||
|
data = New ClassData(MyLogConfig, MyDatabase)
|
||||||
|
|
||||||
Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(My.Settings.AD_GROUP_QUERY)
|
Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(My.Settings.AD_GROUP_QUERY)
|
||||||
|
|
||||||
gridAD_Groups.DataSource = groups.Select(Of String)(Function(g)
|
gridAD_Groups.DataSource = groups.Select(Of String)(Function(g)
|
||||||
@ -63,8 +66,8 @@ Public Class frmADImport_Users
|
|||||||
Dim Email As String = IIf(IsDBNull(userRow.EMAIL), Nothing, userRow.EMAIL)
|
Dim Email As String = IIf(IsDBNull(userRow.EMAIL), Nothing, userRow.EMAIL)
|
||||||
|
|
||||||
|
|
||||||
If Not ClassData.UserExists(Username) Then
|
If Not data.UserExists(Username) Then
|
||||||
If ClassData.InsertUser(Username, Prename, Name, Email) Then
|
If data.InsertUser(Username, Prename, Name, Email) Then
|
||||||
importedUsers = importedUsers + 1
|
importedUsers = importedUsers + 1
|
||||||
Else
|
Else
|
||||||
Throw New Exception($"Could not insert user {Username} into Database. Check the log.")
|
Throw New Exception($"Could not insert user {Username} into Database. Check the log.")
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
Imports System.IO
|
Imports DigitalData.Modules.Database
|
||||||
Imports DD_LIB_Standards
|
Imports DigitalData.Modules.Filesystem
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
Public Class frmConfigDatabase
|
Public Class frmConfigDatabase
|
||||||
|
|
||||||
Private ConnectionChanged As Boolean = False
|
Private ConnectionChanged As Boolean = False
|
||||||
|
|
||||||
Private Sub frmConfigDatabase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub frmConfigDatabase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
|
If MyLogConfig Is Nothing Then
|
||||||
|
MyLogConfig = New LogConfig(LogConfig.PathType.AppData)
|
||||||
|
End If
|
||||||
|
|
||||||
If Not MyConnectionString = String.Empty Then
|
If Not MyConnectionString = String.Empty Then
|
||||||
ConnectionChanged = False
|
ConnectionChanged = False
|
||||||
|
|
||||||
@ -95,17 +100,21 @@ Public Class frmConfigDatabase
|
|||||||
ConnectionChanged = True
|
ConnectionChanged = True
|
||||||
'Set the construction string
|
'Set the construction string
|
||||||
MyConnectionString = con
|
MyConnectionString = con
|
||||||
clsDatabase.Init(MyConnectionString)
|
|
||||||
|
|
||||||
|
MyDatabase = New MSSQLServer(MyLogConfig, MyConnectionString)
|
||||||
|
|
||||||
My.Settings.Save()
|
My.Settings.Save()
|
||||||
|
|
||||||
If chkbxUserAut.Checked = False Then
|
If chkbxUserAut.Checked = False Then
|
||||||
Dim wrapper As New clsEncryption("!35452didalog=")
|
Dim wrapper As New EncryptionLegacy("!35452didalog=")
|
||||||
Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text)
|
Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text)
|
||||||
Dim pw As String = cipherText
|
Dim pw As String = cipherText
|
||||||
con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
|
con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
SaveMySettingsValue("MyConnectionString", con, "ConfigMain")
|
MyConfig.Config.ConnectionString = con
|
||||||
|
MyConfig.Save()
|
||||||
|
|
||||||
Dim csb As New SqlClient.SqlConnectionStringBuilder
|
Dim csb As New SqlClient.SqlConnectionStringBuilder
|
||||||
csb.ConnectionString = MyConnectionString
|
csb.ConnectionString = MyConnectionString
|
||||||
|
|||||||
66
DDUserManager/DDUserManager/frmMain.Designer.vb
generated
66
DDUserManager/DDUserManager/frmMain.Designer.vb
generated
@ -356,6 +356,11 @@ Partial Class frmMain
|
|||||||
Me.TableAdapterManager1 = New DDUserManager.DS_ChangeSTableAdapters.TableAdapterManager()
|
Me.TableAdapterManager1 = New DDUserManager.DS_ChangeSTableAdapters.TableAdapterManager()
|
||||||
Me.TBDD_GROUPS_USERTableAdapter = New DDUserManager.UserDataSetTableAdapters.TBDD_GROUPS_USERTableAdapter()
|
Me.TBDD_GROUPS_USERTableAdapter = New DDUserManager.UserDataSetTableAdapters.TBDD_GROUPS_USERTableAdapter()
|
||||||
Me.QueriesTableAdapter1 = New DDUserManager.UserDataSetTableAdapters.QueriesTableAdapter()
|
Me.QueriesTableAdapter1 = New DDUserManager.UserDataSetTableAdapters.QueriesTableAdapter()
|
||||||
|
Me.Button3 = New System.Windows.Forms.Button()
|
||||||
|
Me.GroupBox3 = New System.Windows.Forms.GroupBox()
|
||||||
|
Me.Button4 = New System.Windows.Forms.Button()
|
||||||
|
Me.txtLDAPUserQuery = New System.Windows.Forms.TextBox()
|
||||||
|
Me.Button5 = New System.Windows.Forms.Button()
|
||||||
GUIDLabel = New System.Windows.Forms.Label()
|
GUIDLabel = New System.Windows.Forms.Label()
|
||||||
PRENAMELabel = New System.Windows.Forms.Label()
|
PRENAMELabel = New System.Windows.Forms.Label()
|
||||||
NAMELabel = New System.Windows.Forms.Label()
|
NAMELabel = New System.Windows.Forms.Label()
|
||||||
@ -517,6 +522,7 @@ Partial Class frmMain
|
|||||||
CType(Me.TBDD_CLIENT_USERBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.TBDD_CLIENT_USERBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(Me.TBDD_USER_MODULESBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.TBDD_USER_MODULESBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
Me.StatusStrip1.SuspendLayout()
|
Me.StatusStrip1.SuspendLayout()
|
||||||
|
Me.GroupBox3.SuspendLayout()
|
||||||
Me.SuspendLayout()
|
Me.SuspendLayout()
|
||||||
'
|
'
|
||||||
'GUIDLabel
|
'GUIDLabel
|
||||||
@ -3500,6 +3506,7 @@ Partial Class frmMain
|
|||||||
'tabPageSettings
|
'tabPageSettings
|
||||||
'
|
'
|
||||||
Me.tabPageSettings.Controls.Add(Me.Button2)
|
Me.tabPageSettings.Controls.Add(Me.Button2)
|
||||||
|
Me.tabPageSettings.Controls.Add(Me.GroupBox3)
|
||||||
Me.tabPageSettings.Controls.Add(Me.GroupBox2)
|
Me.tabPageSettings.Controls.Add(Me.GroupBox2)
|
||||||
Me.tabPageSettings.Controls.Add(Me.GroupBox1)
|
Me.tabPageSettings.Controls.Add(Me.GroupBox1)
|
||||||
Me.tabPageSettings.Controls.Add(Me.btnOpenLogDir)
|
Me.tabPageSettings.Controls.Add(Me.btnOpenLogDir)
|
||||||
@ -3523,6 +3530,7 @@ Partial Class frmMain
|
|||||||
'
|
'
|
||||||
'GroupBox2
|
'GroupBox2
|
||||||
'
|
'
|
||||||
|
Me.GroupBox2.Controls.Add(Me.Button3)
|
||||||
Me.GroupBox2.Controls.Add(Me.btnDebugGroupQuery)
|
Me.GroupBox2.Controls.Add(Me.btnDebugGroupQuery)
|
||||||
Me.GroupBox2.Controls.Add(Me.txtLDAPGroupQuery)
|
Me.GroupBox2.Controls.Add(Me.txtLDAPGroupQuery)
|
||||||
Me.GroupBox2.Location = New System.Drawing.Point(486, 17)
|
Me.GroupBox2.Location = New System.Drawing.Point(486, 17)
|
||||||
@ -3530,7 +3538,7 @@ Partial Class frmMain
|
|||||||
Me.GroupBox2.Size = New System.Drawing.Size(700, 200)
|
Me.GroupBox2.Size = New System.Drawing.Size(700, 200)
|
||||||
Me.GroupBox2.TabIndex = 5
|
Me.GroupBox2.TabIndex = 5
|
||||||
Me.GroupBox2.TabStop = False
|
Me.GroupBox2.TabStop = False
|
||||||
Me.GroupBox2.Text = "LDAP Gruppenabfrage"
|
Me.GroupBox2.Text = "LDAP Filter für Gruppenabfrage"
|
||||||
'
|
'
|
||||||
'btnDebugGroupQuery
|
'btnDebugGroupQuery
|
||||||
'
|
'
|
||||||
@ -3730,6 +3738,55 @@ Partial Class frmMain
|
|||||||
'
|
'
|
||||||
Me.TBDD_GROUPS_USERTableAdapter.ClearBeforeFill = True
|
Me.TBDD_GROUPS_USERTableAdapter.ClearBeforeFill = True
|
||||||
'
|
'
|
||||||
|
'Button3
|
||||||
|
'
|
||||||
|
Me.Button3.Location = New System.Drawing.Point(438, 171)
|
||||||
|
Me.Button3.Name = "Button3"
|
||||||
|
Me.Button3.Size = New System.Drawing.Size(112, 23)
|
||||||
|
Me.Button3.TabIndex = 7
|
||||||
|
Me.Button3.Text = "Speichern"
|
||||||
|
Me.Button3.UseVisualStyleBackColor = True
|
||||||
|
'
|
||||||
|
'GroupBox3
|
||||||
|
'
|
||||||
|
Me.GroupBox3.Controls.Add(Me.Button4)
|
||||||
|
Me.GroupBox3.Controls.Add(Me.Button5)
|
||||||
|
Me.GroupBox3.Controls.Add(Me.txtLDAPUserQuery)
|
||||||
|
Me.GroupBox3.Location = New System.Drawing.Point(486, 239)
|
||||||
|
Me.GroupBox3.Name = "GroupBox3"
|
||||||
|
Me.GroupBox3.Size = New System.Drawing.Size(700, 200)
|
||||||
|
Me.GroupBox3.TabIndex = 5
|
||||||
|
Me.GroupBox3.TabStop = False
|
||||||
|
Me.GroupBox3.Text = "LDAP Filter für Benutzerabfrage"
|
||||||
|
'
|
||||||
|
'Button4
|
||||||
|
'
|
||||||
|
Me.Button4.Location = New System.Drawing.Point(438, 171)
|
||||||
|
Me.Button4.Name = "Button4"
|
||||||
|
Me.Button4.Size = New System.Drawing.Size(112, 23)
|
||||||
|
Me.Button4.TabIndex = 7
|
||||||
|
Me.Button4.Text = "Speichern"
|
||||||
|
Me.Button4.UseVisualStyleBackColor = True
|
||||||
|
'
|
||||||
|
'txtLDAPUserQuery
|
||||||
|
'
|
||||||
|
Me.txtLDAPUserQuery.Location = New System.Drawing.Point(6, 20)
|
||||||
|
Me.txtLDAPUserQuery.Multiline = True
|
||||||
|
Me.txtLDAPUserQuery.Name = "txtLDAPUserQuery"
|
||||||
|
Me.txtLDAPUserQuery.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
|
||||||
|
Me.txtLDAPUserQuery.Size = New System.Drawing.Size(688, 145)
|
||||||
|
Me.txtLDAPUserQuery.TabIndex = 2
|
||||||
|
Me.txtLDAPUserQuery.Text = "(&(objectClass=group) (samAccountName=*))"
|
||||||
|
'
|
||||||
|
'Button5
|
||||||
|
'
|
||||||
|
Me.Button5.Location = New System.Drawing.Point(556, 171)
|
||||||
|
Me.Button5.Name = "Button5"
|
||||||
|
Me.Button5.Size = New System.Drawing.Size(138, 23)
|
||||||
|
Me.Button5.TabIndex = 6
|
||||||
|
Me.Button5.Text = "Abfrage starten"
|
||||||
|
Me.Button5.UseVisualStyleBackColor = True
|
||||||
|
'
|
||||||
'frmMain
|
'frmMain
|
||||||
'
|
'
|
||||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||||
@ -3884,6 +3941,8 @@ Partial Class frmMain
|
|||||||
CType(Me.TBDD_USER_MODULESBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
|
CType(Me.TBDD_USER_MODULESBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
|
||||||
Me.StatusStrip1.ResumeLayout(False)
|
Me.StatusStrip1.ResumeLayout(False)
|
||||||
Me.StatusStrip1.PerformLayout()
|
Me.StatusStrip1.PerformLayout()
|
||||||
|
Me.GroupBox3.ResumeLayout(False)
|
||||||
|
Me.GroupBox3.PerformLayout()
|
||||||
Me.ResumeLayout(False)
|
Me.ResumeLayout(False)
|
||||||
Me.PerformLayout()
|
Me.PerformLayout()
|
||||||
|
|
||||||
@ -4189,4 +4248,9 @@ Partial Class frmMain
|
|||||||
Friend WithEvents btnDebugGroupQuery As Button
|
Friend WithEvents btnDebugGroupQuery As Button
|
||||||
Friend WithEvents txtLDAPGroupQuery As TextBox
|
Friend WithEvents txtLDAPGroupQuery As TextBox
|
||||||
Friend WithEvents QueriesTableAdapter1 As UserDataSetTableAdapters.QueriesTableAdapter
|
Friend WithEvents QueriesTableAdapter1 As UserDataSetTableAdapters.QueriesTableAdapter
|
||||||
|
Friend WithEvents Button3 As Button
|
||||||
|
Friend WithEvents GroupBox3 As GroupBox
|
||||||
|
Friend WithEvents Button4 As Button
|
||||||
|
Friend WithEvents txtLDAPUserQuery As TextBox
|
||||||
|
Friend WithEvents Button5 As Button
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
Imports DevExpress.XtraGrid
|
Imports DevExpress.XtraGrid
|
||||||
Imports DevExpress.XtraGrid.Views.Grid
|
Imports DevExpress.XtraGrid.Views.Grid
|
||||||
Imports DDUserManager.UserDataSet
|
Imports DDUserManager.UserDataSet
|
||||||
Imports DDUserManager.DS_ChangeS
|
Imports DigitalData.Modules.Logging
|
||||||
Imports DD_LIB_Standards
|
Imports DigitalData.Modules.Config
|
||||||
Imports System.Reflection
|
Imports System.Reflection
|
||||||
|
Imports DigitalData.Modules.Filesystem
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Anmerkungen:
|
''' Anmerkungen:
|
||||||
@ -19,32 +20,32 @@ Public Class frmMain
|
|||||||
|
|
||||||
Private DragDropManager As ClassDragDrop = Nothing
|
Private DragDropManager As ClassDragDrop = Nothing
|
||||||
|
|
||||||
Private Shared logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger()
|
|
||||||
|
|
||||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
Try
|
Try
|
||||||
NLog.LogManager.Configuration = ClassNLog.GetLoggerConfigFor(MODULE_NAME)
|
MyLogConfig = New LogConfig(LogConfig.PathType.AppData)
|
||||||
|
MyLogger = MyLogConfig.GetLogger()
|
||||||
|
MyConfig = New ConfigManager(Of UserConfig)(MyLogConfig, Application.UserAppDataPath)
|
||||||
|
|
||||||
|
LoadConfig(MyConfig)
|
||||||
|
|
||||||
CurrentVersion = Assembly.GetEntryAssembly().GetName().Version.ToString()
|
CurrentVersion = Assembly.GetEntryAssembly().GetName().Version.ToString()
|
||||||
|
|
||||||
txtLDAPGroupQuery.DataBindings.Add(New Binding("Text", My.Settings, "AD_GROUP_QUERY"))
|
txtLDAPGroupQuery.DataBindings.Add(New Binding("Text", My.Settings, "AD_GROUP_QUERY"))
|
||||||
|
|
||||||
|
MyLogger.Info("Starting UserManager v" & CurrentVersion)
|
||||||
|
MyLogger.Info($"Current Username: {Environment.UserName}")
|
||||||
|
|
||||||
logger.Info("Starting UserManager v" & CurrentVersion)
|
|
||||||
logger.Info($"Current Username: {Environment.UserName}")
|
|
||||||
|
|
||||||
If InitDatabase() = False Then
|
|
||||||
MsgBox($"Unexpected error in Database Init(1). {vbCrLf & vbCrLf}Please contact Your admin.", MsgBoxStyle.Critical, "UserManager")
|
|
||||||
logger.Fatal($"Unexpected error in Database Init(1). {vbCrLf & vbCrLf}Please contact Your admin.")
|
|
||||||
Application.Exit()
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
If MyConnectionString = "" Then
|
If MyConnectionString = "" Then
|
||||||
MsgBox($"Unexpected error in Database Init(2). {vbCrLf & vbCrLf}Please contact Your admin.", MsgBoxStyle.Critical, "UserManager")
|
frmConfigDatabase.ShowDialog()
|
||||||
logger.Fatal($"Unexpected error in Database Init(2). {vbCrLf & vbCrLf}Please contact Your admin.")
|
|
||||||
|
'MsgBox($"Unexpected error in Database Init(2). {vbCrLf & vbCrLf}Please contact Your admin.", MsgBoxStyle.Critical, "UserManager")
|
||||||
|
'MyLogger.Error($"Unexpected error in Database Init(2). {vbCrLf & vbCrLf}Please contact Your admin.")
|
||||||
Application.Exit()
|
Application.Exit()
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
MyDatabase = New DigitalData.Modules.Database.MSSQLServer(MyLogConfig, MyConnectionString)
|
||||||
|
|
||||||
TBDD_CLIENTTableAdapter.Connection.ConnectionString = MyConnectionString
|
TBDD_CLIENTTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||||
TBDD_CLIENT_USERTableAdapter.Connection.ConnectionString = MyConnectionString
|
TBDD_CLIENT_USERTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||||
TBDD_GROUPSTableAdapter.Connection.ConnectionString = MyConnectionString
|
TBDD_GROUPSTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||||
@ -56,11 +57,11 @@ Public Class frmMain
|
|||||||
TBDD_USER_MODULESTableAdapter.Connection.ConnectionString = MyConnectionString
|
TBDD_USER_MODULESTableAdapter.Connection.ConnectionString = MyConnectionString
|
||||||
|
|
||||||
Dim sql = String.Format("SELECT * FROM [dbo].[FNDD_CHECK_USER_MODULE] ('{0}','UM',{1})", Environment.UserName, 1)
|
Dim sql = String.Format("SELECT * FROM [dbo].[FNDD_CHECK_USER_MODULE] ('{0}','UM',{1})", Environment.UserName, 1)
|
||||||
Dim DT_CHECKUSER_MODULE As DataTable = clsDatabase.Return_Datatable(sql)
|
Dim DT_CHECKUSER_MODULE As DataTable = MyDatabase.GetDatatable(sql)
|
||||||
|
|
||||||
If DT_CHECKUSER_MODULE.Rows.Count = 0 Then
|
If DT_CHECKUSER_MODULE.Rows.Count = 0 Then
|
||||||
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
||||||
logger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt.")
|
MyLogger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt.")
|
||||||
Application.ExitThread()
|
Application.ExitThread()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ Public Class frmMain
|
|||||||
|
|
||||||
If userId = 0 Then
|
If userId = 0 Then
|
||||||
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht in der Benutzerverwaltung vorhanden. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht in der Benutzerverwaltung vorhanden. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
||||||
logger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht in der Benutzerverwaltung vorhanden.")
|
MyLogger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht in der Benutzerverwaltung vorhanden.")
|
||||||
Application.ExitThread()
|
Application.ExitThread()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -112,51 +113,55 @@ Public Class frmMain
|
|||||||
DragDropManager.AddGridView(viewModulesGroups_AvailableGroups)
|
DragDropManager.AddGridView(viewModulesGroups_AvailableGroups)
|
||||||
Else
|
Else
|
||||||
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
||||||
logger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt.")
|
MyLogger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt.")
|
||||||
Application.ExitThread()
|
Application.ExitThread()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If TBDD_USERTableAdapter.IsUserManagerAdmin(Environment.UserName) <> 1 Then
|
If TBDD_USERTableAdapter.IsUserManagerAdmin(Environment.UserName) <> 1 Then
|
||||||
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
MsgBox($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt. {vbCrLf & vbCrLf}Bitte kontaktieren Sie den Administrator, wenn dies ein Fehler ist.", MsgBoxStyle.Critical, "UserManager")
|
||||||
logger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt.")
|
MyLogger.Warn($"Der Benutzer '{Environment.UserName}' ist nicht zur Benutzerverwaltung berechtigt.")
|
||||||
Application.ExitThread()
|
Application.ExitThread()
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
MsgBox("Unexpected Error while loading. Please check the log.", MsgBoxStyle.Critical, "User Manager")
|
MsgBox("Unexpected Error while loading. Please check the log.", MsgBoxStyle.Critical, "User Manager")
|
||||||
logger.Fatal(ex, "Unexpected Error while loading.")
|
MyLogger.Fatal(ex, "Unexpected Error while loading.")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Function InitDatabase()
|
Private Sub LoadConfig(ConfigManager As ConfigManager(Of UserConfig))
|
||||||
|
Dim oConnectionString As String = ""
|
||||||
|
Dim csb As New SqlClient.SqlConnectionStringBuilder
|
||||||
|
csb.ConnectionString = ConfigManager.Config.ConnectionString
|
||||||
|
|
||||||
|
If Not csb.ConnectionString = "" Then
|
||||||
|
If csb.ConnectionString.Contains("Password=") Then
|
||||||
|
'sa-
|
||||||
|
'Jetzt das Passwort entschlüsseln
|
||||||
|
Dim PWplainText As String
|
||||||
|
Dim wrapper As New EncryptionLegacy("!35452didalog=")
|
||||||
|
' DecryptData throws if the wrong password is used.
|
||||||
Try
|
Try
|
||||||
Dim dbResult As Boolean
|
PWplainText = wrapper.DecryptData(csb.Password)
|
||||||
|
oConnectionString = ConfigManager.Config.ConnectionString.Replace(csb.Password, PWplainText)
|
||||||
MySettings_Load()
|
|
||||||
|
|
||||||
clsDatabase.GUI = True
|
|
||||||
If MyConnectionString <> String.Empty Then
|
|
||||||
dbResult = clsDatabase.Init(MyConnectionString)
|
|
||||||
Else
|
|
||||||
frmConfigDatabase.ShowDialog()
|
|
||||||
dbResult = clsDatabase.Init(MyConnectionString)
|
|
||||||
End If
|
|
||||||
clsDatabase.Init(MyConnectionString)
|
|
||||||
If dbResult = False Then
|
|
||||||
If clsLogger.LOGG_MSG <> String.Empty Then
|
|
||||||
Throw New Exception("Error while Initializing database:" & vbNewLine & clsLogger.LOGG_MSG)
|
|
||||||
Else
|
|
||||||
Throw New Exception("Find more information in the logfile.")
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
logger.Fatal(ex, "Unexpected Error in Init Database:")
|
MyLogger.Error(ex)
|
||||||
MsgBox("Unexpected Error in Init Database:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
MyLogger.Warn("- the Password '" & csb.Password & "' could not be decrypted", False)
|
||||||
|
oConnectionString = ""
|
||||||
Return False
|
|
||||||
End Try
|
End Try
|
||||||
End Function
|
|
||||||
|
Else
|
||||||
|
'Windows-Auth
|
||||||
|
oConnectionString = ConfigManager.Config.ConnectionString
|
||||||
|
End If
|
||||||
|
|
||||||
|
MyConnectionString = oConnectionString
|
||||||
|
Else
|
||||||
|
MyConnectionString = ""
|
||||||
|
End If
|
||||||
|
|
||||||
|
LogErrorsOnly = MyConfig.Config.LogErrorsOnly
|
||||||
|
ActiveDirectoryRootNode = MyConfig.Config.ActiveDirectoryRootNode
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub btnImportUsers_Click(sender As Object, e As EventArgs) Handles btnImportUsers.Click
|
Private Sub btnImportUsers_Click(sender As Object, e As EventArgs) Handles btnImportUsers.Click
|
||||||
Dim frm As New frmADImport_Users()
|
Dim frm As New frmADImport_Users()
|
||||||
@ -1036,7 +1041,7 @@ Public Class frmMain
|
|||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Private Sub ShowErrorMessage(errorText As String, ex As Exception)
|
Private Sub ShowErrorMessage(errorText As String, ex As Exception)
|
||||||
logger.Error(ex, errorText)
|
MyLogger.Error(ex, errorText)
|
||||||
MsgBox(errorText & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, "User Manager")
|
MsgBox(errorText & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, "User Manager")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@ -1069,8 +1074,9 @@ Public Class frmMain
|
|||||||
Process.Start(ClassNLog.GetLogPathFor(MODULE_NAME))
|
Process.Start(ClassNLog.GetLogPathFor(MODULE_NAME))
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub txtADRootNode_Leave(sender As Object, e As EventArgs) Handles txtADRootNode.Leave, txtLDAPGroupQuery.Leave
|
Private Sub txtADRootNode_Leave(sender As Object, e As EventArgs) Handles txtADRootNode.Leave, txtLDAPGroupQuery.Leave, txtLDAPUserQuery.Leave
|
||||||
SaveMySettingsValue("ActiveDirectoryRootNode", txtADRootNode.Text, "ConfigMain")
|
MyConfig.Config.ActiveDirectoryRootNode = txtADRootNode.Text
|
||||||
|
MyConfig.Save()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
@ -1081,8 +1087,10 @@ Public Class frmMain
|
|||||||
If ClassActiveDirectory.ConnectionTest(txtADRootNode.Text) Then
|
If ClassActiveDirectory.ConnectionTest(txtADRootNode.Text) Then
|
||||||
MsgBox("Verbindung erfolgreich aufgebaut!", MsgBoxStyle.Information)
|
MsgBox("Verbindung erfolgreich aufgebaut!", MsgBoxStyle.Information)
|
||||||
|
|
||||||
SaveMySettingsValue("ActiveDirectoryRootNode", txtADRootNode.Text, "ConfigMain")
|
MyConfig.Config.ActiveDirectoryRootNode = txtADRootNode.Text
|
||||||
logger.Info($"New ActiveDirectory Path saved: {txtADRootNode.Text}")
|
MyConfig.Save()
|
||||||
|
|
||||||
|
MyLogger.Info($"New ActiveDirectory Path saved: {txtADRootNode.Text}")
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@ -1090,9 +1098,7 @@ Public Class frmMain
|
|||||||
Process.Start("https://didalog.de/support")
|
Process.Start("https://didalog.de/support")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Async Sub btnDebugQuery_Click(sender As Object, e As EventArgs) Handles btnDebugGroupQuery.Click
|
Private Async Sub btnDebugQuery_Click(sender As Object, e As EventArgs) Handles btnDebugGroupQuery.Click, Button5.Click
|
||||||
My.Settings.Save()
|
|
||||||
|
|
||||||
btnDebugGroupQuery.Text = "Abfrage läuft..."
|
btnDebugGroupQuery.Text = "Abfrage läuft..."
|
||||||
btnDebugGroupQuery.Enabled = False
|
btnDebugGroupQuery.Enabled = False
|
||||||
|
|
||||||
@ -1116,7 +1122,7 @@ Public Class frmMain
|
|||||||
|
|
||||||
If MessageBox.Show(oMessage, "Benutzer löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
|
If MessageBox.Show(oMessage, "Benutzer löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
|
||||||
Dim osql = $"EXEC PRDD_DELETE_USER {oUserId}"
|
Dim osql = $"EXEC PRDD_DELETE_USER {oUserId}"
|
||||||
If clsDatabase.Execute_Scalar(osql) = -1 Then
|
If MyDatabase.GetScalarValue(osql) = -1 Then
|
||||||
MessageBox.Show("Fehler beim Löschen des Benutzers.", "Benutzer löschen", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
MessageBox.Show("Fehler beim Löschen des Benutzers.", "Benutzer löschen", MessageBoxButtons.OK, MessageBoxIcon.Warning)
|
||||||
Else
|
Else
|
||||||
UpdateSavedLabel()
|
UpdateSavedLabel()
|
||||||
@ -1124,4 +1130,17 @@ Public Class frmMain
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click, Button4.Click
|
||||||
|
MyConfig.Config.AdGroupFilter = txtLDAPGroupQuery.Text
|
||||||
|
MyConfig.Save()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub XtraTabControl1_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControl1.SelectedPageChanged
|
||||||
|
If e.Page.Name = tabPageSettings.Name Then
|
||||||
|
txtADRootNode.Text = MyConfig.Config.ActiveDirectoryRootNode
|
||||||
|
txtLDAPGroupQuery.Text = MyConfig.Config.AdGroupFilter
|
||||||
|
txtLDAPUserQuery.Text = MyConfig.Config.AdUserFilter
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user