AddRole

Hi,

using 2023 R2 SDK and 2023 R3 SDK

We are getting a DB exception error when we try to add role using Servertask but getting added under roles

Role pr - > is the first available role in the management server.

ServerTask task = ManagementServer.RoleFolder.AddRole("RoleDup", pr.Description, pr.DualAuthorizationRequired, pr.MakeUsersAnonymousDuringPTZSession,

pr.AllowMobileClientLogOn, pr.AllowSmartClientLogOn, pr.AllowWebClientLogOn, pr.RoleDefaultTimeProfile, pr.RoleClientLogOnTimeProfile);

servertask.status = Error

“There has been an unexpected database error. Please contact your server administrator.”

This call was working in older SDK

Thanks,

Vikas

For me it works without the time profiles.

ServerTask task = Server.RoleFolder.AddRole("RoleDup", "My describe", false, false, true, true, true);

Do you require time profiles?

Even if I go the other way and read roles I do not get time profiles. What do you observe if you try this?

var Server = new ManagementServer(Configuration.Instance.ServerFQID);
foreach (var role in Server.RoleFolder.Roles)
{
 label1.Text += role.DisplayName + role.RoleDefaultTimeProfile + Environment.NewLine;
}

It works for me if i use the Configuration API direct, I tested this with the Config API Client sample.

By removing two arguments, we don’t see a DB exception/error.

Yes, we do require the time profiles.

I did a renewed test. It works for me.

ServerTask task = Server.RoleFolder.AddRole("RoleDup", "My describe", false, false, true, true, true, "Role[11111111-1111-1111-1111-111111111111]", "Role[11111111-1111-1111-1111-111111111111]");

I cannot see what arguments you are supplying..

When we read a role properties using SDK

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

//print

Name :Role1

Description:

DualAuthorizationRequired:False

MakeUsersAnonymousDuringPTZSession:False

AllowMobileClientLogOn:False

AllowSmartClientLogOn:True

AllowWebClientLogOn:False

RoleDefaultTimeProfile:

RoleClientLogOnTimeProfile:

We are getting empty/null strings for RoleDefaultTimeProfile and RoleClientLogOnTimeProfile.

In ConfigAPI, we can see that “Role1” has data.

When we pass the suggested values, we are able to add a role and proceed further.

Thanks,

Vega

Your observations now fits mine. I will ask Milestone Development to analyze why we cannot read those values from the VideoOS.Platform.ConfigurationItems.Role object.

The TimeProfile properties has been omitted from the all Roles result for performance reasons. If you request a specific role they will be populated, so in your code above this will include it:

Role pr2 = new Role(EnvironmentManager.Instance.MasterSite.ServerId, pr.Path);

We will make sure to update the documentation regarding this.