locked
MSCRM2015 SDK gives mismatch of the security binding between the client and the server RRS feed

  • Question

  • Hi -

      I am getting the subject error from the code below, and I have no idea how to fix it.  How do I set my binding to be https instead of http?  I am using VS2013, .Net 4.5.2 and the binaries and helpercode from mscrm2015 sdk.

    TIA.

      My connection string is like this:

    ServiceUri=https://myorg.api.crm.dynamics.com; Username=service@myorg.onmicrosoft.com; Password=itsavalidpw

      Here is the code that is failing:

                    System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
                    if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
                    {
                        connString = rootWebConfig.ConnectionStrings.ConnectionStrings["mytest_connstr"].ToString();
                        if (connString == null)
                        {
                            throw new System.Exception("No Connection String");
                        }
                    }
                    var connection1 = CrmConnection.Parse(connString);

                    using (var context = new CrmOrganizationServiceContext(connection1))
                    {
                        // Display information about the logged on user.
                        Guid userid = ((WhoAmIResponse)context.Execute(new WhoAmIRequest())).UserId;
                        SystemUser systemUser = (SystemUser)context.Retrieve("systemuser", userid,
                            new ColumnSet(new string[] { "firstname", "lastname" }));
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);
                    Console.WriteLine("Details: " + e.InnerException.Message);
                }

    Thursday, July 23, 2015 4:34 PM

All replies

  • Hello,

    Open your application config, locate connection string section, find connection with name mytest_connstr and change it.


    Dynamics CRM MVP
    My blog

    Thursday, July 23, 2015 4:49 PM
    Moderator
  • The mytest_connstr was given in the top of the post.  It is https.

    • Edited by DMDude Thursday, July 23, 2015 5:04 PM
    Thursday, July 23, 2015 5:03 PM
  • The mytest_connstr was given in the top of the post.  It is https.

    Ok. So what's wrong?

    Dynamics CRM MVP
    My blog

    Thursday, July 23, 2015 5:38 PM
    Moderator
  • I cannot connect to the CRM.  I know my connection string is correct, and I'm sure I want to be using SSL.  When I change the password in the string, it gives me a different error message about my credentials being wrong.  So it's failing somewhere after the credentials are checked.  The full error message is:

    An error occurred while making the HTTP request to https://dynamicscrmna.accesscontrol.windows.net/v2/wstrust/13/issuedtoken-asymmetric. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.

    Thursday, July 23, 2015 6:24 PM
  • Ok. Seems that you use wrong config parameters. Recheck this article - https://msdn.microsoft.com/en-us/library/gg695810.aspx?f=255&MSPPError=-2147217396

    Try to change connection string to


    connectionString="Url=https://myorg.crm.dynamics.com; Username=service@myorg.onmicrosoft.com; Password=itsavalidpw"


    Dynamics CRM MVP
    My blog

    Thursday, July 23, 2015 6:44 PM
    Moderator
  • Nope, I am getting the same error after I changed the connection string.  Am I setting up the connection wrong in my code?  I do the crmconnection.parse, and no errors are thrown then.
    Thursday, July 23, 2015 7:02 PM
  • Fairly that sounds weird for me because I use this approach on a regular basis without any issues.

    Try to rewrite your code without config-reading section like and also try not to use Early Binding like:

    var connection1 = CrmConnection.Parse("Url=https://myorg.crm.dynamics.com; Username=service@myorg.onmicrosoft.com; Password=itsavalidpw");
    service = new OrganizationService(connection1);
    Guid userid = ((WhoAmIResponse)context.Execute(new WhoAmIRequest())).UserId;
    Entity systemUser = context.Retrieve("systemuser", userid,
    		new ColumnSet(new string[] { "firstname", "lastname" }));
    
    


    Dynamics CRM MVP
    My blog


    Thursday, July 23, 2015 7:18 PM
    Moderator
  • Thanks for the ideas, but nothing is working.  I've tried what you show, I've tried the code from the help system under the topic "Sample: Authenticate users with Microsoft Dynamics CRM web services" and I still get the same error. 

    I've asked the person who set up our CRM for help.  I sent him my sample project and we'll see if he gets the same error.  Perhaps it's something with my Visual Studio setup; I'll also try it from a new virtual on azure.

    Friday, July 24, 2015 12:28 AM
  • I've asked the person who set up our CRM for help. 

    Is it CRM Online or not?

    Dynamics CRM MVP
    My blog

    Friday, July 24, 2015 4:42 AM
    Moderator
  • I don't know what CRM Online is.  The URL ends with "crm.dynamics.com" so I think it is?
    Friday, July 24, 2015 12:38 PM
  • It is CRM Online. You faced really weird issue I haven't seen before...

    My suggestion to make it work - start with simple application that uses CrmConnection class to gather information without touching your current solution. In case it would work - you can compare your current application with new and find differences that cause errors. I would suggest to download SDK and start from simple hello world app that connects to CRM and grab current user name  - https://msdn.microsoft.com/en-us/library/jj602970.aspx


    Dynamics CRM MVP
    My blog

    Friday, July 24, 2015 12:46 PM
    Moderator