added active directory support to security groups

This commit is contained in:
Infineon\StieberD
2024-11-01 17:59:22 -07:00
parent 2fa803e3a1
commit 2ad0386055
25 changed files with 7835 additions and 6559 deletions

View File

@ -26,6 +26,7 @@ $insert SERVICE_SETUP
$Insert LSL_USERS_EQU
$Insert RLIST_EQUATES
$Insert NOTIFICATION_EQUATES
$Insert SEC_GROUPS_EQUATES
equ crlf$ to \0D0A\
equ tab$ to char(09)
@ -45,12 +46,17 @@ Declare Function Get.RecCount, SRP_Datetime, Datetime, SRP_MATH, Lsl_Users_Ser
Declare Function DCount, Database_Services, Environment_Services, SRP_Array, Logging_Services
Declare subroutine Btree.Extract, Logging_Services
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\LSLUsers'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Notification Groups Update Log.csv'
Headers = 'Logging DTM' : @FM : 'Notification ID' : @FM : 'Notes'
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\LSLUsers'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Notification Groups Update Log.csv'
Headers = 'Logging DTM' : @FM : 'Notification ID' : @FM : 'Notes'
objNotificationLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$)
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Security Groups Update Log.csv'
Headers = 'Logging DTM' : @FM : 'Notification ID' : @FM : 'Notes'
objSecGroupsLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, Comma$, Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
GoToService else
@ -414,14 +420,14 @@ Service UpdateNotificationGroups()
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'No LSL_USERS record found for active directory member "':ADUserName:'".'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
Logging_Services('AppendLog', objNotficationLog, LogData, @RM, @FM)
end
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Btree.Extract call failed for DOMAIN_USERNAME "':ADUserName:'".'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
Logging_Services('AppendLog', objNotficationLog, LogData, @RM, @FM)
end
Next ADUserName
end
@ -434,7 +440,7 @@ Service UpdateNotificationGroups()
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to write record during update.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
Logging_Services('AppendLog', objNotficationLog, LogData, @RM, @FM)
end
end
end else
@ -442,14 +448,14 @@ Service UpdateNotificationGroups()
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to read record during update.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
Logging_Services('AppendLog', objNotficationLog, LogData, @RM, @FM)
end
Unlock hTable, KeyId else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to unlock record during update.'
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
Logging_Services('AppendLog', objNotficationLog, LogData, @RM, @FM)
end
end
Repeat
@ -460,3 +466,85 @@ Service UpdateNotificationGroups()
end service
Service UpdateSecurityGroups()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
Open 'SEC_GROUPS' to hTable then
EOF = False$
Select hTable
Loop
ReadNext KeyId else EOF = True$
Until EOF
Lock hTable, KeyId then
Read Rec from hTable, KeyId then
UseAD = Rec<SEC_GROUPS_USE_ACTIVE_DIRECTORY$>
If UseAD then
LSLUserList = ''
// Update LSL_User list based on current members in Active Directory groups
ADGroups = Rec<SEC_GROUPS_ACTIVE_DIRECTORY_GROUPS$>
For each GroupName in ADGroups using @VM
MemberList = Active_Directory_Services('GetADGroupMembersByGroupName', GroupName, 'INFINEON')
MemberList = SRP_Array('Rotate', MemberList, @FM, @VM)
ADUserNames = MemberList<1>
LSLUserNames = ''
LSLNames = ''
Open 'DICT.LSL_USERS' to hDict then
For each ADUserName in ADUserNames using @VM setting vPos
Query = 'DOMAIN_USERNAME':@VM:ADUserName:@FM:'ACTIVE':@VM:True$:@FM
Flag = ''
LSLUsername = ''
Btree.Extract(Query, 'LSL_USERS', hDict, LSLUsername, '', Flag)
If Flag EQ 0 then
If LSLUsername NE '' then
LSLUserList<0, -1> = LSLUsername
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'No LSL_USERS record found for active directory member "':ADUserName:'".'
Logging_Services('AppendLog', objSecGroupsLog, LogData, @RM, @FM)
end
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Btree.Extract call failed for DOMAIN_USERNAME "':ADUserName:'".'
Logging_Services('AppendLog', objSecGroupsLog, LogData, @RM, @FM)
end
Next ADUserName
end
Next GroupName
LSLUserList = SRP_Array('Clean', LSLUserList, 'TrimAndMakeUnique', @VM)
LSLUserList = SRP_Array('SortSimpleList', LSLUserList, 'AscendingText', @VM)
Rec<SEC_GROUPS_USER$> = LSLUserList
Write Rec on hTable, KeyId else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to write record during update.'
Logging_Services('AppendLog', objSecGroupsLog, LogData, @RM, @FM)
end
end
end else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to read record during update.'
Logging_Services('AppendLog', objSecGroupsLog, LogData, @RM, @FM)
end
Unlock hTable, KeyId else
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = KeyId
LogData<3> = 'Failed to unlock record during update.'
Logging_Services('AppendLog', objSecGroupsLog, LogData, @RM, @FM)
end
end
Repeat
end
Unlock hSysLists, ServiceKeyID else Null
end
end service