Marco
10 months agoContributor II
how can I add a group to a user and remove it in a BR?
I would like you to help me with this question, because I want to know how I can add a security group to a person (the section that appears in the image) and how I can remove that group in a BR.
ā
JIC, here's the VB:
Dim updateParentGroupsTrue As Boolean = True Dim userInfo As UserInfo = BRApi.Security.Admin.GetUser(si, username) Dim parentGroups As List(Of Guid) = userInfo.ParentGroups.Keys.ToList() Dim user As User = userInfo.User Dim groupInfo As GroupInfo = BRApi.Security.Admin.GetGroup(si, groupName) Dim addedParentGroupGuid As Guid = groupInfo.Group.UniqueID parentGroups.Add(addedParentGroupGuid) BRApi.Security.Admin.SaveUser(si, user, updateParentGroupsTrue, parentGroups, False)
'Remove a group Dim updateParentGroupsTrue As Boolean = True Dim userInfo As UserInfo = BRApi.Security.Admin.GetUser(si, username) Dim user As User = userInfo.User Dim parentGroups As List(Of Guid) = userInfo.ParentGroups.Keys.ToList() Dim groupInfo As GroupInfo = BRApi.Security.Admin.GetGroup(si, "Development") Dim parentGroupToDeleteGuid As Guid = groupInfo.Group.UniqueID If parentGroups.Contains(parentGroupToDeleteGuid) Then parentGroups.Remove(parentGroupToDeleteGuid) BRApi.Security.Admin.SaveUser(si, user, updateParentGroupsTrue, parentGroups, False) End If