Hello, I know we can set an UserGroup AccessRights with the method SetAccessRights.
But can i do the same from a Group? I noticed the method does not exist for groups.
I am trying to do a script that changes the AccessRights of a usergroup to a specific group.
The reason for this is because i am pretty much "cloning" the access rights from a Old DB to a New DB, using an excel where i only have the old GUIDs of usergroups and the new GUIDS of the new usergroups.
When I run the script I always need to choose a Main Group from a DB.
I do try to use inherit to change the access rights of the groups but in the end I am just changing the Main.
Please tell me if there an easier way to change AccessRights of Groups.
Hello Ana,
have you considered the method
inheritAccessRights ( )
of the Group object? It propagates all access rights from the group to its sub-groups. Note that this is different from what you do in the client, when you select a specific user's (or user group's) permission and inherit that to the sub-groups.
Do I understand correctly that the target DB is a copy (backup&restore) of the source DB in a different environment (with different user and user group GUIDs)? What you can be sure of in that case is, that the GUIDs of the groups in the source and target DBs are identical (including the main group). So if you have a mapping of the source and target GUIDs of the users and user groups, it should be possible to create a list of all groups and their user permissions (method AccessRights) and use that to create the same permissions in the target environment for the mapped user and user group GUIDs.
Using a permission inheritance scheme always bears the risk of overlooking/overwriting deviating permissions downwards in the group hierarchy.
Regards, M. Zschuckelt
Hey M.Zschuckelt
Thank you a lot for answering, I did try to use inheritAccessRights(), but turns out the answer was simpler then what I thought. I was somehow thinking that SetAccessRights could only be used to change the usergroup access, only a group at the time when you run it (the main group) but turns out, you can just make a loop on the groups array and like that you can change all the usergroup's access rights to the groups while also looping through the excell. I couldn't use setAccessRights properly before because of the contants value and that was the main problem. I will let that information here and how I solved it:
for(var i = 0; i < userGroupsList.length; i++){
for(var j = 0; j < foldersList.length; j++){
if(OldGuid_Excel.lastElement() == userGroupsList[i].GUID()){
var right = userGroupsList[i].AccessRights(foldersList[j]);
for(var n = 0; n < userGroupsList.length; n++){
if(NewGuid_Excel.lastElement() == userGroupsList[n].GUID()){
if(right == 0){
var resNR = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_NORIGHTS);
//Mudar direito para NO_RIGHTS
}else{
if(right == 1){
var resR = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_READ);
//Mudar direito para AR_READ
}else{
if(right == 3){
var resW = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_WRITE);
//Mudar direito para AR_WRITE
}else{
if(right == 7){
var resCH = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_CHNG);
//Mudar direito para AR_CHNG
}else{
if(right == 135){
var resCH = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_READ_SUBMIT_WRITE_DELETE);
}else{
if(right == 128){
var resCH = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_SUBMIT);
}else{
if(right == 129){
var resCH = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_READ_SUBMIT);
}else{
if(right == 131){
var resCH = userGroupsList[n].SetAccessRights( [foldersList[j]] , Constants.AR_READ_SUBMIT_WRITE);
}
}
}
}
}
}
}
}
var resFinal = userGroupsList[i].SetAccessRights( [foldersList[j]] , Constants.AR_NORIGHTS);
}
}
}
}
}
row++;
isFilledRow = dataSheet.cell(row, 0).getCellValue().trim().length()>0;
}