Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Unable to connect CRM 365 On-Premise

Posted on by Microsoft Employee

Hi, i am tryng  to connect CRM 365 On-Premise in my console application. I used this code below:

 IOrganizationService _service;
            ClientCredentials _credit = new ClientCredentials();
            _credit.UserName.UserName = "myoffice\fikri.hailal";
            _credit.UserName.Password = "password";
            _service = new OrganizationServiceProxy(new Uri
                ("myoffice/.../Organization.svc"), null, _credit, null);

But when i debug the console application. It says, "the caller was not authenticated by the service". 

Strangely when i used this code for CRM Online and other CRM On-premise, it connect successfully. What did i miss ?

Or did i need a user with specific criteria ?

*This post is locked for comments

  • Verified answer
    Nadeeja Bomiriya Profile Picture
    Nadeeja Bomiriya 6,804 on at
    RE: Unable to connect CRM 365 On-Premise

    Hi Fikri,

    Try the simplified connection.

    https://msdn.microsoft.com/en-us/library/jj602970.aspx

    ConnectionString:

        <!-- On-premises with provided user credentials -->
        <!-- <add name="Server=myserver, organization=AdventureWorksCycle, user=administrator"
             connectionString="Url=myserver/AdventureWorksCycle; Domain=mydomain; Username=administrator; Password=password; authtype=AD"/> -->
    
        <!-- On-premises using Windows integrated security -->
        <!-- <add name="Server=myserver, organization=AdventureWorksCycle"
             connectionString="Url=myserver/AdventureWorksCycle; authtype=AD"/> -->

    Creating Connection:

    // Connect to the CRM web service using a connection string.
    CrmServiceClient conn = new Xrm.Tooling.Connector.CrmServiceClient(connectionString);
    
    // Cast the proxy client to the IOrganizationService interface.
    _orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
    

    Also, try to catch FaultException and provide the full stacktrace, to see what the issue is.

    // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
    catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
    {
        // You can handle an exception here or pass it back to the calling method.
        throw;
    }
  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Unable to connect CRM 365 On-Premise

    Hi Fikri,

    Please refer the discussion below. The resolution for the issue you face is described below.

    stackoverflow.com/.../dynamics-crm-caller-not-authenticated-to-service

    Also you could use the connection code as shown in the blog below.

    arunpotti.wordpress.com/.../connect-to-crm-online-or-on-premise-using-c/

    Hope this helps you.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans