What is wrong with my SecurityAccess.IsMember?

I deleted my other post as I felt the direction was wrong. Instead, I want to use IsMember. However, I keep getting a null reference exception even though Visual Studio shows that all the parameters have data. I suspect one of the parameters are wrong.

Here’s my IsMember:

Dictionary<string, string> dic = QueryRoles();

if (SecurityAccess.IsMember(currentCameraItem.FQID.ServerId, loginSettings.UserIdentity, dic[“Administrators”]))

{

MessageBox.Show(“True”);

}

else

{

MessageBox.Show(“False”);

}

And here’s my QueryRoles, lifted directly from one of the plugin samples:

// The existing roles are children under of the RoleFolder

string roleFolderPath = String.Format(“/{0}”, ItemTypes.RoleFolder);

var roleConfigItems = configurationApiClient.GetChildItems(roleFolderPath);

var roles = new Dictionary<string, string>();

foreach (var role in roleConfigItems)

{

roles.Add(role.DisplayName, role.Path);

}

return roles;

Breaking at the SecurityAccess line, the currentCameraItem.FQID.ServerId has a lot of properties pointing to my server, loginSettings.UserIdentity has a string that starts with S-1-5-21 and dic[“Administrators”] returns Role[1f30d14b-ba91-4e8a-8838-eda17931f8fc].

I found two things.

The serverId should be the management server, in your implementation it will be the recording server.

The roleId should be a GUID not a Path.

I hope you can recognize what I did to you code here

private void button1_Click(object sender, EventArgs e)
{
    var li = VideoOS.Platform.Login.LoginSettingsCache.LoginSettings;
    var dic = roleController.QueryRoles();
    var role = new VideoOS.Platform.Proxy.ConfigApi.ConfigurationItemPath(dic["Administrators"]);
 
    Item camItem = Configuration.Instance.GetItem(new Guid("9085CC03-C4BE-4975-ADAB-204A87042BAA"), Kind.Camera);
    Item recItem = camItem.GetParent();
    Item msItem = recItem.GetParent();
            
    if (VideoOS.Platform.Util.SecurityAccess.IsMember(msItem.FQID.ServerId, li[0].UserIdentity, role.Id))
    {
        MessageBox.Show("True");
    }
    else
    {
        MessageBox.Show("False");
    }
}

Yes, that did work. Thanks a lot for the help!