AD RMS SDK 2.1 C# managed API File is not being IRM Enable Using Method SafeFileApiNativeMethods.IpcfEncryptFileStream RRS feed

  • Question

  • Hi Team,

    I am trying to do IRM Enabled on file which is located in physical location in c drive and it is simply .docx document.

    I want to achieve the goal using the method  "IpcfEncryptFileStream()".

    Problem Statement:

    I am passing the Input stream and out put stream as expected and function gives me the output stream returned which is IRM protected. When i open the file in Word 2013 it is not asking me the username and credentials. It means that file is not IRM enabled. 

    Should i do override the returned stream to the existing file?I have tried this and i found that some junk characters and XML strings added in to the file.

    How can i save IRM Protected Memory Stream in to file?

    Code is as below.

    filePath = @"C:\Users\svc_devdb\Desktop\teststream.docx";
    Stream connStream = File.OpenRead(filepath);
    Stream connOutputStream = new MemoryStream();
     inputStream: connStream,
     inputFilePath: filepath,
     templateId: template.TemplateId,
     outputStream: ref connOutputStream,
     ipcContext: null);
    // Once function is called successfully i am trying to write the stream using below code.
    var f = new FileStream(filepath, FileMode.Create, FileAccess.Write);

    Team, Can you help me out how can i achieve this goal  ?


    Dipen Shah

    Wednesday, June 20, 2018 5:42 AM