Getting an unexpected error when trying to connect to CRM 2011 web service. Here's the background:
Connection String (with sensitive info removed): "ServiceUri=https://crmdomain.com/OrgName/XRMServices/2011/Organization.svc; Url=https://crmdomain.com/OrgName; Username=appusername; Password=hidden"/>
Creating the connection as follows:
- Parse conn string into CRMConnection:
var conn = Microsoft.Xrm.Client.CrmConnection.Parse(connString);
(at this point, the properties in theCrmConnection
object look correct, including ClientCredentials) - Create org proxy:
var orgProxy = new OrganizationServiceProxy(conn.ServiceUri, conn.HomeRealmUri, conn.ClientCredentials, conn.DeviceCredentials);
- Create data context:
var context = new MyContext(orgProxy);
At this point, when retrieving any data from context
, the following WCF exception occurs:
System.ServiceModel.Security.SecurityNegotiationException occurred Message=The caller was not authenticated by the service. Source=mscorlib StackTrace: Server stack trace: at System.ServiceModel.Security.IssuanceTokenProviderBase'1.DoNegotiation(TimeSpan timeout) at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout) at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
... and so on.
The InnerException shows IsSenderFault=True
and IsPredefinedFault=True
.
What's going on here?