fix group filtering while importing users
This commit is contained in:
parent
7cd1acb356
commit
97c628dfab
@ -37,6 +37,7 @@ Partial Class frmADImport_Users
|
|||||||
Me.colEMAIL = New DevExpress.XtraGrid.Columns.GridColumn()
|
Me.colEMAIL = New DevExpress.XtraGrid.Columns.GridColumn()
|
||||||
Me.Panel1 = New System.Windows.Forms.Panel()
|
Me.Panel1 = New System.Windows.Forms.Panel()
|
||||||
Me.btnImport = New System.Windows.Forms.Button()
|
Me.btnImport = New System.Windows.Forms.Button()
|
||||||
|
Me.colGroupName = New DevExpress.XtraGrid.Columns.GridColumn()
|
||||||
CType(Me.gridAD_Groups, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.gridAD_Groups, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(Me.viewAD_Groups, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.viewAD_Groups, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
CType(Me.gridAD_Users, System.ComponentModel.ISupportInitialize).BeginInit()
|
CType(Me.gridAD_Users, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||||
@ -58,6 +59,7 @@ Partial Class frmADImport_Users
|
|||||||
'
|
'
|
||||||
'viewAD_Groups
|
'viewAD_Groups
|
||||||
'
|
'
|
||||||
|
Me.viewAD_Groups.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.colGroupName})
|
||||||
Me.viewAD_Groups.GridControl = Me.gridAD_Groups
|
Me.viewAD_Groups.GridControl = Me.gridAD_Groups
|
||||||
Me.viewAD_Groups.Name = "viewAD_Groups"
|
Me.viewAD_Groups.Name = "viewAD_Groups"
|
||||||
Me.viewAD_Groups.OptionsBehavior.Editable = False
|
Me.viewAD_Groups.OptionsBehavior.Editable = False
|
||||||
@ -164,6 +166,15 @@ Partial Class frmADImport_Users
|
|||||||
Me.btnImport.Text = "Import starten"
|
Me.btnImport.Text = "Import starten"
|
||||||
Me.btnImport.UseVisualStyleBackColor = True
|
Me.btnImport.UseVisualStyleBackColor = True
|
||||||
'
|
'
|
||||||
|
'colGroupName
|
||||||
|
'
|
||||||
|
Me.colGroupName.Caption = "Gruppe"
|
||||||
|
Me.colGroupName.FieldName = "Name"
|
||||||
|
Me.colGroupName.Name = "colGroupName"
|
||||||
|
Me.colGroupName.UnboundType = DevExpress.Data.UnboundColumnType.[String]
|
||||||
|
Me.colGroupName.Visible = True
|
||||||
|
Me.colGroupName.VisibleIndex = 0
|
||||||
|
'
|
||||||
'frmADImport_Users
|
'frmADImport_Users
|
||||||
'
|
'
|
||||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||||
@ -199,4 +210,5 @@ Partial Class frmADImport_Users
|
|||||||
Friend WithEvents colSELECTED As DevExpress.XtraGrid.Columns.GridColumn
|
Friend WithEvents colSELECTED As DevExpress.XtraGrid.Columns.GridColumn
|
||||||
Friend WithEvents btnImport As Button
|
Friend WithEvents btnImport As Button
|
||||||
Friend WithEvents Panel1 As Panel
|
Friend WithEvents Panel1 As Panel
|
||||||
|
Friend WithEvents colGroupName As DevExpress.XtraGrid.Columns.GridColumn
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -18,7 +18,8 @@ Public Class frmADImport_Users
|
|||||||
|
|
||||||
Dim oGroups = activeDirectory.ListGroups(MyConfig.Config.AdGroupFilter)
|
Dim oGroups = activeDirectory.ListGroups(MyConfig.Config.AdGroupFilter)
|
||||||
|
|
||||||
gridAD_Groups.DataSource = oGroups.Select(Function(g) g.SAMAccountName)
|
'gridAD_Groups.DataSource = oGroups.Select(Function(g) g.SAMAccountName)
|
||||||
|
gridAD_Groups.DataSource = oGroups
|
||||||
viewAD_Groups.Columns.Item(0).Caption = "Gruppe"
|
viewAD_Groups.Columns.Item(0).Caption = "Gruppe"
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
logger.Error(ex, $"Error while loading initial groups")
|
logger.Error(ex, $"Error while loading initial groups")
|
||||||
@ -27,10 +28,18 @@ Public Class frmADImport_Users
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub gridADGroups_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles viewAD_Groups.FocusedRowChanged
|
Private Sub gridADGroups_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles viewAD_Groups.FocusedRowChanged
|
||||||
Dim groupName As String = viewAD_Groups.GetRow(e.FocusedRowHandle)
|
Dim oGroup As ADGroup = Nothing
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim oUsers = activeDirectory.ListUsers(groupName, MyConfig.Config.AdUserFilter)
|
oGroup = viewAD_Groups.GetRow(e.FocusedRowHandle)
|
||||||
|
Catch ex As Exception
|
||||||
|
logger.Error(ex, $"Error while loading focused group")
|
||||||
|
MsgBox($"Error while loading focused group", MsgBoxStyle.Critical, Text)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
If Not IsNothing(oGroup) Then
|
||||||
|
Try
|
||||||
|
Dim oUsers = activeDirectory.ListUsers(oGroup.Name, MyConfig.Config.AdUserFilter)
|
||||||
|
|
||||||
UserDataSet.TBLOCAL_ADUSERS.Clear()
|
UserDataSet.TBLOCAL_ADUSERS.Clear()
|
||||||
|
|
||||||
@ -47,9 +56,10 @@ Public Class frmADImport_Users
|
|||||||
|
|
||||||
TBLOCAL_ADUSERSBindingSource.DataSource = UserDataSet.TBLOCAL_ADUSERS
|
TBLOCAL_ADUSERSBindingSource.DataSource = UserDataSet.TBLOCAL_ADUSERS
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
logger.Error(ex, $"Error while loading users for group {groupName}")
|
logger.Error(ex, $"Error while loading users for group {oGroup.Name}")
|
||||||
MsgBox($"Error while loading users for group {groupName}")
|
MsgBox($"Error while loading users for group {oGroup.Name}")
|
||||||
End Try
|
End Try
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnImport_Click(sender As Object, e As EventArgs) Handles btnImport.Click
|
Private Sub btnImport_Click(sender As Object, e As EventArgs) Handles btnImport.Click
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user