locked
Modify FetchXML in User Query entity for other users -- is this possible? RRS feed

  • Question

  • We need to modify lots of User Queries due to some changed logic, and I've been able to stage the data outside of CRM with the goal of updating CRM using the SDK via C# or CozyRoc via SSIS.  When I attempt to Update the FetchXML field in the UserQuery entity I get this error:

    [Dynamics CRM Destination [2]] Error: An error occurred with the following error message: "System.Exception: (1)  Error: SecLib::AccessCheckEx failed. AccessRights: WriteAccess 

    I can update a User Query that I created, but I can't modify anyone else's.  I understand the security disallowing one user to modify another user's User Queries, but given I'm an administrator how can I properly modify other user's User Queries?

    Thanks..

    Tuesday, April 14, 2015 2:52 PM

All replies

  • The only way to modify another users User Queries is to impersonate each user in turn. This is because it is not possible (even for the system administrator) to get rights beyond user-level for the userquery entity

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, April 14, 2015 2:57 PM
    Moderator
  • The only way to modify another users User Queries is to impersonate each user in turn. This is because it is not possible (even for the system administrator) to get rights beyond user-level for the userquery entity

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Thanks.  I understand the security behind what's happening, but is there any way to take ownership of these User Queries by updating the Entity, making the change, then giving ownership back? We have a 100 queries to update.  I was able to copy the FetchXML and UserQueryID's to a staged table, make the changes, and now I just need to push them back into the User Query entity.  I really hoped there would be some way to push these back to CRM in mass.

    Thanks again for your feedback and help.

    Tuesday, April 14, 2015 3:34 PM
  • Since you need to be the owner to exercise the update and you must have a process written to do so, how about writing a workflow activity that filters to owner == current user and instruct all the users to run the workflow.
    Tuesday, April 14, 2015 3:41 PM
  • Thanks again for the reply.  Also would it be possible using the SDK to write a command line app to impersonate each User then make the change under their context?  Per this documentation it shouldn't be too difficult to change the CallerID given it's ran by an administrator with the appropriate permissions. 

    https://msdn.microsoft.com/en-us/library/gg334744(v=crm.6).aspx

    Thanks again.

    Tuesday, April 14, 2015 4:02 PM
  • I think you're going to have to come up with everyone's passwords one way or the other.
    Wednesday, April 15, 2015 3:38 AM
  • Yes, it would be possible to write a command-line app to impersonate each user in turn and make the changes. There's no need to have any user passwords to do this. Going back a very long way (to Crm 3 days), this shows the general approach

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, April 15, 2015 2:16 PM
    Moderator