Security Group Update with Business Rule

mvalerio24
New Contributor III

Is it possible to update a users security group with a business rule? If I have them in Group A but want to add them to Group B without going to the system tab and updating their security manually can I update their groupings with a Business Rule? 

1 ACCEPTED SOLUTION

hbindu
New Contributor III

The groups that are created in OS is saved to a table called "SecGroups" in the database. In your case if GroupA and GroupB exists. Get the UniqueID's of the GroupA and GroupB.

"SecGroupChild" table will have the group and child relation (this table will give you the list of GroupA - Users rows).

Read all rows that has GroupKey (GroupA), ChildKey (User).. to a dictionary, Update the GroupA key with GroupB key in the dict and then insert the rows to the SecGroupChild.

You can create a Dashboard where you can display the Groups, Users and add a button, Admin can then click the button which will then insert the rows in SecGroupChild group. If needed can add additional check, if specific users have to have access to the GroupB...

View solution in original post

3 REPLIES 3

hbindu
New Contributor III

The groups that are created in OS is saved to a table called "SecGroups" in the database. In your case if GroupA and GroupB exists. Get the UniqueID's of the GroupA and GroupB.

"SecGroupChild" table will have the group and child relation (this table will give you the list of GroupA - Users rows).

Read all rows that has GroupKey (GroupA), ChildKey (User).. to a dictionary, Update the GroupA key with GroupB key in the dict and then insert the rows to the SecGroupChild.

You can create a Dashboard where you can display the Groups, Users and add a button, Admin can then click the button which will then insert the rows in SecGroupChild group. If needed can add additional check, if specific users have to have access to the GroupB...

mvalerio24
New Contributor III

This helps, thank you!

Krishna
Valued Contributor

@mvalerio24  - Yes you can do it through BR and attached the BR. I am looping through the files from batch Harvest Folder. It is good starting point.

	
				'Bach Harvest File Path
			 Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
			 Dim folderPath As String = FileShareFolderHelper.GetBatchFolderForApp(si,True,configSettings.FileShareRootFolder,si.AppToken.AppName) & "\" & "Harvest" & "\" & "UserGroup.csv"
			 
			 'Read the File
			 
			 'If folderPath = "EntityGroup.csv" Then 
				 
			 Using parser As New TextFieldParser(folderPath)
				 	parser.TextFieldType = FieldType.Delimited
					parser.SetDelimiters(",")
					
					'Skip the Header File
					If Not parser.EndOfData Then
						parser.ReadLine()
					End If 
					
						'Loop the File and Assign the Column to Variables
							While Not parser.EndOfData
								
								Dim fields() As String = parser.ReadFields()
								Dim secGroupName As String = fields(0)
								Dim userName As String = fields(1)
								
							'Get a Group And UserInfo Object And add the Group To the user's list of parent groups.
								Dim objGroupInfo As GroupInfo = BRApi.Security.Admin.GetGroup(si, secGroupName)
									If Not objGroupInfo Is Nothing Then
									    Dim objUserInfo As UserInfo = BRApi.Security.Admin.GetUser(si, userName)
									    If Not objUserInfo Is Nothing Then

									        If (Not objUserInfo.ParentGroups.ContainsKey(objGroupInfo.Group.UniqueID)) Then
									            Dim parentGroupIDs As List(Of Guid) = objUserInfo.ParentGroups.Keys.ToList()
									            parentGroupIDs.Add(objGroupInfo.Group.UniqueID)

									            BRApi.Security.Admin.SaveUser(si, objUserInfo.User, True, parentGroupIDs, TriStateBool.Unknown)
									        End If
									    End If
									End If	
			End While
							
				End Using
				
				'Else
					Brapi.ErrorLog.LogMessage(si,"Incorrect FIleName")
				
			'End If
				
System.IO.File.Delete(folderPath)

 

Thanks
Krishna