Getting endpoint policy info programmatically

I wanted to share an approach you can use to find out your endpoint's capabilities and policy settings through UCMA code. To give you an example of where this can be useful, image you have an application that creates conferences or provides services to conferences, and in order to work it needs to be able to invite anonymous participants. If the endpoint has this capability turned off in meeting policy, the application will fail or exhibit strange behaviour. You might already have exception handling to deal with the situations where the application tries to do something that's prohibited by policy, but by that time your application is already running. By querying policy information, you can confirm that the necessary settings are there when your application starts and avoid unpleasant surprises later. All of this policy information is included in a single class called ProvisioningData. This class has a few different properties which expose dictionaries packed full of key/value pairs with useful details on what the endpoint can and can't do.

To get a ProvisioningData object, all you need to do is call GetProvisioningData on your endpoint, like so:

[csharp] ProvisioningData provisioningData = _endpoint.GetProvisioningData(); [/csharp]

Whether it's an application endpoint or user endpoint doesn't matter; it works the same way.

Next, you can examine the dictionaries attached to the different policy objects, such as ProvisioningData.MeetingPolicy, to get the information you''re looking for:

[csharp] bool anonymousParticipantsAllowed = (provisioningData.MeetingPolicyConfiguration.Properties ["allowanonymousparticipants"] == "true");

if (!anonymousParticipantsAllowed) { Console.WriteLine("The application cannot function if anonymous meeting " + "participants are disabled by policy. Please change the policy " + "and re-run the application."); } [/csharp]

The names of the keys in the dictionaries may not be immediately obvious, so you may find it useful to run some code like the following first to grab all the available key names:

[csharp] foreach (string key in provisioningData. MeetingPolicyConfiguration.Properties.Keys) { Console.WriteLine(key); } [/csharp]

Using these many policy settings that are included in the provisioning data, you can check that all the capabilities you need are enabled for your application, and show a meaningful error message if they aren't.