none
Opening file from SharePoint with claims autetication RRS feed

  • Question

  • It's pretty straitforward to open a file (pptx in this case) from a local drive:

     

    using PPDoc = Microsoft.Office.Interop.PowerPoint; 
    
    PPDoc.Application app = new PPDoc.Application();
    
    app.Visible - MsoTriState.msoCTrue;
    PPDoc.Presentation p = app.Presentations.Open(myFilePath, MsoTriState.msFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
    

    but if this code try to open a file in SharePoint folder with claims autentication you'll get "Access denied" wich is expected because you have to provide auth cookie like in this example:

     

    request = (HttpWebRequest)WebRequest.Create(mySharepointFolderURL);
    
    request.CookieContainer = new CookieContainer();
    
    request.CookieContainer = _myCookieContainerWithAuthCookie;
    

     

    The Question is where in Office object model I can find property/object to supply security token?


    Wednesday, June 1, 2011 1:53 PM

All replies

  • Hi Alec,

    As far as I know, Office Object model does not provide property/object to supply security token.

    Here is a article on MSDN about security considerations for Office solutions: http://msdn.microsoft.com/en-us/library/1thd35d7.aspx , I am not sure whether this can give you the hint.

    Besides, Office automation is not good for server-side automation:

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment. 

    For more details, please take a look at this KB article:

    http://support.microsoft.com/kb/257757 

    Hope this can help you.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 7, 2011 2:23 AM
  • This is not server side automation. It's client application which tries to open a file on SharePoint server. The default office behaivior without automation and security based on session cookies is popping up a window where user can supply his credentials. This window is not popping up with code above. So to solve the problem I need either find a way how to open this window for a user or directly assign cookie with a SAML token.
    http://alecpojidaev.wordpress.com
    Tuesday, June 7, 2011 1:27 PM
  • Hi Alec,

    Please take a look at this blog article:

    http://msdn.microsoft.com/en-us/magazine/cc507632.aspx

    I think you may need to add the location of the sharepoint document to the Trust Center. After trying to add the location, you can open it via powerpoint object model.

    Hope the suggestion can help you.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 8, 2011 5:49 AM
  • Thanks for your suggestion. This problem caused by not enough trust at SharePoint side not at Office (client) side. Althoug I have tried to specify file location in Trust center just for the sake to see if it will be any difference in PowerPoint error. The error is the same: "PowerPoint could not open the file". Which is again expected because the request for the file was without autentication information.

    What could help is the alternative ways to open files (maybe using open file dilog). May be in this case PowerPoint will show up window for entering user credentials.


    http://alecpojidaev.wordpress.com
    Wednesday, June 8, 2011 1:51 PM