update adsync test gui
This commit is contained in:
parent
f68e5cf19f
commit
2296b31519
7
GUIs.Test.ADSyncTest/ADConfig.vb
Normal file
7
GUIs.Test.ADSyncTest/ADConfig.vb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Friend Class ADConfig
|
||||||
|
|
||||||
|
Public Class AttributeMap
|
||||||
|
Public AttributeName As String
|
||||||
|
Public ColumnName As String
|
||||||
|
End Class
|
||||||
|
End Class
|
||||||
@ -81,6 +81,7 @@
|
|||||||
<Import Include="System.Threading.Tasks" />
|
<Import Include="System.Threading.Tasks" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ADConfig.vb" />
|
||||||
<Compile Include="Form1.vb">
|
<Compile Include="Form1.vb">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -133,6 +134,10 @@
|
|||||||
<Project>{39ec839a-3c30-4922-a41e-6b09d1dde5c3}</Project>
|
<Project>{39ec839a-3c30-4922-a41e-6b09d1dde5c3}</Project>
|
||||||
<Name>Jobs</Name>
|
<Name>Jobs</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Modules.Config\Config.vbproj">
|
||||||
|
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
|
||||||
|
<Name>Config</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Modules.Database\Database.vbproj">
|
<ProjectReference Include="..\Modules.Database\Database.vbproj">
|
||||||
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
|
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
|
||||||
<Name>Database</Name>
|
<Name>Database</Name>
|
||||||
|
|||||||
@ -1,64 +1,33 @@
|
|||||||
Imports DigitalData.Modules.Interfaces
|
Imports DigitalData.Modules.Interfaces
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports DigitalData.Modules.Interfaces.ActiveDirectoryInterface
|
|
||||||
Imports DigitalData.Modules.Database
|
Imports DigitalData.Modules.Database
|
||||||
|
Imports DigitalData.Modules.Config
|
||||||
|
|
||||||
Public Class Form1
|
Public Class Form1
|
||||||
Private _sync As ActiveDirectoryInterface
|
Private _sync As ActiveDirectoryInterface
|
||||||
Private _logConfig As LogConfig
|
Private _logConfig As LogConfig
|
||||||
Private _logger As Logger
|
Private _logger As Logger
|
||||||
Private _firebird As Firebird
|
Private _firebird As Firebird
|
||||||
|
Private _sql As MSSQLServer
|
||||||
|
Private _configManager As ConfigManager(Of ADConfig)
|
||||||
|
|
||||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
_logConfig = New LogConfig(LogConfig.PathType.CurrentDirectory)
|
_logConfig = New LogConfig(LogConfig.PathType.CurrentDirectory)
|
||||||
_logConfig.Debug = True
|
_logConfig.Debug = True
|
||||||
_logger = _logConfig.GetLogger()
|
_logger = _logConfig.GetLogger()
|
||||||
_firebird = New Firebird(_logConfig, "172.24.12.41", "172.24.12.41:E:\DB\Firebird\Databases\DD_ICM.fdb", "sysdba", "dd")
|
_firebird = New Firebird(_logConfig, "172.24.12.41", "172.24.12.41:E:\DB\Firebird\Databases\DD_ICM.fdb", "sysdba", "dd")
|
||||||
|
_sql = New MSSQLServer(_logConfig, "Server=172.24.12.41\tests;Database=DD_ECM_TEST;User Id=sa; Password=dd")
|
||||||
|
|
||||||
_sync = New ActiveDirectoryInterface(_logConfig, _firebird)
|
_sync = New ActiveDirectoryInterface(_logConfig, Nothing, _sql)
|
||||||
_sync.Authenticate()
|
_sync.Authenticate()
|
||||||
|
|
||||||
Dim oType As Type = Type.GetType("DigitalData.Modules.Jobs.ADSyncJob")
|
|
||||||
Activator.CreateInstance(oType)
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||||
Dim oGroup As String = ListBox1.SelectedItem
|
Dim oGroup As String = ListBox1.SelectedItem
|
||||||
_sync.SyncUsersForGroup(oGroup)
|
Dim oAttributeMappings = GetAttributeMappings()
|
||||||
|
_sync.SyncUsersForGroup(oGroup, oAttributeMappings)
|
||||||
'' STEP 1: Get all Groups that have AD_SYNC enabled
|
|
||||||
'Dim oSQL As String = $"SELECT RECORD_ID, GROUP_NAME FROM VWICM_GROUP WHERE AD_SYNC = 1"
|
|
||||||
'Dim oResult As DataTable = _firebird.GetDatatable(oSQL)
|
|
||||||
|
|
||||||
|
|
||||||
'For Each oRow As DataRow In oResult.Rows
|
|
||||||
' Dim oGroupName As String = oRow.Item("GROUP_NAME")
|
|
||||||
' Dim oGroupId As Int64 = oRow.Item("RECORD_ID")
|
|
||||||
|
|
||||||
' ' STEP 2: List all Users for that Group
|
|
||||||
' Dim oUsers As List(Of ADUser) = _sync.ListUsers(oGroupName)
|
|
||||||
|
|
||||||
' For Each oUser In oUsers
|
|
||||||
' ' STEP 3: Check if user exists in DB
|
|
||||||
' oSQL = $"SELECT FNICM_GET_RECORD4SYSKEY('{oUser.samAccountName}','001-USRNAME') from RDB$DATABASE"
|
|
||||||
' Dim oResult2 = _firebird.GetScalarValue(oSQL)
|
|
||||||
' Dim oUserId
|
|
||||||
|
|
||||||
' ' STEP 3.A: If user does not exists, create and add to group
|
|
||||||
' If IsDBNull(oResult2) Then
|
|
||||||
' 'Create user
|
|
||||||
' oSQL = $"SELECT FNICM_RADM_NEW_USER('{oUser.GivenName}', '{oUser.Surname}', '{oUser.samAccountName}', 'AD-Sync') from RDB$DATABASE"
|
|
||||||
' Dim oResult3 = _firebird.GetScalarValue(oSQL)
|
|
||||||
' oUserId = oResult3
|
|
||||||
' Else
|
|
||||||
' oUserId = oResult2
|
|
||||||
' End If
|
|
||||||
|
|
||||||
' ' STEP 4: Add user to group
|
|
||||||
' oSQL = $"SELECT FNICM_RADM_NEW_USER2GROUP({oUserId}, {oGroupId}, 'AD-Sync') from RDB$DATABASE"
|
|
||||||
' Dim oResult4 = _firebird.GetScalarValue(oSQL)
|
|
||||||
' Next
|
|
||||||
'Next
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||||
@ -71,7 +40,9 @@ Public Class Form1
|
|||||||
|
|
||||||
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
||||||
Dim oGroup As String = ListBox1.SelectedItem
|
Dim oGroup As String = ListBox1.SelectedItem
|
||||||
Dim oUsers = _sync.ListUsers(oGroup)
|
Dim oAttributeMappings = GetAttributeMappings()
|
||||||
|
|
||||||
|
Dim oUsers = _sync.ListUsers(oGroup, oAttributeMappings)
|
||||||
|
|
||||||
ListBox2.Items.Clear()
|
ListBox2.Items.Clear()
|
||||||
For Each oUser In oUsers
|
For Each oUser In oUsers
|
||||||
@ -82,4 +53,22 @@ Public Class Form1
|
|||||||
ListBox2.Items.Add("No users found ¯\_(ツ)_/¯")
|
ListBox2.Items.Add("No users found ¯\_(ツ)_/¯")
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function GetAttributeMappings() As List(Of AttributeMapping)
|
||||||
|
Dim oDatatable = _sql.GetDatatable("SELECT * FROM TBDD_EXTATTRIBUTES_MATCHING")
|
||||||
|
|
||||||
|
Dim oAttributeMappings = New List(Of AttributeMapping)
|
||||||
|
|
||||||
|
For Each oRow As DataRow In oDatatable.Rows
|
||||||
|
oAttributeMappings.Add(New AttributeMapping() With {
|
||||||
|
.AttributeName = oRow.Item("EXT_ATTRIBUTE"),
|
||||||
|
.FirebirdSyskey = oRow.Item("FB_SYS_KEY"),
|
||||||
|
.MSSQLColumn = oRow.Item("TBDD_USER_COLUMN")
|
||||||
|
})
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return oAttributeMappings
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user