locked
Protect Word document with RMS (right management Services) RRS feed

  • السؤال

  • Hi all,

    I created an application (VS 2010/C#) to automate creation of word document.

    Because data is sensitive, I would like to protect this document with RMS. I know by advance what kind of template I want to use.. but don't find any clue about how I can create this via C# code.

    I also tried to record a macro, and do this manually ... and I can see that the recording process don't record anything when I set RMS configuration... so no clue.

    Any idea ?

    Thanks a lot !

    Regards.


    Frederic (MSFT)

    06/رمضان/1433 10:30 ص

جميع الردود

  • Hi Frederic,

    Thanks for posting in the MSDN forum.

    It's based on my experience that isn't a word development issue, Word doesn't provide any funtions to support your goal. If you want to protect your Word document via Word develop technic, I would recommed you use set Password of the document interface.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    08/رمضان/1433 06:12 ص
  • HI Frederic

    Which IRM options are you interested in and which version of Word is this?

    Word, as of version 2003, certainly does have some IRM support, but not all of it is available in the object model. The Word object model does support the options available in the document protection task pane.

    Then there are the more advanced IRM Permissions. These are part of the Office object model and are "inherited" into Word, which is why the only thing you can find on the Word side is Document.Permission.

    But if you look in the Office object model you'll find Permission and UserPermission objects. These provide the settings that can be found in, for example, the Word 2007 File/Prepare/Restrict Permissons dialog.

    As I don't have an IRM service available, I can't offer you any examples or sample code, but I encourage you to explore the two objects in the Office object model mentioned.


    Cindy Meister, VSTO/Word MVP

    08/رمضان/1433 08:07 ص
  • Thanks a lot,

    I am using Office 2010 and AD RMS is implemented in my company.

    If I am in word, FILE/Protect Document/Restrict permission by people...and usually select one of the templates that we have my company, for example "Full time employee/full control" which prevents people outside of the company to access this document.

    Thanks a lot !

    Regards.

    frederic


    Frederic (MSFT)

    08/رمضان/1433 09:06 ص
  • Hello Frederick,

    What process does your application (VS 2010/C#) use to automate creation of a word document? Does it generate it through use of the Word object model, automation of the Word Application, or by assembling the appropriate xml document parts? Or some other process?


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    11/رمضان/1433 09:47 م
  • Hi,

    I am still working on the scenaro unfortunatly. Password protection is not an option for me since when you know the secret, document is not protected anymore. I would rather protect it with RMS since you rely on the identity, either the user, or because the user is member of a group.

    I use the FILETOINSERT function to add the data I want in my final document.

    If you have any idea about RMS let me know.. still searching.

    regards


    Frederic (MSFT)

    12/رمضان/1433 06:38 ص
  • Hi Frederick,

    Rights Management is a Windows component, members of which are found in Windows Base.

    In your project add a reference to Windows.Base and in the ObjectBrowser search for 'System.Security.RightsManagement' Classes of interest include

    ContentRight (which has  members such as DocumentEdit, Edit, Export, Extract....Owner, Print, etc.)

    and

    ContentUser.

    Perhaps someone visiting this thread can suggest how you apply all of the requisite settings to your specific document programmatically.


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    12/رمضان/1433 06:05 م
  • Hi Frederic,

    There may be something useful to your endeavor in the following technet content:

    Plan for Information Rights Management in Office 2010
    http://technet.microsoft.com/en-us/library/cc179103.aspx

    One point of interest in the article is that your organization may have an existing template with Rights Management already configured that you could use as the template for your project. The limitation would be that the permissions in the template restrict editing or writing.


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    12/رمضان/1433 08:04 م
  • Hi,

    I will investigate asap.

    Thanks !

    Regards


    Frederic (MSFT)

    12/رمضان/1433 09:24 م
  • Hi Frederic

    Did you ever get this working?  I'm just trying to do the same thing?

    Thanks


    tony

    01/جمادى الأولى/1440 05:18 ص
  • After complete setup of IRM user below code :
    Microsoft.Office.Interop.Word.Application application = null;
    application = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application") as Microsoft.Office.Interop.Word.Application;
    Microsoft.Office.Interop.Word.Document document = application.Documents.Open(FileName: @"D:\IRM3.docx", ReadOnly: false);
    DateTime dtExpirationDate = DateTime.Today.AddMinutes(3);
    document.Permission.Enabled = true;
    document.Permission.Add(null, Microsoft.Office.Core.MsoPermission.msoPermissionFullControl, dtExpirationDate);
    document.Close(true);  
    17/ربيع الأول/1441 09:19 ص