Much stuff
This commit is contained in:
@@ -129,6 +129,14 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Jobs\Jobs.vbproj">
|
||||
<Project>{39ec839a-3c30-4922-a41e-6b09d1dde5c3}</Project>
|
||||
<Name>Jobs</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Database\Database.vbproj">
|
||||
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
|
||||
<Name>Database</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Interfaces\Interfaces.vbproj">
|
||||
<Project>{AB6F09BF-E794-4F6A-94BB-C97C0BA84D64}</Project>
|
||||
<Name>Interfaces</Name>
|
||||
|
||||
37
ADSyncTest/Form1.Designer.vb
generated
37
ADSyncTest/Form1.Designer.vb
generated
@@ -24,6 +24,9 @@ Partial Class Form1
|
||||
Private Sub InitializeComponent()
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.ListBox1 = New System.Windows.Forms.ListBox()
|
||||
Me.ListBox2 = New System.Windows.Forms.ListBox()
|
||||
Me.Button2 = New System.Windows.Forms.Button()
|
||||
Me.Button3 = New System.Windows.Forms.Button()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'Button1
|
||||
@@ -40,14 +43,43 @@ Partial Class Form1
|
||||
Me.ListBox1.FormattingEnabled = True
|
||||
Me.ListBox1.Location = New System.Drawing.Point(245, 12)
|
||||
Me.ListBox1.Name = "ListBox1"
|
||||
Me.ListBox1.Size = New System.Drawing.Size(543, 420)
|
||||
Me.ListBox1.Size = New System.Drawing.Size(244, 420)
|
||||
Me.ListBox1.TabIndex = 1
|
||||
'
|
||||
'ListBox2
|
||||
'
|
||||
Me.ListBox2.FormattingEnabled = True
|
||||
Me.ListBox2.Location = New System.Drawing.Point(495, 12)
|
||||
Me.ListBox2.Name = "ListBox2"
|
||||
Me.ListBox2.Size = New System.Drawing.Size(266, 420)
|
||||
Me.ListBox2.TabIndex = 2
|
||||
'
|
||||
'Button2
|
||||
'
|
||||
Me.Button2.Location = New System.Drawing.Point(12, 70)
|
||||
Me.Button2.Name = "Button2"
|
||||
Me.Button2.Size = New System.Drawing.Size(227, 38)
|
||||
Me.Button2.TabIndex = 3
|
||||
Me.Button2.Text = "List Groups"
|
||||
Me.Button2.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Button3
|
||||
'
|
||||
Me.Button3.Location = New System.Drawing.Point(12, 114)
|
||||
Me.Button3.Name = "Button3"
|
||||
Me.Button3.Size = New System.Drawing.Size(227, 35)
|
||||
Me.Button3.TabIndex = 4
|
||||
Me.Button3.Text = "List Users for selected Group"
|
||||
Me.Button3.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
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.Button3)
|
||||
Me.Controls.Add(Me.Button2)
|
||||
Me.Controls.Add(Me.ListBox2)
|
||||
Me.Controls.Add(Me.ListBox1)
|
||||
Me.Controls.Add(Me.Button1)
|
||||
Me.Name = "Form1"
|
||||
@@ -58,4 +90,7 @@ Partial Class Form1
|
||||
|
||||
Friend WithEvents Button1 As Button
|
||||
Friend WithEvents ListBox1 As ListBox
|
||||
Friend WithEvents ListBox2 As ListBox
|
||||
Friend WithEvents Button2 As Button
|
||||
Friend WithEvents Button3 As Button
|
||||
End Class
|
||||
|
||||
@@ -1,21 +1,85 @@
|
||||
Imports DigitalData.Modules.Interfaces
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Interfaces.ActiveDirectoryInterface
|
||||
Imports DigitalData.Modules.Database
|
||||
|
||||
Public Class Form1
|
||||
Private _sync As ActiveDirectoryInterface
|
||||
Private _logConfig As LogConfig
|
||||
Private _logger As Logger
|
||||
Private _firebird As Firebird
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
_logConfig = New LogConfig(LogConfig.PathType.CurrentDirectory)
|
||||
_logConfig.Debug = True
|
||||
_logger = _logConfig.GetLogger()
|
||||
_sync = New ActiveDirectoryInterface(_logConfig)
|
||||
_firebird = New Firebird(_logConfig, "172.24.12.41", "172.24.12.41:E:\DB\Firebird\Databases\DD_ICM.fdb", "sysdba", "dd")
|
||||
|
||||
_sync = New ActiveDirectoryInterface(_logConfig, _firebird)
|
||||
_sync.Authenticate()
|
||||
|
||||
Dim oType As Type = Type.GetType("DigitalData.Modules.Jobs.ADSyncJob")
|
||||
Activator.CreateInstance(oType)
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Dim oGroup As String = ListBox1.SelectedItem
|
||||
_sync.SyncUsersForGroup(oGroup)
|
||||
|
||||
'' 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
|
||||
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||
Dim oGroups = _sync.ListGroups()
|
||||
|
||||
For Each oGroup In oGroups
|
||||
ListBox1.Items.Add(oGroup.SAMAccountName)
|
||||
ListBox1.Items.Add(oGroup.Name)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
||||
Dim oGroup As String = ListBox1.SelectedItem
|
||||
Dim oUsers = _sync.ListUsers(oGroup)
|
||||
|
||||
ListBox2.Items.Clear()
|
||||
For Each oUser In oUsers
|
||||
ListBox2.Items.Add(oUser.samAccountName)
|
||||
Next
|
||||
|
||||
If oUsers.Count = 0 Then
|
||||
ListBox2.Items.Add("No users found ¯\_(ツ)_/¯")
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user