JobRunner, ADInterface
This commit is contained in:
@@ -13,33 +13,39 @@ Public Class ADSyncJob
|
||||
End Sub
|
||||
|
||||
Public Sub Start(Arguments As ADSyncArgs) Implements IJob(Of ADSyncArgs).Start
|
||||
Dim oSync = New ActiveDirectoryInterface(_LogConfig, _Firebird, _MSSQL, Arguments.RootPath)
|
||||
Dim oJobName As String = [GetType]().Name
|
||||
|
||||
_Logger.Info("Running job {0}", oJobName)
|
||||
Try
|
||||
Dim oSync = New ActiveDirectoryInterface(_LogConfig, _Firebird, _MSSQL, Arguments.RootPath)
|
||||
|
||||
If oSync.Authenticate() = False Then
|
||||
_Logger.Warn("Job {0} could not be completed! Authentication failed!", oJobName)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oGroups As List(Of ADGroup) = oSync.ListGroups()
|
||||
_Logger.Info("Running job {0}", oJobName)
|
||||
|
||||
_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)
|
||||
If oSync.Authenticate() = False Then
|
||||
_Logger.Warn("Job {0} could not be completed! Authentication failed!", oJobName)
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
|
||||
_Logger.Info("Job {0} completed!", oJobName)
|
||||
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("Synced {0} users for group {1}", oSyncedUsers.Count, oGroup)
|
||||
End If
|
||||
Next
|
||||
|
||||
_Logger.Info("Job {0} completed!", oJobName)
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Job {0} failed!", oJobName)
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Function ShouldStart(Arguments As ADSyncArgs) As Boolean Implements IJob(Of ADSyncArgs).ShouldStart
|
||||
|
||||
Reference in New Issue
Block a user