03-14-2024 01:10 PM
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.
Solved! Go to Solution.
03-14-2024 01:56 PM - edited 03-14-2024 02:16 PM
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
03-14-2024 01:35 PM
You will want to look at BRApi.Security.Admin. This post might help:
And the MarketPlace solution Process Control Manager has some code which saves security groups in the Dashboard Extender PCM_SolutionHelper
03-14-2024 01:44 PM
I checked the post but I do not see exactly how to add, and even more how to delete, I have not found something like that in the forum.
03-14-2024 01:47 PM - edited 03-14-2024 02:14 PM
Add a user to a group:
bool updateParentGroupsTrue = true;
UserInfo userInfo = BRApi.Security.Admin.GetUser(si, username);
User user = userInfo.User;
List<Guid> parentGroups = userInfo.ParentGroups.Keys.ToList();
GroupInfo groupInfo = BRApi.Security.Admin.GetGroup(si, groupName);
Guid addedParentGroupGuid = groupInfo.Group.UniqueID;
parentGroups.Add(addedParentGroupGuid);
BRApi.Security.Admin.SaveUser(si, user, updateParentGroupsTrue, parentGroups, false);
Remove the person from the group is similar
//remove a group
bool updateParentGroupsTrue = true;
UserInfo userInfo = BRApi.Security.Admin.GetUser(si, username);
User user = userInfo.User;
List<Guid> parentGroups = userInfo.ParentGroups.Keys.ToList();
GroupInfo groupInfo = BRApi.Security.Admin.GetGroup(si, "Development");
Guid parentGroupToDeleteGuid = groupInfo.Group.UniqueID;
if(parentGroups.Contains(parentGroups)
{
parentGroups.Remove(parentGroupToDeleteGuid);
BRApi.Security.Admin.SaveUser(si, user, updateParentGroupsTrue, parentGroups, false);
}
03-14-2024 01:56 PM - edited 03-14-2024 02:16 PM
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
03-14-2024 02:43 PM
Thank you very much Robb.