web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to Connect custom web app to CRM 2016 Online

(1) ShareShare
ReportReport
Posted on by

I am trying to use Microsoft.Xrm.Tooling to connect my custom web service to CRM 2016 Online (office 365) but I am getting:

"Unable to Login to Dynamics CRMOrganizationServiceProxy is nullOrganizationWebProxyClient is null"

 

Same code works as console app without any issues.

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Provide code you use please.

  • Verified answer
    Mariusz Profile Picture
    on at

    It was a problem with permissions of IIS application pool service account, I haven’t looked deep into that so I don’t know exactly what permissions my service account is missing but since I changed app pool to ApplicationPoolIdentity I am able to connect.

     

    Thanks anyway.

  • Community Member Profile Picture
    on at

    Hi Mariusz

    Could you please tell what exactly you did  in order to change  app pool to ApplicationPoolIdentity? I am new at IIS,  have the same issue you had and do not know even from where to start.  

    Z góry dziękuję!

  • Mariusz Profile Picture
    on at

    After an investigation I found out that account which is used by IIS app pool must have windows user profile (files/folders). I believe that Microsoft.Xrm.Tooling is using user profile location and if you use service account that doesn’t have user profile it won’t work. Details on how to configure IIS app pool identities are here:

    http://www.iis.net/learn/manage/configuring-security/application-pool-identities

  • Daniel Ellar Profile Picture
    10 on at

    I also have a very similar problem and it occurs when running from my webapi 2 project and in the cloud on my webapp

    I create the client like so
    var serviceClient = new CrmServiceClient(AuthType=Office365;Username=<USER_NAME>; Password=<PASSWORD>;Url=https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc);

    Often I have the following properties on the client once instantiated, that means I get a null ref exception when I try to use the client
    IsReady = false
    + OrganizationServiceProxy null Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy
    + OrganizationWebProxyClient null Microsoft.Xrm.Sdk.WebServiceClient.OrganizationWebProxyClient
    LastCrmError "Unable to Login to Dynamics CRMOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationServiceProxy is nullOrganizationServiceProxy is null" string

    I found this article that helps me connect in Azure blog.vertica.dk/.../crm-2016-unable-to-login-to-dynamics-crm , but I still have the same problem in my local webapi app unless I stop my iis express process then I can SOMETIMES connect once then on the second request IsReady is false etc.

    The article says to set create the following app setting in Azure WEBSITE_LOAD_USER_PROFILE = 1 (true), and thats working for me
    Locally in my webapi app I have edited my .vs\config\applicationhost.config so that my app pool has the same setting i.e. <processModel loadUserProfile="true" />

    If I could get some help to be able to connect consistently in my local project it would be great

    Example
    Request sent from POSTMAN in my browser to webapi 2 project on my machine, connecting to CRM 2016 online

    TRACE LOG for failed attempt.
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : DiscoveryServer indicated organization service location = https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : Organization Service URI is = https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Initializing Organization Service Object
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Requesting connection to Org with CRM Version: 8.1.0.359
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Information: 8 : ConnectAndInitCrmOrgService - Using ISerivceManagement
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - attempting to connect to CRM server @ https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc
    Application Insights Telemetry (unconfigured): {"name":"Microsoft.ApplicationInsights.Dev.RemoteDependency","time":"2016-06-04T13:03:03.3822979+00:00","tags":{"ai.device.roleInstance":"<MY_PC>","ai.application.ver":"Unknown","ai.device.type":"PC","ai.device.id":"<MY_PC>","ai.device.oemName":"VMware, Inc.","ai.device.model":"VMware Virtual Platform","ai.device.network":"Ethernet","ai.device.language":"en-GB","ai.user.userAgent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36","ai.operation.name":"GET optionsets","ai.operation.id":"<REMOVED>","ai.internal.sdkVersion":"1.2.3.490"},"data":{"baseType":"RemoteDependencyData","baseData":{"ver":2,"name":"https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=8.1","kind":1,"value":<REMOVED>,"dependencyKind":1,"success":true,"async":false,"dependencySource":0,"properties":{"DeveloperMode":"true"}}}}
    Application Insights Telemetry (unconfigured): {"name":"Microsoft.ApplicationInsights.Dev.RemoteDependency","time":"2016-06-04T13:03:03.6102748+00:00","tags":{"ai.device.roleInstance":"<MY_PC>","ai.application.ver":"Unknown","ai.device.type":"PC","ai.device.id":"<MY_PC>","ai.device.oemName":"VMware, Inc.","ai.device.model":"VMware Virtual Platform","ai.device.network":"Ethernet","ai.device.language":"en-GB","ai.user.userAgent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36","ai.operation.name":"GET optionsets","ai.operation.id":"<REMOVED>","ai.internal.sdkVersion":"1.2.3.490"},"data":{"baseType":"RemoteDependencyData","baseData":{"ver":2,"name":"https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl=wsdl0","kind":1,"value":<REMOVED>,"dependencyKind":1,"success":true,"async":false,"dependencySource":0,"properties":{"DeveloperMode":"true"}}}}
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - created CRM server proxy configuration for https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc - duration: 00:00:00.4700699
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Verbose: 16 : ConnectAndInitCrmOrgService - proxy requiring authentication type : OnlineFederation
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Source : Microsoft.Xrm.Sdk
    Method : Assert
    Date : 04/06/2016
    Time : 14:03:03
    Error : clientCredentials.UserName.UserName or clientCredentials.Windows.ClientCredential.UserName MUST be populated!
    Stack Trace : at Microsoft.Xrm.Sdk.ClientExceptionHelper.Assert(Boolean condition, String message)
    at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.GetIdentityProvider(ClientCredentials clientCredentials)
    at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateOnlineFederationInternal(AuthenticationCredentials authenticationCredentials)
    at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.Authenticate(AuthenticationCredentials authenticationCredentials)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration.Authenticate(AuthenticationCredentials authenticationCredentials)
    at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.ClaimsIFDFailOverAuth[T](IServiceManagement`1 servicecfg, Uri homeRealm, ClientCredentials userCredentials, ClientCredentials deviceCredentials, Int32 depthLevel, Boolean tryNetworkCred)
    at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.CreateAndAuthenticateProxy[T](IServiceManagement`1 servicecfg, Uri ServiceUri, Uri homeRealm, ClientCredentials userCredentials, ClientCredentials deviceCredentials, String LogString)
    at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.ConnectAndInitCrmOrgService(OrganizationDetail orgdata, Boolean IsOnPrem, Uri homeRealmUri)
    at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.InitCRM2011Service()

    ======================================================================================================================

    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM
    'iisexpress.exe' (CLR v4.0.30319: <REMOVED>): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\<REMOVED>\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationWebProxyClient is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
    Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationWebProxyClient is null

  • gotdibbs Profile Picture
    45 on at

    I'm having a similar issue when trying to use CrmServiceClient to connect to an Office 365 CRM 2016 online org inside a powershell cmdlet. I'm guessing it is a similar issue, where the powershell environment likely doesn't have the right access to something. Anyone narrowed this down further to the root cause and maybe have a thought that might help?

  • Community Member Profile Picture
    on at

    Try with this:

    var serviceClient = new CrmServiceClient(AuthType=Office365;Username=<USER_NAME>; Password=<PASSWORD>;Url=https://<HOSTNAME>.api.crm4.dynamics.com/XRMServices/2011/Organization.svc);

    i.e.

    var serviceClient = new CrmServiceClient(AuthType=Office365;Username=<USER_NAME>; Password=<PASSWORD>;Url=https://<HOSTNAME>.api.crm4.dynamics.com);

  • Community Member Profile Picture
    on at

    For reference, you can enable an app pool to 'Load User Profile' by reading this post

    https://blogs.msdn.microsoft.com/vijaysk/2009/03/08/iis-7-tip-3-you-can-now-load-the-user-profile-of-the-application-pool-identity/

  • Dhananjay Pashte Profile Picture
    17 on at

    I was getting following error while connecting Dynamics 365 (Online trial) instance from Azure Worker Role application (C#).

    Error at Code Snippet:

    CrmServiceClient conn = new CrmServiceClient

    ("AuthType=Office365;Url=https://<orgname>.api.crm.dynamics.com;Username=username@<orgname>.onmicrosoft.com;Password=xxxx");

    Error:

    "Unable to Login to Dynamics CRMOrganizationServiceProxy is nullOrganizationWebProxyClient is nullOrganizationWebProxyClient is nullOrganizationServiceProxy is nullOrganizationWebProxyClient is null"

    Resolution:

    Included following lines under <configuration> in application configuration (app.config) file and I am able to connect Dynamics 365 (Online trial) instance.

    <system.net>

    <defaultProxy useDefaultCredentials="true"/>

    </system.net>

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

News and Announcements

Season of Giving Solutions is Here!

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