Role ChangeOverallSecurityPermissions Exception

Hi,

using SDK 2023 R2 with XProtect Corporate 2023 R2.

Getting "Bad request: parameters missing " error.

Code snippet:

//update ChangeOverallSecurityPermissions from parent role to child role

Role cr = ChildManagementServer.RoleFolder.Roles.FirsOrDefault();

Role pr = ParentManagementServer.RoleFolder.Roles.FirsOrDefault();

ChangeOverallSecurityPermissionsServerTask task = cr.ChangeOverallSecurityPermissions();

while (task.State != StateEnum.Error && task.State != StateEnum.Success)

{

System.Threading.Thread.Sleep(10);

task.UpdateState();

}

if (task.State == StateEnum.Error)

{

pushLogs("Error - " + task.ErrorText + " PR: " + pr.Name + " CR: " + cr.Name, true);

}

else if(task.State == StateEnum.Success)

{

Dictionary<string, string> dc1 = task.SecurityNamespaceValues;

foreach (string s in dc1.Values)

{

ServerTask cosp = pr.ChangeOverallSecurityPermissions(s);

while (cosp.State != StateEnum.Error && cosp.State != StateEnum.Success)

{

  System.Threading.Thread.Sleep(10);

  cosp.UpdateState();

}    

if (cosp.State == StateEnum.Error)

{

  pushLogs("Error - " + task.ErrorText + " PR: " + [pr.Name](http://pr.Name "http://pr.Name") + " CR: " + [cr.Name](http://cr.Name "http://cr.Name") + " Property - " + s, true);

}

else if (cosp.State == StateEnum.Success)

{

    // Proceed with data

}

}

cr.Save();

}

Was working in older releases.

Thanks,

Vega

I notice the ChildX and ParentX.

I might guess you are doing Milestone Federated Architecture. Please tell me if that is so and explain the setup. If multiple servers are involved I would like to hear if it works in the regular one site scenario.

Using Nuget milestoneSDK version 23.3.1 and 23.2.1 on XProtect Corporate 2023 R2

We have both federation and non-federation(single) sites and on both, we are facing the same issue.

Below is the code snippet for better understand

SelectedSiteItem - current site(object of type VideoOS.Platform.Item)

try

{

ManagementServer ParentManagementServer = null;

ParentManagementServer = new ManagementServer(SelectedSiteItem.FQID);

Role pr = ParentManagementServer.RoleFolder.Roles.SingleOrDefault(x => x.Name == “Role1”);

ChangeOverallSecurityPermissionsServerTask task = pr.ChangeOverallSecurityPermissions();

while (task.State != StateEnum.Error && task.State != StateEnum.Success)

{

System.Threading.Thread.Sleep(10);

task.UpdateState();

}

if (task.State == StateEnum.Error)

{

pushLogs("Error - " + task.ErrorText + " PR: " + pr.Name, true);

}

if (task.State == StateEnum.Success)

{

//do work

}

}

catch(Exception exp)

{

pushLogs("Exp - " + ex.Message.ToString(), true);

}

Thanks,

Vega

Tried SDK 2023 R3 on XProtect Corporate 2023 R3.

when calling ChangeOverallSecurityPermissions(), getting the “Bad request: parameters missing” error.

Hey Code Vega

This is because of a bug in how we handle the initial communication. This should have been a warning that addiotional parameter should be added (in this case it would be the secrutiynamespace). I’ve created a bug and we will look into fixing it.

As a workaround I suggest that the following options:

1.Set the following property in the start of your code: Configuration.Instance.ConfigurationApiManager.UseRestApiWhenAvailable = false;

This will change the functionality of the SDK to use the configAPI for communication which doesn’t have this issue. We have no plans of deprecatomg the configAPI, but some new features may only work in through the REST API. So once the bug has been fixed, I suggeste that you remove this line.

2.When receiving the first error, check if SecurityNamespaceValues on the task is empty. If they are not emtpy, ignorer the error. This is not the pretty solution, but it will work. The bug is only seen with the initial call, with the following calls, you will receive task with state success.

I hope the workarounds make sense and can work for you. If you have further questions, please let me now.

@Henrik Hein​ Thanks that helped