first pass of jobrunner with adsync

This commit is contained in:
Jonathan Jenne 2019-04-10 11:58:17 +02:00
parent 2855cc6208
commit dee5d33bb9
2 changed files with 23 additions and 8 deletions

View File

@ -1,4 +1,5 @@
Imports DigitalData.Modules.Database Imports System.Collections.Generic
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Interfaces Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Jobs Imports DigitalData.Modules.Jobs
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
@ -7,23 +8,38 @@ Public Class ADSyncJob
Inherits JobBase Inherits JobBase
Implements IJob(Of ADSyncArgs) Implements IJob(Of ADSyncArgs)
Private _ADSync As ActiveDirectoryInterface
Public Sub New(LogConfig As LogConfig, Firebird As Firebird) Public Sub New(LogConfig As LogConfig, Firebird As Firebird)
MyBase.New(LogConfig, Firebird) MyBase.New(LogConfig, Firebird)
End Sub End Sub
Public Sub Start(Arguments As ADSyncArgs) Implements IJob(Of ADSyncArgs).Start Public Sub Start(Arguments As ADSyncArgs) Implements IJob(Of ADSyncArgs).Start
_ADSync = New ActiveDirectoryInterface(_LogConfig, _Firebird, Arguments.RootPath) Dim oSync = New ActiveDirectoryInterface(_LogConfig, _Firebird, Arguments.RootPath)
Dim oJobName As String = [GetType]().Name
'TODO: Do AD Sync! _Logger.Info("Running job {0}", oJobName)
If _ADSync.Authenticate() = False Then If oSync.Authenticate() = False Then
_Logger.Warn("Job could not be completed! Authentication failed!") _Logger.Warn("Job {0} could not be completed! Authentication failed!", oJobName)
Exit Sub Exit Sub
End If End If
Dim oGroups As List(Of ADGroup) = oSync.ListGroups()
_Logger.Debug("Found {0} Groups", oGroups.Count)
For Each oGroup In oGroups
_Logger.Debug("Syncing Group {0}", oGroup.Name)
Dim oSyncedUsers = oSync.SyncUsersForGroup(oGroup.Name)
If oSyncedUsers Is Nothing Then
_Logger.Warn("Group {0} could not be synced!", oGroup)
Else
_Logger.Debug("Group {0} synced", oGroup)
_Logger.Debug("Synced {0} users", oSyncedUsers.Count)
End If
Next
_Logger.Info("Job {0} completed!", oJobName)
End Sub End Sub
Public Function ShouldStart(Arguments As ADSyncArgs) As Boolean Implements IJob(Of ADSyncArgs).ShouldStart Public Function ShouldStart(Arguments As ADSyncArgs) As Boolean Implements IJob(Of ADSyncArgs).ShouldStart

View File

@ -56,7 +56,6 @@ Public Class ActiveDirectoryInterface
_logger.Debug("Getting group Id for group {0}", GroupName) _logger.Debug("Getting group Id for group {0}", GroupName)
oGroupId = GetGroupId(GroupName) oGroupId = GetGroupId(GroupName)
If oGroupId = 0 Then If oGroupId = 0 Then
_logger.Warn("Group {0} does not exist in database. Exiting", GroupName) _logger.Warn("Group {0} does not exist in database. Exiting", GroupName)
Return Nothing Return Nothing