web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics SDK - How to change max clock skew when using late binding with an IOrganizationService

(0) ShareShare
ReportReport
Posted on by

I am attempting to connect to Dynamics using late binding and am recieving the error message

"An unsecured or incorrectly secured fault was received from the other party."

 

From what i have been able to find out the most likely cause of this is the clocks being out of sync between the machine making the request and the machine handling the request, unfortunately this is something that is out of my control. If i was using a standard WCF service i would be able to create a custom binding in the web.config, something like the following

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="customDynamicsBinding">
          <security authenticationMode="UserNameOverTransport" requireSecurityContextCancellation="true">
            <localServiceSettings maxClockSkew="Infinite"/>
            <localClientSettings maxClockSkew="Infinite"/>
            <secureConversationBootstrap />
          </security>
          <textMessageEncoding />
          <httpsTransport />
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>
 

How would i use a custom binding like this with the late bound Dynamics SDK? Alternatively is there anyway i can set the maxClockSkew for requests against the IOrganizationService without using the custom binding?

 

 

 

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    No one able to provide any feedback on this?

  • Verified answer
    Community Member Profile Picture
    on at

    Bit late response, but I stumbled upon your question, while searching for an answer.
    I ended up adapting a new custom binding to the organization service endpoint and adjust the MaxClockSkew from there.

    var serviceProxy = new OrganizationServiceProxy(organizationUri, null, credentials, null);
    serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
    
    // Find the Security binding element and set the MaxClockSkew 
    var customBinding = new CustomBinding(serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Binding);
    var security = customBinding.Elements.Find<TransportSecurityBindingElement>();
    security.LocalClientSettings.MaxClockSkew = TimeSpan.FromMinutes(60);
    security.LocalServiceSettings.MaxClockSkew = TimeSpan.FromMinutes(60);
    serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Binding = customBinding;
    
    var organizationService = (IOrganizationService)serviceProxy;

    I created a blog post for it as I haven't found any other solutions online yet. Hope it helps!

    http://vanheije.nl/blog/fixing-wcf-iorganizationservice-clienthost-maxclockskew-security-issues/

  • Community Member Profile Picture
    on at

    Wesley,

    Thanks for the reply. The Dynamics work got put on hold but should resume in the next month or so. I'll give your code a try when we start work on our Dynamics service again and let you know how i get on.

    Kev

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans