The user authentication failed if I call offline http://localhost:2525/../organisation.svc service. RRS feed

  • Question

  • Hello Team,

    After setting CRM outlook client to offline I am trying to create an account entity using c# code. To create an entity in offline mode I am passing all values but still getting "The user authentication failed!" exception:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Client;
    using Microsoft.Xrm.Client;
    using Microsoft.Xrm.Client.Configuration;
    using Microsoft.Xrm.Client.Services;
    using System.ServiceModel.Description;
    using System.ServiceModel;
    using System.Net;
    namespace Offline
        public class CRMConnector
            #region Class Variables
            OrganizationServiceProxy service;
            OrganizationServiceContext serviceContext;
            public string sUserName = string.Empty;
            public string sDomain = string.Empty;
            public string sPassword = string.Empty;
            public Uri OrgUri;
            public CRMConnector()
                sUserName = oCryptHelper.Decrypt(Properties.Settings.Default.UserName.ToString());
                sDomain = oCryptHelper.Decrypt(Properties.Settings.Default.Domain.ToString());
                sPassword = oCryptHelper.Decrypt(Properties.Settings.Default.Password.ToString());            
                OrgUri = new Uri("http://localhost:2525/XRMServices/2011/Organization.svc");
            internal OrganizationServiceContext Connector()
                CRMConnector crmconn = new CRMConnector();
                ClientCredentials credentials = new ClientCredentials();
                credentials.Windows.ClientCredential = new System.Net.NetworkCredential(crmconn.sUserName, crmconn.sPassword, crmconn.sDomain);
                //credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;                        
                using (service = new OrganizationServiceProxy(crmconn.OrgUri, null, credentials, null))
                    service.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
                    OrganizationServiceContext orgIntitialContext = new OrganizationServiceContext(service);
                    OrganizationServiceContext orgContext = new OrganizationServiceContext(service);
                    Entity account = new Entity("account");
                    Guid accountId = service.Create(account);                
                    return orgContext;

    If I try to access the online organisation service same manner then I am not getting any issue.

    Even I can access the http://localhost:2525/XRMServices/2011/Organization.svc in browser.

    Can you please suggest me why exactly I am getting that error.

    Thanks a lot.

    Thursday, February 12, 2015 1:55 PM

All replies

  • Just for information, This is resolved now. I was getting issue because of very small mistake. I was trying to access the .DLL files from other drive where local user don't have access rights. One more info please use CRM outlook dlls else you can get "Could not load file or assembly 'Microsoft.Crm.Outlook.Sdk, Version=" error.


    Monday, February 16, 2015 3:50 PM