Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamics CRM - Caller not authenticated to service
    primarykey
    data
    text
    <p>I have an MVC4 Web Application on Web Server A that is consuming the Dynamics CRM Web Service using the OrganizationServiceProxy, which is on Web Server B. The MVC4 application is setup with ASP .NET Impersonation and Windows Authentication enabled. When I call the WhoAmI I get an error:</p> <p>'The caller was not authenticated by the service.'</p> <p>Now if I move the MVC4 Application to Web Server B (same as CRM) with the same Authentication as it had on Web Server A it calls WhoAmI without an exception.</p> <p>Here is the code being used to connect to the server.</p> <pre><code> string serviceURL = ConfigurationManager.AppSettings["CRMROOTURL"].ToString() + "XRMServices/2011/Organization.svc"; this.CRMService = GetCRMService(serviceURL); private OrganizationServiceProxy GetCRMService(string serviceURL) { ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; OrganizationServiceProxy client = new OrganizationServiceProxy(new Uri(serviceURL), null, credentials, null); return client; } </code></pre> <p>Here is a screenshot of the authentication on the IIS Web Site.</p> <p><img src="https://i.stack.imgur.com/RBSTN.png" alt="enter image description here"></p> <p>Per the correct answer I just wanted to provide some snippets to help anyone else. </p> <pre><code>string loggedUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name; ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = new NetworkCredential(username, password, domain); OrganizationServiceProxy client = new OrganizationServiceProxy(new Uri(serviceURL), null, credentials, null); client.ClientCredentials.Windows.ClientCredential = credentials.Windows.ClientCredential; // -- Retrieve the user. QueryExpression expression = new QueryExpression { EntityName = "systemuser", ColumnSet = new ColumnSet("systemuserid") }; expression.Criteria.AddCondition("domainname", ConditionOperator.Equal, loggedUser); EntityCollection ec = client.RetrieveMultiple(expression); if (ec.Entities.Count &gt; 0) { // -- Impersonate the logged in user. client.CallerId = ec.Entities[0].Id; } </code></pre> <p>Thanks!</p>
    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.
 

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