I got an error when connecting the CRM 2013 from CRM SDK code. The error message is
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
And here is the inner exception message:
An error occurred when verifying security for the message.
The CRM is installed on Virtual Box that consist of:
I have test the CRM connection with below scenario
Here is my source code:
var uri = new Uri(@"http://XXXX/MRC/XRMServices/2011/Organization.svc");
var username = @"XX\Administrator";
var password = "password";
_credential.UserName.UserName = username;
_credential.UserName.Password = password;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(uri, null, _credential, null))
{
serviceProxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)serviceProxy;
MRServiceContext context = new MRServiceContext(service);
var query = context.ContactSet.ToList();
foreach (var item in query)
{
Console.WriteLine(item.FirstName);
}
}
Thanks in advance.
Oppss this is a stupid mistake that I have ever made. This issue is caused by the guest machine date is in the past compare with the host machine. I only checked the time on guest and host machine that already the same. But, I forgot to check the date.
Here is the clue:
System.ServiceModel.Security.MessageSecurityException, System.ServiceModel,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The security timestamp is stale because its expiration time
('2014-04-03T06:49:23.526Z') is in the past. Current time is '2014-04-04T06:44:14.447Z'
and allowed clock skew is '00:05:00'.</Message><StackTrace> at
System.ServiceModel.Security.SecurityTimestamp.ValidateFreshness(TimeSpan timeToLive,
TimeSpan allowedClockSkew)
Here is the best way to check some error that occurred on CRM (doesn't appear on client side):
Hope this steps is useful for the others.