Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you need to use separate user account to log into the <code>OrganizationServiceProxy</code>. You wont be able retrieve the windows credentials to pass to the proxy for authentication.</p> <p>The user that you do use needs <code>prvActOnBehalfOfAnotherUser</code> privilege associated with it.</p> <p>Once this is done and you can successfullly login and retrieve a valid OrganizationServiceProxy, what you need to do as a consumer of the service is specify the CallerId whenever you are calling operations on it. This token you should retrieve from the xrm model using <code>Xrm.Page.context.getUserId</code>. See. <a href="http://msdn.microsoft.com/en-us/library/gg334511.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/gg334511.aspx</a>.</p> <p>Then from silverlight you would use the <code>System.Windows.Browser.ScriptObject</code> bridge to execute client side javascript to retrieve the userid of current user logged into crm. Preferably do this at application bootstrap time and save the value into an applicationdata variable so so can access it globally from within your silverlight app.</p> <p>Eg. of client side script.</p> <pre><code>function CrmContext() { } var context = null; with (window.parent) { context = Xrm.Page.context;} CrmContext.prototype.ReadUserId = function () { var userId = context.getUserId(); return userId; } </code></pre> <p>Once you have the user token set the Proxy CallerId with this value</p> <p>Eg.</p> <pre><code>private OrganizationServiceProxy Proxy { get; set; } public Guid Create(CreateEntity request) { if (request == null || request.UserId == Guid.Empty || request.Entity == null) { throw new InvalidMessageException("Invalid reqest message. Please provide compulsory criteria"); } var result = Guid.Empty; try { if (Proxy != null) { Proxy.CallerId = request.UserId; using (Proxy) { result = Proxy.Create(request.Entity); } } } catch (FaultException&lt;OrganizationServiceFault&gt; e) { Log.Error(e.Message); throw new IntegrationException(e.Message); } return result; } </code></pre> <p>The approach ive taken to solve this was to create a crm adapter encapsulating the crm proxy and sending request object to service interface that includes the user token.</p> <pre><code>public OrganizationServiceAdapter(ICrmConfigurationContext crmConfigurationConext) { try { Proxy = new OrganizationServiceProxy( crmConfigurationConext.OrganizationServiceConfiguration, crmConfigurationConext.Credentials); } catch (Exception e) { //// TODO: Add local proxy pattern implementation for failover Proxy = null; Log.Error(e.Message); throw new IntegrationException(ExceptionMessages.CouldNotLoginToOrganizationService()); } } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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