Discussing the nuts and bolts of software development

Wednesday, July 09, 2008

 

Trouble Getting Your Custom Protector Called?

You might be getting a lot of grey hair by developing your own custom protector for SharePoint. Until recently, I was right there with you. Having troubles getting your custom protector to be called by SharePoint? I'm here to help. I'm happy to tell you that it could be a simple fix. A simple flag as a matter of fact. If you haven't heard of the IrmAddInsEnabled flag, then this is what you must do.

You need to set the IrmAddInsEnabled flag to true in the Central Admin page to get SharePoint to call any of the protector function calls (HrIsProtected, HrProtect, HrUnprotect). This sets a Boolean value that specifies whether to enable Information Rights Management (IRM) addins.

You can do this directly on the MOSS server from the 12 Hive (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN) by calling the following:

On the MOSS server:

'stsadm -o setproperty -propertyname irmaddinsenabled -propertyvalue "yes"'

Alternatively, you can do this programmatically by using SharePoint via the IRM Settings by using SPIrmSettings.IrmAddins. This can be done at the farm level or as granular as a per-list basis.

IRM Settings for the FARM:

SPWebService svc = SPFarm.Local.Services.GetValue();
SPIrmSettings irmSettings = svc.IrmSettings;

//Specifies whether to enable Information Rights Management (IRM)
//locally for sites
irmSettings.IrmRMSEnabled = true;

//Specifies whether to enable Information Rights Management (IRM)
//addins
irmSettings.IrmAddinsEnabled = true;

//Sets the number of times the Information Rights Management (IRM)
//settings have been changed
irmSettings.IrmChanges += 2;

svc.Update();

IRM Settings for the Individual Lists on FeatureActivated:

SPWeb web = (SPWeb)properties.Feature.Parent;
foreach (SPList list in web.Lists)
{
// Specifies whether to enable Information Rights Management (IRM)
// for the list
list.IrmEnabled = true;

// Specifies whether to allow users to upload documents that do
// not support IRM
list.IrmReject = true;

list.Update();
}

After you have done this, your custom protector should be called when the documents are checked in and out of your SharePoint system via the HrIsProtected, HrProtect, HrUnprotect methods.

Goodluck!

Labels: , ,


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?