Search code examples
dynamics-crmdynamics-crm-4

Can I use the Dynamics CRM 4.0 SDK against a hosted IFD system?


I am running this code (with names and security details obscured). When I do, I get 401 unauthorised. The credentials are that of the user on the hosted server. Is this possible against an IFD system?

var token = new CrmAuthenticationToken(); token.AuthenticationType = 0; token.OrganizationName = "myorganisation";

    CrmService service = new CrmService();
    service.Url = "https://myorganisation.dynamicsgateway.com/mscrmservices/2007/crmservice.asmx";
    service.CrmAuthenticationTokenValue = token;
    service.Credentials = new NetworkCredential("bob.smith", "Password", "HOSTEDCRM");

    var request = new RetrieveMultipleRequest();
    request.Query = new QueryExpression
    {
        ColumnSet = new ColumnSet(new string[] { "name" }),
        EntityName = "account"
    };
    var response = service.Execute(request);

Solution

  • Yes, it's possible, you are only missing a little pieces, the CrmAuthenticationToken.ExtractCrmAuthenticationToken.

    Check out this great explaination on Dynamics Forum http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/81f8ba82-981d-40dd-893d-3add67436478