A couple of weeks earlier, I saw an interesting issue. It was a normal day as far as days go in support and in comes this issue, where the person in question wants to investigate or rather should I say automate the process of creating IRM settings on document libraries. I wasn't working on this issue and a colleague took this over. But then somewhere it was lurking, how the hell do you do that? The natural starting point is getting a site/web context and going down to the list and then getting dirty with the properties exposed by the particular SPList object. So after finishing what I had on my plate, I dug into figuring out how exactly to set the IRM settings for a list using the object model. So here goes:
Step 1 Enable IRM on the farm SPWebService svc = SPFarm.Local.Services.GetValue<SPWebService>();SPIrmSettings irmSettings = svc.IrmSettings;irmSettings.IrmRMSEnabled = true;//set true or false based on the situationirmSettings.IrmRMSUseAD = true;irmSettings.IrmRMSCertServer = "certificate server here";irmSettings.IrmChanges = irmSettings.IrmChanges + 1;svc.Update();
Step2 Set the IRM properties for a document library
Phew!
~harsh