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)

Unable to Login to Dynamics CRM online via a Console application

(0) ShareShare
ReportReport
Posted on by 1,004

Hi,

I am trying to connect to Dynamics CRM Online via a console application. I manged to connect successfully when I use the service account. But if I use any other user I get the following error as the last CRM error in conn object; so the orgService is null: (these users can login to CRM and do their work.)

Unable to Login to Dynamics CRMOrganizationWebProxyClient is nullOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationWebProxyClient is nullOrganizationServiceProxy is nullOrganizationWebProxyClient is nullOrganizationServiceProxy is null

Here is my code:

private static string connectionString = "Url=orgname.crm6.dynamics.com; Username=username@example.com; Password=password; authtype=Office365";

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            
CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connectionString);


IOrganizationService orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

I have tried using the organization unique name instead of org name in the connection string as suggested here:

http://missdynamicscrm.blogspot.in/2017/02/error-unable-to-login-to-dynamics.html

and also this one:

https://www.solzit.com/resolve-error-unable-login-dynamics-crmorganizationwebproxyclient-null-crm-online/

Nothing works.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Can you try and check if the following works?

    using Microsoft.Xrm.Tooling.Connector;

    string userName = ConfigurationManager.AppSettings["UserName"].ToString();

    string password = "password"

    string internalUrl = ConfigurationManager.AppSettings["InternalUrl"].ToString();

    string orgName = ConfigurationManager.AppSettings["OrgName"].ToString();

    NetworkCredential creds = new NetworkCredential(userName, ConvertToSecureString(password));

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    // Next two lines use Microsoft.Xrm.Tooling.Connector namespace;

    AuthenticationType authType = AuthenticationType.Office365;

    conn = new CrmServiceClient(userName, ConvertToSecureString(CRM_PASSWORD), "NorthAmerica", orgName, isOffice365: true);

    if (conn.IsReady)

    {

      _orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

    }

    Not sure if this will resolve your issue, but I had issues in the past with connection string as well.

    Hope this helps.

  • Verified answer
    JohnAnonymous Profile Picture
    5,241 on at

    Maybe it is due to CRM forcing you to use TLS 1.2? I had the same error using an Azure Function and forcing TLS 1.2 solved it for me.

  • Suggested answer
    Friyank Profile Picture
    944 on at

    This is because,

    CRM 365 9.0 connection  is only possible using TLS 1.2

    Hope this blog here helps you

    coderscollection.wordpress.com/.../607

  • Verified answer
    Justinjose Profile Picture
    2,707 on at

    Hi SCV,

    I am not sure tried this or not.

    Known Issue with Visual Studio 2015

    When you are running your project/solution in VS 2015 in debug mode, there is a known issue where you may not be able to connect to Dynamics 365 (online), version 9.0. This happens regardless of whether you are using a Target Framework of 4.6.2 or higher. This can occur because the Visual Studio hosting process is compiled against .NET 4.5 which means by default it does not support TLS 1.2. You can disable the Visual Studio hosting process as a work around. Right-click on the name of your project in Visual Studio and then click Properties. On the Debug tab you can uncheck the Enable the Visual Studio hosting process option.

    Please Note: This only impacts the debug experience in VS 2015. This does not impact the binaries or executable that are built. The same issue does not occur in Visual Studio 2017.

    Thanks

    Justin Jose

  • Suggested answer
    Nishant Rana Profile Picture
    11,325 Microsoft Employee on at

    We were also getting the same error - this helped

    nishantrana.me/.../

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

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