Note that there are some explanatory texts on larger screens.

plurals
  1. POGet OrganizationServiceProxy from CrmOrganizationServiceContext in external MVC app
    primarykey
    data
    text
    <p>I'm want to be able to set the caller ID on my</p> <pre><code>XrmServiceContext : Microsoft.Xrm.Client.CrmOrganizationServiceContext </code></pre> <p>Context that has been generated for crm using svcutil.exe.</p> <p>As far as I can tell I cant do this on an existing connection and I need to first create an instance of <code>OrganizationServiceProxy</code> set the CallerID and then pass it as a paramater to a new <code>XrmServiceContext</code> which I can then use instead.</p> <p>However I'm kind of stuck on how I go from a <code>CrmOrganizationServiceContext</code> to having a <code>OrganizationServiceProxy</code></p> <p>The program is a separate .Net4.5 application</p> <p>Any helpful tips or links?</p> <hr> <p><strong>Edit</strong>: Found this page just after posting this: <a href="http://msdn.microsoft.com/en-us/library/gg695810.aspx">http://msdn.microsoft.com/en-us/library/gg695810.aspx</a></p> <p>So it may be as simple as:</p> <pre><code> var connection = new CrmConnection("Xrm"); connection.CallerId = uide; _serviceContext = new XrmServiceContext(connection); </code></pre> <p><strong>Edit 2</strong>: It was not as simple as that. Doing this resulted in no change of what data I received.</p> <pre><code> CrmConnection connection = new CrmConnection("Xrm"); connection.CallerId = Guid.NewGuid();//u.Id; _serviceContext = new XrmServiceContext(connection); </code></pre> <p>It compiles and dosen't crash but I was suspicious when I used the id of a user with very low privledges but still got all data back, I then tried generating a new Guid for every instance of the XrmServiceContext but I am still getting everything back. So I am guessing it is not being used.. or I am missing something else.</p> <p><strong>Edit 3</strong> Doing a <code>WhoAmIRequest</code> after the <code>CallerID</code> has been set still returns the same user that is set in the connection string.</p> <p><strong>Edit 4</strong> Seems my problems are Cache related. In my implementation I need to first make a call to the service context to figure out the Guid of the user I want to impersonate. This call is made without <code>CallerID</code> set. If I skip this initial query and just set a specific Guid from the beginning the CallerID works. I'm guessing this is because the service context has cached my original CallerId or something similar.</p> <p>Now I just have to figure out how to clear the cache in CRM 2013 SDK.</p> <p><strong>Edit 5</strong> By turning of the cache completly using this guide: <a href="http://msdn.microsoft.com/en-us/library/gg695805.aspx">http://msdn.microsoft.com/en-us/library/gg695805.aspx</a> I have gotten it to work. I would however prefer if I could just clear it out at the one point I need to instead of disabling it completly.</p> <p>If someone can show me how to empty the service context cache using code I will mark that as the correct solution</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload