Resources for IT Professionals > Dynamics Forums > CRM Development > Cannot Automatically Download File Attachment After Update Rollup 7
Ask a questionAsk a question
 

AnswerCannot Automatically Download File Attachment After Update Rollup 7

  • Thursday, October 29, 2009 6:09 PMJBeaulac Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Update Rollup 7 appears to have introduced a new RPC Security Token that is sends when requesting attachment downloads.  There is example code in the CRM SDK that shows how to automatically download a specific CRM attachment, but no longer works now because of the new token.

    Naturally, we have implemented this SDK code in a number of customizations and need to know how to make it compatible with Update Rollup 7.  How can request an RPC Token to include in the download attachment function?

Answers

All Replies

  • Wednesday, November 04, 2009 2:20 PMDon ChangMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer

    Hello Developers,

    We are aware of this issue.   The security fix was introduced on in UR7 to prevent Cross-Site request forgery attacks on the CRM servers.   Unfortunately, what it does is break every ISV and partner that needs to download attachments because there is no programmatic way to create WRPC tokens in a supported manner.  We are working in a fix to resolve this issue.

    Thank you,


    Best regards,

    Don Chang
    Partner Online Technical Community
    -----------------------------------------------------------------------------------------
    We hope you get value from our new forums platform! Tell us what you think:
    http://social.microsoft.com/Forums/en-US/partnerfdbk/threads
    ------------------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed As Answer byDavidBerry Wednesday, November 04, 2009 5:30 PM
    •  
  • Thursday, November 05, 2009 5:10 PMAFCC Inc - Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I also did a update rollup 7 and now i cannot access my uploaded attachments.



    http://afccinc.com?siteref=msdn
  • Thursday, November 05, 2009 6:16 PMAFCC Inc - Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hey,

    For no reason at all it is working now.

    http://afccinc.com?siteref=msdn
  • Friday, November 06, 2009 3:03 AMmaxcelcat Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    G'day All,

    We've just upgraded to Rollup 7 (on advice from Microsoft!) and encountered this same issue.

    It seems to work fine from the server itself if one uses the localhost address...

    Any timeframe on getting a fix for this?

    Paul J.
  • Friday, November 06, 2009 11:21 AMDavidJennawayMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I reckon that any occasional cases of this working on UR7 are due to caching, as it looks to me like UR 7 properly breaks this functionality.

    However, there is a registry value that can turn off token checking, and hence fixes it. See http://mscrmuk.blogspot.com/2009/11/ur-7-breaks-attachment-download-code.html for details.

    As to a proper code fix, the CRM product team, and the SDK team are aware of the problem, and I'd hope they undo this change (my view is it makes CRM implementations less secure, as people apply the registry change), though the earliest that I'd envision something happen would be UR8
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
  • Monday, November 09, 2009 8:19 PMbsykes Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This problem seemed to go away for me if I used the FQDN of my CRM server
    i.e.

    not http://crmserver:5555
    but rather http://crmserver.mydomain.com:5555

    quick change to user's homepage.

    sorted.
  • Wednesday, November 11, 2009 1:35 PMJBeaulac Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Unfortunately, work-arounds or unsupported fixes won't work.  We've got 100's of customers being affected by this change right now and these "solutions" won't work for many of them.  I've been working with MS Support directly for almost 2 weeks now, but so far they seem clueless about how to handle it. 

  • Friday, November 13, 2009 3:36 PMDon ChangMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Update to this issue.   If you have questions, please contact CRM Support.

    We recommend the following new code to address the issue you are experiencing.

    For example, for Notes, the code will look like

     

                CrmAuthenticationToken token = new CrmAuthenticationToken();

                token.AuthenticationType = 0;

                token.OrganizationName = "<<MyOrgName>>";

     

                CrmService service = new CrmService();

                service.Url = "http://<<MyServerName>>/mscrmservices/2007/crmservice.asmx";

                service.CrmAuthenticationTokenValue = token;

                service.Credentials = System.Net.CredentialCache.DefaultCredentials;

     

                annotation attachment = (annotation)service.Retrieve(EntityName.annotation.ToString(), new Guid("<<AttachmentGuid>>"), new ColumnSet(new string[] { "filename", "documentbody", "mimetype" }));

     

                using (FileStream fileStream = new FileStream(attachment.filename, FileMode.OpenOrCreate))

                {

                    byte[] fileContent = Convert.FromBase64String(attachment.documentbody);

                    fileStream.Write(fileContent, 0, fileContent.Length);

                }

     

    For salesliterature, “annotation” should be changed to “salesliterature” and “EntityName.annotation” to “EntityName.salesliterature”, everything else stays the same.

    For Mail Merge Templates and Activity Mime Attachments (email attachments), “documentbody” will change to “body” and object names should change correspondingly.

    SDK documentation will be updated to reflect the new code snippet.


    Best regards,

    Don Chang
    Partner Online Technical Community
    -----------------------------------------------------------------------------------------
    We hope you get value from our new forums platform! Tell us what you think:
    http://social.microsoft.com/Forums/en-US/partnerfdbk/threads
    ------------------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.