protected string GetTemplateID(string templateName)
{
// Get the template settings
SettingsResponse settingsResponse = this.ASRMAdapter.Settings();
// Choose the all rights policy template and get template ID.
this.Site.Assert.IsNotNull(settingsResponse.ResponseData.RightsManagementInformation, "The RightsManagementInformation element should not be null in Settings response.");
this.Site.Assert.IsNotNull(settingsResponse.ResponseData.RightsManagementInformation.Get, "The Get element should not be null in Settings response.");
this.Site.Assert.IsNotNull(settingsResponse.ResponseData.RightsManagementInformation.Get.RightsManagementTemplates, "The RightsManagementTemplates element should not be null in Settings response.");
string templateID = null;
foreach (Response.RightsManagementTemplatesRightsManagementTemplate template in settingsResponse.ResponseData.RightsManagementInformation.Get.RightsManagementTemplates)
{
if (template.TemplateName == templateName)
{
templateID = template.TemplateID;
break;
}
}
this.Site.Assert.IsNotNull(templateID, "Template {0} is not found on the server. This may happen if MS-ASRM configuration is not performed properly.", templateName);
return templateID;
}