IOrganizationService with default credentials RRS feed

  • Question

  • Hello I tried to connect to the IOrganizationService with default credentials and allways get the error:
    The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
    when I pass user name, domain and password the code connect normaly, I'm sure there is a way to connect using default credentials.
     The code I used is:
          Uri organizationUri = new Uri(ConfigurationManager.AppSettings["OrganizationUri"].ToString());
          Uri homeRealmUri = null;
          ClientCredentials credentials = new ClientCredentials();
          // set default credentials for OrganizationService       
          credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
          credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; 
          OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
          serviceProxy = new OrganizationServiceProxy(
            new Uri(ConfigurationManager.AppSettings["OrganizationUri"].ToString()),

    the code is used inside an asp.net page
    Thanks in advance
    Monday, August 22, 2011 9:00 AM

All replies

  • The credential you used in code is not a member of systemusers
    daemon lin
    Monday, August 22, 2011 10:09 AM
  • Hi,

    If you will host the webpage under CRM website <CRM Web>\ISV folder then it will not work (using CRM web.config settings and Application pool will not work this way), you have to host the webpage into a separate IIS web application with a separate Application pool or you have to manually pass the user name and password i.e.


    credentials.Windows.ClientCredential  = new System.Net.NetworkCredential(prmUserName, prmPassword, prmDomain);

    You can also impersonate as other CRM users as mentioned in the following article: http://msdn.microsoft.com/en-us/library/gg309629.aspx

    Jehanzeb Javeed

    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, August 22, 2011 11:27 AM
  • Check it in the debug mode what credentials System.Net.CredentialCache.DefaultNetworkCredentials is using and if that user is crm user.


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    Monday, August 22, 2011 1:18 PM
  • Hello,

    Thanks for the response and sorry for late response from my part.

    I tried to debug and when I use (NetworkCredential)CredentialCache.DefaultCredentials or System.Net.CredentialCache.DefaultNetworkCredentials I see an empty string under user name


    Thanks Jonathan
    Wednesday, August 31, 2011 8:03 AM