diff --git a/DDUserManager/DDUserManager/App.config b/DDUserManager/DDUserManager/App.config index 9d507d7..8005d0b 100644 --- a/DDUserManager/DDUserManager/App.config +++ b/DDUserManager/DDUserManager/App.config @@ -1,11 +1,33 @@ + +
+ + +
+ - + + + + + + + + + + + + (&(objectClass=group) (samAccountName=*)) + + + diff --git a/DDUserManager/DDUserManager/ClassActiveDirectory.vb b/DDUserManager/DDUserManager/ClassActiveDirectory.vb index f314f76..c40d721 100644 --- a/DDUserManager/DDUserManager/ClassActiveDirectory.vb +++ b/DDUserManager/DDUserManager/ClassActiveDirectory.vb @@ -49,6 +49,20 @@ Public Class ClassActiveDirectory "Zulässige" } + Public Class GroupResult + Public SAMAccountName As String + Public ObjectClass As String + Public CN As String + Public Description As String + Public DistinguishedName As String + Public Name As String + Public ObjectCategory As String + + Public Overrides Function ToString() As String + Return $"SAMAccountName={SAMAccountName}, ObjectClass={ObjectClass}, CN={CN}, Description={Description}, DistinguishedName={DistinguishedName}, Name={Name}, ObjectCategory={ObjectCategory}" + End Function + End Class + Public Shared Function ConnectionTest(path As String) Try Dim de As New DirectoryEntry(path) @@ -80,28 +94,81 @@ Public Class ClassActiveDirectory Return dirSearcher End Function - Public Shared Function GetActiveDirectoryGroups() As List(Of String) - Dim groups As New List(Of String) + Public Shared Function GetActiveDirectoryGroups(Optional query As String = "(&(objectClass=group) (samAccountName=*))") As List(Of GroupResult) + Dim groups As New List(Of GroupResult) Dim deSearch = GetDirectorySearch(GetDirectoryEntry()) - deSearch.Filter = "(&(objectClass=group) (samAccountName=" & "*" & "))" + deSearch.SearchScope = SearchScope.Subtree + deSearch.Filter = query + deSearch.SizeLimit = 50000 + Dim results As SearchResultCollection = deSearch.FindAll() For Each r As SearchResult In results Try - 'Dim groupName = r.GetDirectoryEntry.Name.Replace("CN=", "") - Dim groupName = r.Properties.Item("samaccountname").Item(0) + Dim groupName, objectClass, cn, description, distinguishedName, name, objectCategory As String + Try + groupName = r.Properties.Item("samaccountname").Item(0) + Catch ex As Exception + logger.Error(ex) + groupName = "" + End Try + Try + objectClass = r.Properties.Item("objectClass").Item(0) + Catch ex As Exception + logger.Error(ex) + objectClass = "" + End Try + Try + cn = r.Properties.Item("cn").Item(0) + Catch ex As Exception + logger.Error(ex) + cn = "" + End Try + Try + description = r.Properties.Item("description").Item(0) + Catch ex As Exception + logger.Error(ex) + description = "" + End Try + Try + distinguishedName = r.Properties.Item("distinguishedName").Item(0) + Catch ex As Exception + logger.Error(ex) + distinguishedName = "" + End Try + Try + name = r.Properties.Item("name").Item(0) + Catch ex As Exception + logger.Error(ex) + name = "" + End Try + Try + objectCategory = r.Properties.Item("objectCategory").Item(0) + Catch ex As Exception + logger.Error(ex) + objectCategory = "" + End Try - If Not IsNothing(groupName) Then + If Not String.IsNullOrEmpty(groupName) Then Dim isExcluded = excludedGroupNames.Where(Function(excludedGroup) Return (groupName.Contains(excludedGroup) Or groupName.StartsWith(excludedGroup)) End Function).Any() If Not isExcluded Then - groups.Add(groupName) + groups.Add(New GroupResult() With { + .SAMAccountName = groupName, + .CN = cn, + .Description = description, + .DistinguishedName = distinguishedName, + .Name = name, + .ObjectCategory = objectCategory, + .ObjectClass = objectClass + }) End If End If Catch ex As Exception - MsgBox("Error while fetching Active Directory groups", MsgBoxStyle.Critical) + 'MsgBox("Error while fetching Active Directory groups", MsgBoxStyle.Critical) + logger.Error(ex) End Try Next diff --git a/DDUserManager/DDUserManager/DDUserManager.vbproj b/DDUserManager/DDUserManager/DDUserManager.vbproj index 05a21a4..07125f3 100644 --- a/DDUserManager/DDUserManager/DDUserManager.vbproj +++ b/DDUserManager/DDUserManager/DDUserManager.vbproj @@ -105,6 +105,12 @@ True DS_ChangeS.xsd + + frmADDebug.vb + + + Form + frmConfigDatabase.vb @@ -156,6 +162,9 @@ + + frmADDebug.vb + frmConfigDatabase.vb diff --git a/DDUserManager/DDUserManager/DS_ChangeS.xsd b/DDUserManager/DDUserManager/DS_ChangeS.xsd index 2a3e825..83bf3e4 100644 --- a/DDUserManager/DDUserManager/DS_ChangeS.xsd +++ b/DDUserManager/DDUserManager/DS_ChangeS.xsd @@ -200,7 +200,7 @@ VALUES (@NAME,@ADDED_WHO,@ECM_FK_ID,@AD_SYNC,@INTERNAL,@ACTIVE) - + diff --git a/DDUserManager/DDUserManager/My Project/AssemblyInfo.vb b/DDUserManager/DDUserManager/My Project/AssemblyInfo.vb index 15ca17b..e97578c 100644 --- a/DDUserManager/DDUserManager/My Project/AssemblyInfo.vb +++ b/DDUserManager/DDUserManager/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/DDUserManager/DDUserManager/My Project/Settings.Designer.vb b/DDUserManager/DDUserManager/My Project/Settings.Designer.vb index 181bb45..8fb2a52 100644 --- a/DDUserManager/DDUserManager/My Project/Settings.Designer.vb +++ b/DDUserManager/DDUserManager/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase @@ -64,6 +64,27 @@ Namespace My Return CType(Me("DD_ECMConnectionString"),String) End Get End Property + + _ + Public ReadOnly Property AD_GROUP_QUERY() As String + Get + Return CType(Me("AD_GROUP_QUERY"),String) + End Get + End Property + + _ + Public Property AD_USER_QUERY() As String + Get + Return CType(Me("AD_USER_QUERY"),String) + End Get + Set + Me("AD_USER_QUERY") = value + End Set + End Property End Class End Namespace diff --git a/DDUserManager/DDUserManager/My Project/Settings.settings b/DDUserManager/DDUserManager/My Project/Settings.settings index 8ca5281..494437e 100644 --- a/DDUserManager/DDUserManager/My Project/Settings.settings +++ b/DDUserManager/DDUserManager/My Project/Settings.settings @@ -10,5 +10,11 @@ </SerializableConnectionString> Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd + + (&(objectClass=group) (samAccountName=*)) + + + + \ No newline at end of file diff --git a/DDUserManager/DDUserManager/UserDataSet.Designer.vb b/DDUserManager/DDUserManager/UserDataSet.Designer.vb index 189608b..78e63b3 100644 --- a/DDUserManager/DDUserManager/UserDataSet.Designer.vb +++ b/DDUserManager/DDUserManager/UserDataSet.Designer.vb @@ -47,6 +47,8 @@ Partial Public Class UserDataSet Private tableTBLOCAL_ADGROUPS As TBLOCAL_ADGROUPSDataTable + Private tableTBLOCAL_DEBUG_GROUPS As TBLOCAL_DEBUG_GROUPSDataTable + Private relationFK_TBDD_USER_MODULES_MODULE_ID As Global.System.Data.DataRelation Private relationFK_TBDD_CLIENT_USER_GROUP_ID As Global.System.Data.DataRelation @@ -129,6 +131,9 @@ Partial Public Class UserDataSet If (Not (ds.Tables("TBLOCAL_ADGROUPS")) Is Nothing) Then MyBase.Tables.Add(New TBLOCAL_ADGROUPSDataTable(ds.Tables("TBLOCAL_ADGROUPS"))) End If + If (Not (ds.Tables("TBLOCAL_DEBUG_GROUPS")) Is Nothing) Then + MyBase.Tables.Add(New TBLOCAL_DEBUG_GROUPSDataTable(ds.Tables("TBLOCAL_DEBUG_GROUPS"))) + End If Me.DataSetName = ds.DataSetName Me.Prefix = ds.Prefix Me.Namespace = ds.Namespace @@ -256,6 +261,16 @@ Partial Public Class UserDataSet End Get End Property + _ + Public ReadOnly Property TBLOCAL_DEBUG_GROUPS() As TBLOCAL_DEBUG_GROUPSDataTable + Get + Return Me.tableTBLOCAL_DEBUG_GROUPS + End Get + End Property + _ + Private Function ShouldSerializeTBLOCAL_DEBUG_GROUPS() As Boolean + Return false + End Function + _ Private Sub SchemaChanged(ByVal sender As Object, ByVal e As Global.System.ComponentModel.CollectionChangeEventArgs) @@ -675,6 +707,9 @@ Partial Public Class UserDataSet _ Public Delegate Sub TBLOCAL_ADGROUPSRowChangeEventHandler(ByVal sender As Object, ByVal e As TBLOCAL_ADGROUPSRowChangeEvent) + _ + Public Delegate Sub TBLOCAL_DEBUG_GROUPSRowChangeEventHandler(ByVal sender As Object, ByVal e As TBLOCAL_DEBUG_GROUPSRowChangeEvent) + ''' '''Represents the strongly named DataTable class. ''' @@ -4822,6 +4857,336 @@ Partial Public Class UserDataSet End Function End Class + ''' + '''Represents the strongly named DataTable class. + ''' + _ + Partial Public Class TBLOCAL_DEBUG_GROUPSDataTable + Inherits Global.System.Data.TypedTableBase(Of TBLOCAL_DEBUG_GROUPSRow) + + Private columnSAMACCOUNTNAME As Global.System.Data.DataColumn + + Private columnCN As Global.System.Data.DataColumn + + Private columnOBJECT_CLASS As Global.System.Data.DataColumn + + Private columnOBJECT_CATEGORY As Global.System.Data.DataColumn + + Private columnDESCRIPTION As Global.System.Data.DataColumn + + Private columnDISTINGUISHED_NAME As Global.System.Data.DataColumn + + Private columnNAME As Global.System.Data.DataColumn + + _ + Public Sub New() + MyBase.New + Me.TableName = "TBLOCAL_DEBUG_GROUPS" + Me.BeginInit + Me.InitClass + Me.EndInit + End Sub + + _ + Friend Sub New(ByVal table As Global.System.Data.DataTable) + MyBase.New + Me.TableName = table.TableName + If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then + Me.CaseSensitive = table.CaseSensitive + End If + If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then + Me.Locale = table.Locale + End If + If (table.Namespace <> table.DataSet.Namespace) Then + Me.Namespace = table.Namespace + End If + Me.Prefix = table.Prefix + Me.MinimumCapacity = table.MinimumCapacity + End Sub + + _ + Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext) + MyBase.New(info, context) + Me.InitVars + End Sub + + _ + Public ReadOnly Property SAMACCOUNTNAMEColumn() As Global.System.Data.DataColumn + Get + Return Me.columnSAMACCOUNTNAME + End Get + End Property + + _ + Public ReadOnly Property CNColumn() As Global.System.Data.DataColumn + Get + Return Me.columnCN + End Get + End Property + + _ + Public ReadOnly Property OBJECT_CLASSColumn() As Global.System.Data.DataColumn + Get + Return Me.columnOBJECT_CLASS + End Get + End Property + + _ + Public ReadOnly Property OBJECT_CATEGORYColumn() As Global.System.Data.DataColumn + Get + Return Me.columnOBJECT_CATEGORY + End Get + End Property + + _ + Public ReadOnly Property DESCRIPTIONColumn() As Global.System.Data.DataColumn + Get + Return Me.columnDESCRIPTION + End Get + End Property + + _ + Public ReadOnly Property DISTINGUISHED_NAMEColumn() As Global.System.Data.DataColumn + Get + Return Me.columnDISTINGUISHED_NAME + End Get + End Property + + _ + Public ReadOnly Property NAMEColumn() As Global.System.Data.DataColumn + Get + Return Me.columnNAME + End Get + End Property + + _ + Public ReadOnly Property Count() As Integer + Get + Return Me.Rows.Count + End Get + End Property + + _ + Public Default ReadOnly Property Item(ByVal index As Integer) As TBLOCAL_DEBUG_GROUPSRow + Get + Return CType(Me.Rows(index),TBLOCAL_DEBUG_GROUPSRow) + End Get + End Property + + _ + Public Event TBLOCAL_DEBUG_GROUPSRowChanging As TBLOCAL_DEBUG_GROUPSRowChangeEventHandler + + _ + Public Event TBLOCAL_DEBUG_GROUPSRowChanged As TBLOCAL_DEBUG_GROUPSRowChangeEventHandler + + _ + Public Event TBLOCAL_DEBUG_GROUPSRowDeleting As TBLOCAL_DEBUG_GROUPSRowChangeEventHandler + + _ + Public Event TBLOCAL_DEBUG_GROUPSRowDeleted As TBLOCAL_DEBUG_GROUPSRowChangeEventHandler + + _ + Public Overloads Sub AddTBLOCAL_DEBUG_GROUPSRow(ByVal row As TBLOCAL_DEBUG_GROUPSRow) + Me.Rows.Add(row) + End Sub + + _ + Public Overloads Function AddTBLOCAL_DEBUG_GROUPSRow(ByVal SAMACCOUNTNAME As String, ByVal CN As String, ByVal OBJECT_CLASS As String, ByVal OBJECT_CATEGORY As String, ByVal DESCRIPTION As String, ByVal DISTINGUISHED_NAME As String, ByVal NAME As String) As TBLOCAL_DEBUG_GROUPSRow + Dim rowTBLOCAL_DEBUG_GROUPSRow As TBLOCAL_DEBUG_GROUPSRow = CType(Me.NewRow,TBLOCAL_DEBUG_GROUPSRow) + Dim columnValuesArray() As Object = New Object() {SAMACCOUNTNAME, CN, OBJECT_CLASS, OBJECT_CATEGORY, DESCRIPTION, DISTINGUISHED_NAME, NAME} + rowTBLOCAL_DEBUG_GROUPSRow.ItemArray = columnValuesArray + Me.Rows.Add(rowTBLOCAL_DEBUG_GROUPSRow) + Return rowTBLOCAL_DEBUG_GROUPSRow + End Function + + _ + Public Overrides Function Clone() As Global.System.Data.DataTable + Dim cln As TBLOCAL_DEBUG_GROUPSDataTable = CType(MyBase.Clone,TBLOCAL_DEBUG_GROUPSDataTable) + cln.InitVars + Return cln + End Function + + _ + Protected Overrides Function CreateInstance() As Global.System.Data.DataTable + Return New TBLOCAL_DEBUG_GROUPSDataTable() + End Function + + _ + Friend Sub InitVars() + Me.columnSAMACCOUNTNAME = MyBase.Columns("SAMACCOUNTNAME") + Me.columnCN = MyBase.Columns("CN") + Me.columnOBJECT_CLASS = MyBase.Columns("OBJECT_CLASS") + Me.columnOBJECT_CATEGORY = MyBase.Columns("OBJECT_CATEGORY") + Me.columnDESCRIPTION = MyBase.Columns("DESCRIPTION") + Me.columnDISTINGUISHED_NAME = MyBase.Columns("DISTINGUISHED_NAME") + Me.columnNAME = MyBase.Columns("NAME") + End Sub + + _ + Private Sub InitClass() + Me.columnSAMACCOUNTNAME = New Global.System.Data.DataColumn("SAMACCOUNTNAME", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnSAMACCOUNTNAME) + Me.columnCN = New Global.System.Data.DataColumn("CN", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnCN) + Me.columnOBJECT_CLASS = New Global.System.Data.DataColumn("OBJECT_CLASS", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnOBJECT_CLASS) + Me.columnOBJECT_CATEGORY = New Global.System.Data.DataColumn("OBJECT_CATEGORY", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnOBJECT_CATEGORY) + Me.columnDESCRIPTION = New Global.System.Data.DataColumn("DESCRIPTION", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnDESCRIPTION) + Me.columnDISTINGUISHED_NAME = New Global.System.Data.DataColumn("DISTINGUISHED_NAME", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnDISTINGUISHED_NAME) + Me.columnNAME = New Global.System.Data.DataColumn("NAME", GetType(String), Nothing, Global.System.Data.MappingType.Element) + MyBase.Columns.Add(Me.columnNAME) + End Sub + + _ + Public Function NewTBLOCAL_DEBUG_GROUPSRow() As TBLOCAL_DEBUG_GROUPSRow + Return CType(Me.NewRow,TBLOCAL_DEBUG_GROUPSRow) + End Function + + _ + Protected Overrides Function NewRowFromBuilder(ByVal builder As Global.System.Data.DataRowBuilder) As Global.System.Data.DataRow + Return New TBLOCAL_DEBUG_GROUPSRow(builder) + End Function + + _ + Protected Overrides Function GetRowType() As Global.System.Type + Return GetType(TBLOCAL_DEBUG_GROUPSRow) + End Function + + _ + Protected Overrides Sub OnRowChanged(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanged(e) + If (Not (Me.TBLOCAL_DEBUG_GROUPSRowChangedEvent) Is Nothing) Then + RaiseEvent TBLOCAL_DEBUG_GROUPSRowChanged(Me, New TBLOCAL_DEBUG_GROUPSRowChangeEvent(CType(e.Row,TBLOCAL_DEBUG_GROUPSRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowChanging(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowChanging(e) + If (Not (Me.TBLOCAL_DEBUG_GROUPSRowChangingEvent) Is Nothing) Then + RaiseEvent TBLOCAL_DEBUG_GROUPSRowChanging(Me, New TBLOCAL_DEBUG_GROUPSRowChangeEvent(CType(e.Row,TBLOCAL_DEBUG_GROUPSRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleted(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleted(e) + If (Not (Me.TBLOCAL_DEBUG_GROUPSRowDeletedEvent) Is Nothing) Then + RaiseEvent TBLOCAL_DEBUG_GROUPSRowDeleted(Me, New TBLOCAL_DEBUG_GROUPSRowChangeEvent(CType(e.Row,TBLOCAL_DEBUG_GROUPSRow), e.Action)) + End If + End Sub + + _ + Protected Overrides Sub OnRowDeleting(ByVal e As Global.System.Data.DataRowChangeEventArgs) + MyBase.OnRowDeleting(e) + If (Not (Me.TBLOCAL_DEBUG_GROUPSRowDeletingEvent) Is Nothing) Then + RaiseEvent TBLOCAL_DEBUG_GROUPSRowDeleting(Me, New TBLOCAL_DEBUG_GROUPSRowChangeEvent(CType(e.Row,TBLOCAL_DEBUG_GROUPSRow), e.Action)) + End If + End Sub + + _ + Public Sub RemoveTBLOCAL_DEBUG_GROUPSRow(ByVal row As TBLOCAL_DEBUG_GROUPSRow) + Me.Rows.Remove(row) + End Sub + + _ + Public Shared Function GetTypedTableSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType + Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType() + Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence() + Dim ds As UserDataSet = New UserDataSet() + Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny() + any1.Namespace = "http://www.w3.org/2001/XMLSchema" + any1.MinOccurs = New Decimal(0) + any1.MaxOccurs = Decimal.MaxValue + any1.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any1) + Dim any2 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny() + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1" + any2.MinOccurs = New Decimal(1) + any2.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax + sequence.Items.Add(any2) + Dim attribute1 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute() + attribute1.Name = "namespace" + attribute1.FixedValue = ds.Namespace + type.Attributes.Add(attribute1) + Dim attribute2 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute() + attribute2.Name = "tableTypeName" + attribute2.FixedValue = "TBLOCAL_DEBUG_GROUPSDataTable" + type.Attributes.Add(attribute2) + type.Particle = sequence + Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable + If xs.Contains(dsSchema.TargetNamespace) Then + Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream() + Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream() + Try + Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing + dsSchema.Write(s1) + Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator + Do While schemas.MoveNext + schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema) + s2.SetLength(0) + schema.Write(s2) + If (s1.Length = s2.Length) Then + s1.Position = 0 + s2.Position = 0 + + Do While ((s1.Position <> s1.Length) _ + AndAlso (s1.ReadByte = s2.ReadByte)) + + + Loop + If (s1.Position = s1.Length) Then + Return type + End If + End If + + Loop + Finally + If (Not (s1) Is Nothing) Then + s1.Close + End If + If (Not (s2) Is Nothing) Then + s2.Close + End If + End Try + End If + xs.Add(dsSchema) + Return type + End Function + End Class + ''' '''Represents strongly named DataRow class. ''' @@ -7107,6 +7472,212 @@ Partial Public Class UserDataSet End Sub End Class + ''' + '''Represents strongly named DataRow class. + ''' + Partial Public Class TBLOCAL_DEBUG_GROUPSRow + Inherits Global.System.Data.DataRow + + Private tableTBLOCAL_DEBUG_GROUPS As TBLOCAL_DEBUG_GROUPSDataTable + + _ + Friend Sub New(ByVal rb As Global.System.Data.DataRowBuilder) + MyBase.New(rb) + Me.tableTBLOCAL_DEBUG_GROUPS = CType(Me.Table,TBLOCAL_DEBUG_GROUPSDataTable) + End Sub + + _ + Public Property SAMACCOUNTNAME() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.SAMACCOUNTNAMEColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte SAMACCOUNTNAME in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull.", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.SAMACCOUNTNAMEColumn) = value + End Set + End Property + + _ + Public Property CN() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.CNColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte CN in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull.", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.CNColumn) = value + End Set + End Property + + _ + Public Property OBJECT_CLASS() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CLASSColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte OBJECT_CLASS in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull.", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CLASSColumn) = value + End Set + End Property + + _ + Public Property OBJECT_CATEGORY() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CATEGORYColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte OBJECT_CATEGORY in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull.", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CATEGORYColumn) = value + End Set + End Property + + _ + Public Property DESCRIPTION() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.DESCRIPTIONColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte DESCRIPTION in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull.", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.DESCRIPTIONColumn) = value + End Set + End Property + + _ + Public Property DISTINGUISHED_NAME() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.DISTINGUISHED_NAMEColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte DISTINGUISHED_NAME in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull"& _ + ".", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.DISTINGUISHED_NAMEColumn) = value + End Set + End Property + + _ + Public Property NAME() As String + Get + Try + Return CType(Me(Me.tableTBLOCAL_DEBUG_GROUPS.NAMEColumn),String) + Catch e As Global.System.InvalidCastException + Throw New Global.System.Data.StrongTypingException("Der Wert für Spalte NAME in Tabelle TBLOCAL_DEBUG_GROUPS ist DBNull.", e) + End Try + End Get + Set + Me(Me.tableTBLOCAL_DEBUG_GROUPS.NAMEColumn) = value + End Set + End Property + + _ + Public Function IsSAMACCOUNTNAMENull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.SAMACCOUNTNAMEColumn) + End Function + + _ + Public Sub SetSAMACCOUNTNAMENull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.SAMACCOUNTNAMEColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function IsCNNull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.CNColumn) + End Function + + _ + Public Sub SetCNNull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.CNColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function IsOBJECT_CLASSNull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CLASSColumn) + End Function + + _ + Public Sub SetOBJECT_CLASSNull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CLASSColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function IsOBJECT_CATEGORYNull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CATEGORYColumn) + End Function + + _ + Public Sub SetOBJECT_CATEGORYNull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.OBJECT_CATEGORYColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function IsDESCRIPTIONNull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.DESCRIPTIONColumn) + End Function + + _ + Public Sub SetDESCRIPTIONNull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.DESCRIPTIONColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function IsDISTINGUISHED_NAMENull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.DISTINGUISHED_NAMEColumn) + End Function + + _ + Public Sub SetDISTINGUISHED_NAMENull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.DISTINGUISHED_NAMEColumn) = Global.System.Convert.DBNull + End Sub + + _ + Public Function IsNAMENull() As Boolean + Return Me.IsNull(Me.tableTBLOCAL_DEBUG_GROUPS.NAMEColumn) + End Function + + _ + Public Sub SetNAMENull() + Me(Me.tableTBLOCAL_DEBUG_GROUPS.NAMEColumn) = Global.System.Convert.DBNull + End Sub + End Class + ''' '''Row event argument class ''' @@ -7502,6 +8073,42 @@ Partial Public Class UserDataSet End Get End Property End Class + + ''' + '''Row event argument class + ''' + _ + Public Class TBLOCAL_DEBUG_GROUPSRowChangeEvent + Inherits Global.System.EventArgs + + Private eventRow As TBLOCAL_DEBUG_GROUPSRow + + Private eventAction As Global.System.Data.DataRowAction + + _ + Public Sub New(ByVal row As TBLOCAL_DEBUG_GROUPSRow, ByVal action As Global.System.Data.DataRowAction) + MyBase.New + Me.eventRow = row + Me.eventAction = action + End Sub + + _ + Public ReadOnly Property Row() As TBLOCAL_DEBUG_GROUPSRow + Get + Return Me.eventRow + End Get + End Property + + _ + Public ReadOnly Property Action() As Global.System.Data.DataRowAction + Get + Return Me.eventAction + End Get + End Property + End Class End Class Namespace UserDataSetTableAdapters @@ -12688,6 +13295,70 @@ Namespace UserDataSetTableAdapters End Function End Class + ''' + '''Represents the connection and commands used to retrieve and save data. + ''' + _ + Partial Public Class QueriesTableAdapter + Inherits Global.System.ComponentModel.Component + + Private _commandCollection() As Global.System.Data.IDbCommand + + _ + Protected ReadOnly Property CommandCollection() As Global.System.Data.IDbCommand() + Get + If (Me._commandCollection Is Nothing) Then + Me.InitCommandCollection + End If + Return Me._commandCollection + End Get + End Property + + _ + Private Sub InitCommandCollection() + Me._commandCollection = New Global.System.Data.IDbCommand(0) {} + Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand() + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Connection = New Global.System.Data.SqlClient.SqlConnection(Global.DDUserManager.My.MySettings.Default.DD_ECMConnectionString) + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).CommandText = "dbo.PRDD_DELETE_USER" + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).CommandType = Global.System.Data.CommandType.StoredProcedure + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@RETURN_VALUE", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + CType(Me._commandCollection(0),Global.System.Data.SqlClient.SqlCommand).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@pUSER_ID", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.Input, 10, 0, Nothing, Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + End Sub + + _ + Public Overloads Overridable Function PRDD_DELETE_USER(ByVal pUSER_ID As Global.System.Nullable(Of Integer)) As Integer + Dim command As Global.System.Data.SqlClient.SqlCommand = CType(Me.CommandCollection(0),Global.System.Data.SqlClient.SqlCommand) + If (pUSER_ID.HasValue = true) Then + command.Parameters(1).Value = CType(pUSER_ID.Value,Integer) + Else + command.Parameters(1).Value = Global.System.DBNull.Value + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = command.Connection.State + If ((command.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + command.Connection.Open + End If + Dim returnValue As Integer + Try + returnValue = command.ExecuteNonQuery + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + command.Connection.Close + End If + End Try + Return returnValue + End Function + End Class + ''' '''TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios ''' diff --git a/DDUserManager/DDUserManager/UserDataSet.xsd b/DDUserManager/DDUserManager/UserDataSet.xsd index 161043c..f25d65e 100644 --- a/DDUserManager/DDUserManager/UserDataSet.xsd +++ b/DDUserManager/DDUserManager/UserDataSet.xsd @@ -2,7 +2,7 @@ - + @@ -1092,7 +1092,19 @@ VALUES (@NAME,@ADDED_WHO, 1, 1, 0, 1) - + + + + + dbo.PRDD_DELETE_USER + + + + + + + + @@ -1550,6 +1562,19 @@ VALUES (@NAME,@ADDED_WHO, 1, 1, 0, 1) + + + + + + + + + + + + + diff --git a/DDUserManager/DDUserManager/UserDataSet.xss b/DDUserManager/DDUserManager/UserDataSet.xss index 84286bf..a8478c2 100644 --- a/DDUserManager/DDUserManager/UserDataSet.xss +++ b/DDUserManager/DDUserManager/UserDataSet.xss @@ -4,22 +4,24 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + - - - - - - - - - - - + + + + + + + + + + + + + - + 1322 @@ -31,7 +33,7 @@ - + 304 @@ -47,7 +49,7 @@ - + 606 @@ -59,7 +61,7 @@ - + 606 @@ -71,7 +73,7 @@ - + 306 @@ -83,7 +85,7 @@ - + 1322 @@ -99,7 +101,7 @@ - + 511 @@ -111,7 +113,7 @@ - + 841 @@ -127,7 +129,7 @@ - + 902 @@ -143,7 +145,7 @@ - + 708 diff --git a/DDUserManager/DDUserManager/frmADDebug.Designer.vb b/DDUserManager/DDUserManager/frmADDebug.Designer.vb new file mode 100644 index 0000000..b06fb40 --- /dev/null +++ b/DDUserManager/DDUserManager/frmADDebug.Designer.vb @@ -0,0 +1,62 @@ + _ +Partial Class frmADDebug + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.GridControl1 = New DevExpress.XtraGrid.GridControl() + Me.GridView1 = New DevExpress.XtraGrid.Views.Grid.GridView() + CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.GridView1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'GridControl1 + ' + Me.GridControl1.Dock = System.Windows.Forms.DockStyle.Fill + Me.GridControl1.Location = New System.Drawing.Point(0, 0) + Me.GridControl1.MainView = Me.GridView1 + Me.GridControl1.Name = "GridControl1" + Me.GridControl1.Size = New System.Drawing.Size(800, 450) + Me.GridControl1.TabIndex = 1 + Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView1}) + ' + 'GridView1 + ' + Me.GridView1.GridControl = Me.GridControl1 + Me.GridView1.Name = "GridView1" + ' + 'frmADDebug + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Controls.Add(Me.GridControl1) + Me.Name = "frmADDebug" + Me.Text = "frmADDebug" + CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.GridView1, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + + Friend WithEvents GridControl1 As DevExpress.XtraGrid.GridControl + Friend WithEvents GridView1 As DevExpress.XtraGrid.Views.Grid.GridView +End Class diff --git a/DDUserManager/DDUserManager/frmADDebug.resx b/DDUserManager/DDUserManager/frmADDebug.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DDUserManager/DDUserManager/frmADDebug.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DDUserManager/DDUserManager/frmADDebug.vb b/DDUserManager/DDUserManager/frmADDebug.vb new file mode 100644 index 0000000..82f1ade --- /dev/null +++ b/DDUserManager/DDUserManager/frmADDebug.vb @@ -0,0 +1,17 @@ +Imports DDUserManager.ClassActiveDirectory + +Public Class frmADDebug + Public Property DebugData As List(Of GroupResult) + + Private Sub frmADDebug_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Dim table As New UserDataSet.TBLOCAL_DEBUG_GROUPSDataTable() + + For Each group In DebugData + table.AddTBLOCAL_DEBUG_GROUPSRow(group.SAMAccountName, group.CN, group.ObjectClass, group.ObjectCategory, group.Description, group.DistinguishedName, group.Name) + Next + + + Me.Text = $"{table.Rows.Count} Gruppen" + GridControl1.DataSource = table + End Sub +End Class \ No newline at end of file diff --git a/DDUserManager/DDUserManager/frmADImport_Groups.Designer.vb b/DDUserManager/DDUserManager/frmADImport_Groups.Designer.vb index f88cf72..d2cb21f 100644 --- a/DDUserManager/DDUserManager/frmADImport_Groups.Designer.vb +++ b/DDUserManager/DDUserManager/frmADImport_Groups.Designer.vb @@ -31,6 +31,7 @@ Partial Class frmADImport_Groups Me.colGROUPNAME = New DevExpress.XtraGrid.Columns.GridColumn() Me.btnImport = New System.Windows.Forms.Button() Me.DS_ChangeS = New DDUserManager.DS_ChangeS() + Me.lbGroupsCount = New System.Windows.Forms.Label() CType(Me.gridAD_Groups, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TBLOCAL_ADGROUPSBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.UserDataSet, System.ComponentModel.ISupportInitialize).BeginInit() @@ -95,11 +96,21 @@ Partial Class frmADImport_Groups Me.DS_ChangeS.DataSetName = "DS_ChangeS" Me.DS_ChangeS.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema ' + 'lbGroupsCount + ' + Me.lbGroupsCount.AutoSize = True + Me.lbGroupsCount.Location = New System.Drawing.Point(12, 616) + Me.lbGroupsCount.Name = "lbGroupsCount" + Me.lbGroupsCount.Size = New System.Drawing.Size(103, 13) + Me.lbGroupsCount.TabIndex = 2 + Me.lbGroupsCount.Text = "Anzahl Gruppen: {0}" + ' 'frmADImport_Groups ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(1154, 688) + Me.Controls.Add(Me.lbGroupsCount) Me.Controls.Add(Me.btnImport) Me.Controls.Add(Me.gridAD_Groups) Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) @@ -111,6 +122,7 @@ Partial Class frmADImport_Groups CType(Me.viewAD_Groups, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.DS_ChangeS, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) + Me.PerformLayout() End Sub @@ -121,4 +133,5 @@ Partial Class frmADImport_Groups Friend WithEvents colGROUPNAME As DevExpress.XtraGrid.Columns.GridColumn Friend WithEvents btnImport As Button Friend WithEvents DS_ChangeS As DS_ChangeS + Friend WithEvents lbGroupsCount As Label End Class diff --git a/DDUserManager/DDUserManager/frmADImport_Groups.vb b/DDUserManager/DDUserManager/frmADImport_Groups.vb index 0f4ae58..118161b 100644 --- a/DDUserManager/DDUserManager/frmADImport_Groups.vb +++ b/DDUserManager/DDUserManager/frmADImport_Groups.vb @@ -5,14 +5,16 @@ Public Class frmADImport_Groups Private Sub frmADImport_Groups_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try - Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups() + Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(My.Settings.AD_GROUP_QUERY) UserDataSet.TBLOCAL_ADGROUPS.Clear() - For Each group In groups - UserDataSet.TBLOCAL_ADGROUPS.AddTBLOCAL_ADGROUPSRow(group) + For Each group As ClassActiveDirectory.GroupResult In groups + UserDataSet.TBLOCAL_ADGROUPS.AddTBLOCAL_ADGROUPSRow(group.SAMAccountName) Next + lbGroupsCount.Text = String.Format(lbGroupsCount.Text, UserDataSet.TBLOCAL_ADGROUPS.Rows.Count) + gridAD_Groups.DataSource = UserDataSet.TBLOCAL_ADGROUPS Catch ex As Exception logger.Error(ex, "Error while loading initial groups") diff --git a/DDUserManager/DDUserManager/frmADImport_Users.vb b/DDUserManager/DDUserManager/frmADImport_Users.vb index fbfa5e4..94408a5 100644 --- a/DDUserManager/DDUserManager/frmADImport_Users.vb +++ b/DDUserManager/DDUserManager/frmADImport_Users.vb @@ -10,9 +10,11 @@ Public Class frmADImport_Users Private Sub frmADImport_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try - Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups() + Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(My.Settings.AD_GROUP_QUERY) - gridAD_Groups.DataSource = groups + gridAD_Groups.DataSource = groups.Select(Of String)(Function(g) + Return g.SAMAccountName + End Function) viewAD_Groups.Columns.Item(0).Caption = "Gruppe" Catch ex As Exception logger.Error(ex, $"Error while loading initial groups") diff --git a/DDUserManager/DDUserManager/frmMain.Designer.vb b/DDUserManager/DDUserManager/frmMain.Designer.vb index 38bec39..4690db5 100644 --- a/DDUserManager/DDUserManager/frmMain.Designer.vb +++ b/DDUserManager/DDUserManager/frmMain.Designer.vb @@ -326,6 +326,9 @@ Partial Class frmMain Me.tabPageRights = New DevExpress.XtraTab.XtraTabPage() Me.tabPageSettings = New DevExpress.XtraTab.XtraTabPage() Me.Button2 = New System.Windows.Forms.Button() + Me.GroupBox2 = New System.Windows.Forms.GroupBox() + Me.btnDebugGroupQuery = New System.Windows.Forms.Button() + Me.txtLDAPGroupQuery = New System.Windows.Forms.TextBox() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.btnADConnectionTest = New System.Windows.Forms.Button() Me.txtADRootNode = New System.Windows.Forms.TextBox() @@ -352,6 +355,7 @@ Partial Class frmMain Me.TBDD_GROUPSTableAdapter = New DDUserManager.DS_ChangeSTableAdapters.TBDD_GROUPSTableAdapter() Me.TableAdapterManager1 = New DDUserManager.DS_ChangeSTableAdapters.TableAdapterManager() Me.TBDD_GROUPS_USERTableAdapter = New DDUserManager.UserDataSetTableAdapters.TBDD_GROUPS_USERTableAdapter() + Me.QueriesTableAdapter1 = New DDUserManager.UserDataSetTableAdapters.QueriesTableAdapter() GUIDLabel = New System.Windows.Forms.Label() PRENAMELabel = New System.Windows.Forms.Label() NAMELabel = New System.Windows.Forms.Label() @@ -507,6 +511,7 @@ Partial Class frmMain CType(Me.TBDD_MODULESBindingNavigator, System.ComponentModel.ISupportInitialize).BeginInit() Me.TBDD_MODULESBindingNavigator.SuspendLayout() Me.tabPageSettings.SuspendLayout() + Me.GroupBox2.SuspendLayout() Me.GroupBox1.SuspendLayout() CType(Me.TBDD_GROUPS_USERBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TBDD_CLIENT_USERBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() @@ -2055,7 +2060,7 @@ Partial Class frmMain Me.TBDD_USERBindingNavigator.BindingSource = Me.TBDD_USERBindingSource Me.TBDD_USERBindingNavigator.CountItem = Me.BindingNavigatorCountItem Me.TBDD_USERBindingNavigator.CountItemFormat = "von {0} Benutzern" - Me.TBDD_USERBindingNavigator.DeleteItem = Me.BindingNavigatorDeleteItem + Me.TBDD_USERBindingNavigator.DeleteItem = Nothing Me.TBDD_USERBindingNavigator.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BindingNavigatorMoveFirstItem, Me.BindingNavigatorMovePreviousItem, Me.BindingNavigatorSeparator, Me.BindingNavigatorPositionItem, Me.BindingNavigatorCountItem, Me.BindingNavigatorSeparator1, Me.BindingNavigatorMoveNextItem, Me.BindingNavigatorMoveLastItem, Me.BindingNavigatorSeparator2, Me.BindingNavigatorAddNewItem, Me.BindingNavigatorDeleteItem, Me.TBDD_USERBindingNavigatorSaveItem, Me.btnImportUsers, Me.ToolStripButton2}) Me.TBDD_USERBindingNavigator.Location = New System.Drawing.Point(0, 0) Me.TBDD_USERBindingNavigator.MoveFirstItem = Me.BindingNavigatorMoveFirstItem @@ -3495,6 +3500,7 @@ Partial Class frmMain 'tabPageSettings ' Me.tabPageSettings.Controls.Add(Me.Button2) + Me.tabPageSettings.Controls.Add(Me.GroupBox2) Me.tabPageSettings.Controls.Add(Me.GroupBox1) Me.tabPageSettings.Controls.Add(Me.btnOpenLogDir) Me.tabPageSettings.Controls.Add(Me.btnOpenConfigDir) @@ -3515,6 +3521,36 @@ Partial Class frmMain Me.Button2.Text = "Support Tool aufrufen" Me.Button2.UseVisualStyleBackColor = True ' + 'GroupBox2 + ' + Me.GroupBox2.Controls.Add(Me.btnDebugGroupQuery) + Me.GroupBox2.Controls.Add(Me.txtLDAPGroupQuery) + Me.GroupBox2.Location = New System.Drawing.Point(486, 17) + Me.GroupBox2.Name = "GroupBox2" + Me.GroupBox2.Size = New System.Drawing.Size(700, 200) + Me.GroupBox2.TabIndex = 5 + Me.GroupBox2.TabStop = False + Me.GroupBox2.Text = "LDAP Gruppenabfrage" + ' + 'btnDebugGroupQuery + ' + Me.btnDebugGroupQuery.Location = New System.Drawing.Point(556, 171) + Me.btnDebugGroupQuery.Name = "btnDebugGroupQuery" + Me.btnDebugGroupQuery.Size = New System.Drawing.Size(138, 23) + Me.btnDebugGroupQuery.TabIndex = 6 + Me.btnDebugGroupQuery.Text = "Abfrage starten" + Me.btnDebugGroupQuery.UseVisualStyleBackColor = True + ' + 'txtLDAPGroupQuery + ' + Me.txtLDAPGroupQuery.Location = New System.Drawing.Point(6, 20) + Me.txtLDAPGroupQuery.Multiline = True + Me.txtLDAPGroupQuery.Name = "txtLDAPGroupQuery" + Me.txtLDAPGroupQuery.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtLDAPGroupQuery.Size = New System.Drawing.Size(688, 145) + Me.txtLDAPGroupQuery.TabIndex = 2 + Me.txtLDAPGroupQuery.Text = "(&(objectClass=group) (samAccountName=*))" + ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.btnADConnectionTest) @@ -3839,6 +3875,8 @@ Partial Class frmMain Me.TBDD_MODULESBindingNavigator.ResumeLayout(False) Me.TBDD_MODULESBindingNavigator.PerformLayout() Me.tabPageSettings.ResumeLayout(False) + Me.GroupBox2.ResumeLayout(False) + Me.GroupBox2.PerformLayout() Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() CType(Me.TBDD_GROUPS_USERBindingSource, System.ComponentModel.ISupportInitialize).EndInit() @@ -4147,4 +4185,8 @@ Partial Class frmMain Friend WithEvents GroupBox1 As GroupBox Friend WithEvents btnADConnectionTest As Button Friend WithEvents Button2 As Button + Friend WithEvents GroupBox2 As GroupBox + Friend WithEvents btnDebugGroupQuery As Button + Friend WithEvents txtLDAPGroupQuery As TextBox + Friend WithEvents QueriesTableAdapter1 As UserDataSetTableAdapters.QueriesTableAdapter End Class diff --git a/DDUserManager/DDUserManager/frmMain.resx b/DDUserManager/DDUserManager/frmMain.resx index 3c5e5c9..6313187 100644 --- a/DDUserManager/DDUserManager/frmMain.resx +++ b/DDUserManager/DDUserManager/frmMain.resx @@ -220,7 +220,7 @@ 17, 17 - 469, 95 + 642, 95 489, 56 @@ -229,10 +229,10 @@ 911, 56 - 1026, 134 + 17, 173 - 906, 134 + 1162, 134 693, 17 @@ -248,18 +248,6 @@ zpX/v6RC8f/fWzFAjeH/p+Zp/J+QpfW/O0P3f3uq/v/mREPCYTIb6E+Qc//dCPjfk6FDWAM6APnz3w1/ IPb735qsT7oB3em6YP+CcH2cEekGtCQZ/G+IN/xfE2v8vzLahHQD6AQYGAAkI9iedfyIaQAAAABJRU5E rkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - wwAADsMBx2+oZAAAAW9JREFUOE+1kE0ow2Ecx3dV3krt4oJaOSCTvIRkMqSxyITIzCQHDouEdnFwIOVC - DrhIDiQl5UTiNG/z2ppafy1S2gX/uDwfY6i1v7Hie3nqeb7fz+/7/FR/Ilwn0G0Exw4fV5GJlXlEZxXC - rIet9bAQvB5Ymgn2sLYAvSZEux7RUQFzE4qQt4bCXAYjPaHvnDoCkLpsRGMB2JqCTGLIijDlwqQ9bEMV - i9OIytR3EMNWcJ/BWH8A6j8/bOGFxwXNxYEvGbMQ9XnQ1/K78KfY3/VXzkMY0qFGG2H4RoLGQshJQNbG - 86CNhdrsX9a/uQZTPhQl4rMY4OLofbl3aX7I8uwPC7y/g1YdjyVJuEvT8e1tfwUYteHUxCCfHChDeHmG - QQvokjlOU+PbWA0x3pZnILVVI3uvQyHsbiLnqnGmRCF1NYD8pDhpRxOH7HQoAKZGkFKjceszQbpSrumX - bO+G80MFwKUTxgfgcO/b8D9IpXoFiiMDHIQm0skAAAAASUVORK5CYII= @@ -300,6 +288,18 @@ kqub/+6/S/4B3AZ4VN3/XzL3HVyzoksPXDFILn/am//2GdtxG2Bfevd/YMszDM0gAJLLnvz6v0XCetwG WOTd+W9TcAVDMwiA5FL7X8O9hBUYZt3GqhkEQHJhLS//6wbPw22ATtoNnJIgOb/qh/81fKfhNgAfcMq9 8l/FYwIYQ4UGBWBgAAC+0b+zuQxOnAAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wwAADsMBx2+oZAAAAW9JREFUOE+1kE0ow2Ecx3dV3krt4oJaOSCTvIRkMqSxyITIzCQHDouEdnFwIOVC + DrhIDiQl5UTiNG/z2ppafy1S2gX/uDwfY6i1v7Hie3nqeb7fz+/7/FR/Ilwn0G0Exw4fV5GJlXlEZxXC + rIet9bAQvB5Ymgn2sLYAvSZEux7RUQFzE4qQt4bCXAYjPaHvnDoCkLpsRGMB2JqCTGLIijDlwqQ9bEMV + i9OIytR3EMNWcJ/BWH8A6j8/bOGFxwXNxYEvGbMQ9XnQ1/K78KfY3/VXzkMY0qFGG2H4RoLGQshJQNbG + 86CNhdrsX9a/uQZTPhQl4rMY4OLofbl3aX7I8uwPC7y/g1YdjyVJuEvT8e1tfwUYteHUxCCfHChDeHmG + QQvokjlOU+PbWA0x3pZnILVVI3uvQyHsbiLnqnGmRCF1NYD8pDhpRxOH7HQoAKZGkFKjceszQbpSrumX + bO+G80MFwKUTxgfgcO/b8D9IpXoFiiMDHIQm0skAAAAASUVORK5CYII= @@ -310,7 +310,7 @@ - 17, 95 + 190, 95 @@ -403,7 +403,7 @@ - 247, 95 + 420, 95 @@ -477,7 +477,7 @@ - 909, 95 + 1082, 95 @@ -538,32 +538,35 @@ 1116, 56 - 692, 95 + 865, 95 - 1148, 95 - - 17, 134 + + 273, 134 + - 268, 134 + 524, 134 - 385, 134 + 641, 134 - 654, 134 + 910, 134 - 1246, 134 + 237, 173 - 17, 173 + 445, 173 1152, 17 + + 17, 95 + 198 diff --git a/DDUserManager/DDUserManager/frmMain.vb b/DDUserManager/DDUserManager/frmMain.vb index d31cc8d..92711ec 100644 --- a/DDUserManager/DDUserManager/frmMain.vb +++ b/DDUserManager/DDUserManager/frmMain.vb @@ -3,6 +3,7 @@ Imports DevExpress.XtraGrid.Views.Grid Imports DDUserManager.UserDataSet Imports DDUserManager.DS_ChangeS Imports DD_LIB_Standards +Imports System.Reflection ''' ''' Anmerkungen: @@ -14,6 +15,7 @@ Public Class frmMain Private CurrentUser As TBDD_USERRow = Nothing Private CurrentUserId As Integer + Private CurrentVersion As String Private DragDropManager As ClassDragDrop = Nothing @@ -22,8 +24,12 @@ Public Class frmMain Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try NLog.LogManager.Configuration = ClassNLog.GetLoggerConfigFor(MODULE_NAME) + CurrentVersion = Assembly.GetEntryAssembly().GetName().Version.ToString() - logger.Info("Starting UserManager v" & Application.ProductVersion) + txtLDAPGroupQuery.DataBindings.Add(New Binding("Text", My.Settings, "AD_GROUP_QUERY")) + + + logger.Info("Starting UserManager v" & CurrentVersion) logger.Info($"Current Username: {Environment.UserName}") If InitDatabase() = False Then @@ -75,7 +81,7 @@ Public Class frmMain End If tsLabelUser.Text = $"Angemeldeter Benutzer: {Environment.UserName}" - tsLabelVersion.Text = $"Version {Application.ProductVersion}" + tsLabelVersion.Text = $"Version {CurrentVersion}" lblADRootNode.Text = String.Format(lblADRootNode.Text, Environment.UserDomainName) txtADRootNode.Text = ActiveDirectoryRootNode @@ -393,11 +399,8 @@ Public Class frmMain Private Function GetAssignedUsersByGroupId(groupId As Integer) As TBDD_USERDataTable Try Dim dt As New TBDD_USERDataTable() - Dim sql = String.Format("SELECT T1.GUID, T1.PRENAME, T1.NAME, T1.USERNAME, T1.SHORTNAME, T1.EMAIL, T1.LANGUAGE, T1.COMMENT, T1.DATE_FORMAT, T1.ADDED_WHO, T1.ADDED_WHEN, T1.CHANGED_WHO, T1.CHANGED_WHEN " & -"FROM TBDD_USER AS T1 INNER JOIN " & -" TBDD_GROUPS_USER AS T2 ON T1.GUID = T2.USER_ID " & -"WHERE (T2.GROUP_ID = {0})", groupId) - clsDatabase.Return_Datatable(sql) + TBDD_USERTableAdapter.FillByGroupId(dt, groupId) + Return dt Catch ex As Exception ShowErrorMessage($"Error in GetAssignedUsersByGroupId with groupId {groupId}", ex) @@ -1066,7 +1069,7 @@ Public Class frmMain Process.Start(ClassNLog.GetLogPathFor(MODULE_NAME)) End Sub - Private Sub txtADRootNode_Leave(sender As Object, e As EventArgs) Handles txtADRootNode.Leave + Private Sub txtADRootNode_Leave(sender As Object, e As EventArgs) Handles txtADRootNode.Leave, txtLDAPGroupQuery.Leave SaveMySettingsValue("ActiveDirectoryRootNode", txtADRootNode.Text, "ConfigMain") End Sub @@ -1086,4 +1089,38 @@ Public Class frmMain Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Process.Start("https://didalog.de/support") End Sub + + Private Async Sub btnDebugQuery_Click(sender As Object, e As EventArgs) Handles btnDebugGroupQuery.Click + My.Settings.Save() + + btnDebugGroupQuery.Text = "Abfrage läuft..." + btnDebugGroupQuery.Enabled = False + + Await Task.Run(Sub() + Dim groups = ClassActiveDirectory.GetActiveDirectoryGroups(txtLDAPGroupQuery.Text) + Dim frm As New frmADDebug() + frm.DebugData = groups + frm.ShowDialog() + + + End Sub) + + btnDebugGroupQuery.Text = "Abfrage starten" + btnDebugGroupQuery.Enabled = True + End Sub + + Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorDeleteItem.Click + Dim oUsername = USERNAMETextBox.Text + Dim oUserId As Integer = GUIDTextBox.Text + Dim oMessage = String.Format("Wollen sie den Benutzer {0} löschen?", oUsername) + + If MessageBox.Show(oMessage, "Benutzer löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then + If QueriesTableAdapter1.PRDD_DELETE_USER(oUserId) = -1 Then + MessageBox.Show("Fehler beim Löschen des Benutzers.", "Benutzer löschen", MessageBoxButtons.OK, MessageBoxIcon.Warning) + Else + UpdateSavedLabel() + LoadData() + End If + End If + End Sub End Class diff --git a/DDUserManager/SetupWix/Product.wxs b/DDUserManager/SetupWix/Product.wxs index 55b23ae..c4e01db 100644 --- a/DDUserManager/SetupWix/Product.wxs +++ b/DDUserManager/SetupWix/Product.wxs @@ -80,6 +80,7 @@ + @@ -108,6 +109,10 @@ + + + +