locked
CRM 4.0 Connection issue RRS feed

  • Question

  • Hey everyone,
       
        We have just recently installed CRM 4.0 on one of our servers and I have been assigned the job to design synchronization functionality between our existing asp.net 2.0 application and CRM. Our CRM server sits on another domain then our asp.net application.
         Here is the situation:

         I have created a console windows app which i could connect to CRM using either DefaultNetworkCredentials or by specifying the creating a new NetworkCredentials object with username and password. Everything works fine. I can log into the CRM using these same username/password. Everything works fine. I even created a quick ASP.NET Web Page project, which ran under the VS2005 Development server (not IIS), and was able to connect to CRM correctly.  For some reason, when i try to connect to CRM from our web application, which uses IIS, I always get Unauthorized exception on trying to access the web service. I have tested this one the discover service and the metadata service.  I have tried impersonating myself, and it didnt work. I made sure out asp.net application web.config has <authentication mode="Windows" />.

    Here is my code:

    discoveryWS = 'http://xxxxxxx:5555/MSCRMServices/2007/AD/CrmDiscoveryService.asmx'

    if (impersonateValidUser("myusername", "mydomain", "mypassword")) { 
                    RetrieveOrganizationsRequest orgRequest = null;
          System.Net.NetworkCredential cred = new System.Net.NetworkCredential(_username, _password,                  "crmdomainname");
                    discovery.Credentials = cred;                   
                    discovery.Url = discoveryWS;
                    orgRequest = new RetrieveOrganizationsRequest();
                    try {
                        discovery.Discover();
                    }
                    catch (Exception ecx)  {
    _bag.err.add(new ExceptionsBag.Item(Errors.DiscoveryWSInvalid, new object[] {                                   ExceptionsHelper.format(ecx) }));
                        return;
                    }
                }
    }

    The impersonation works correctly, I verified it using System.Security.Principal.WindowsIdentity.GetCurrent(), but as soon
    as I call Discover() I get an exception:

    'The request failed with HTTP status 401: Unauthorized.'. 

    As far as I understand the issue is that when I log into my computer, I log into our asp.net application domain, and when I log into CRM through IE I am logging into the CRM domain, which has its own Active Directory. I have tried impersonating myself using the CRM domain, but it still did not work.

    Can anyone shed any light on this?

    If you need more information please let me know.
    Thank you very much,
    Mike

    Tuesday, May 27, 2008 10:21 PM

Answers

  • I believe Mike and I are having similar if not the same problem.  An account I work with is trying to configure the CRM client for Outlook.  It is successful on a domain computer when using the "My Company" option, but fails when using the "ISP" option.  The computer is on the same subnet as the CRM server.  Another computer, which is not a domain computer but on the same subnet as the server cannot be configured at all using "My Company" or the ISP option.  The error is always the same:  The remote server returned an error: 401 Unauthorized.  Any ideas?  The failure diagnostics from CRM diagnostics are below.  When entering the URL into a web browser, the CRM web client comes up immediately, so I know the address is good.

     

     

     

    <Type>Microsoft.Crm.Outlook.Diagnostics.ApplicationEndpointDiagnosticCheck</Type>

      <Title>Verifying Web access.</Title>
      <Status>Failed</Status>
      <Details>Microsoft.Crm.Outlook.Diagnostics.DiagnosticCheckException: The Web address (URL) specified for the installation (http://server2:5555/ESACRM) is not responding. Diagnostic tests that require connectivity will not be run. Verify the specified Web service address and check for connectivity. If necessary, rerun the CRM Configuration Wizard. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadData(Uri address) at System.Net.WebClient.DownloadData(String address) at Microsoft.Crm.Outlook.Diagnostics.ApplicationEndpointDiagnosticCheck.Execute(BackgroundWorker backgroundWorker) --- End of inner exception stack trace --- at Microsoft.Crm.Outlook.Diagnostics.ApplicationEndpointDiagnosticCheck.Execute(BackgroundWorker backgroundWorker) at Microsoft.Crm.Outlook.Diagnostics.DiagnosticCheck.DeepExecute(BackgroundWorker backgroundWorker)</Details>
     
    Tony
    Wednesday, May 28, 2008 2:48 PM

All replies

  • I believe Mike and I are having similar if not the same problem.  An account I work with is trying to configure the CRM client for Outlook.  It is successful on a domain computer when using the "My Company" option, but fails when using the "ISP" option.  The computer is on the same subnet as the CRM server.  Another computer, which is not a domain computer but on the same subnet as the server cannot be configured at all using "My Company" or the ISP option.  The error is always the same:  The remote server returned an error: 401 Unauthorized.  Any ideas?  The failure diagnostics from CRM diagnostics are below.  When entering the URL into a web browser, the CRM web client comes up immediately, so I know the address is good.

     

     

     

    <Type>Microsoft.Crm.Outlook.Diagnostics.ApplicationEndpointDiagnosticCheck</Type>

      <Title>Verifying Web access.</Title>
      <Status>Failed</Status>
      <Details>Microsoft.Crm.Outlook.Diagnostics.DiagnosticCheckException: The Web address (URL) specified for the installation (http://server2:5555/ESACRM) is not responding. Diagnostic tests that require connectivity will not be run. Verify the specified Web service address and check for connectivity. If necessary, rerun the CRM Configuration Wizard. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadData(Uri address) at System.Net.WebClient.DownloadData(String address) at Microsoft.Crm.Outlook.Diagnostics.ApplicationEndpointDiagnosticCheck.Execute(BackgroundWorker backgroundWorker) --- End of inner exception stack trace --- at Microsoft.Crm.Outlook.Diagnostics.ApplicationEndpointDiagnosticCheck.Execute(BackgroundWorker backgroundWorker) at Microsoft.Crm.Outlook.Diagnostics.DiagnosticCheck.DeepExecute(BackgroundWorker backgroundWorker)</Details>
     
    Tony
    Wednesday, May 28, 2008 2:48 PM
  • I resolved this issue. I hurrier writing this code and made a stupid mistake when i created the "discovery" property. It always returned a new object, so when i called Discover() the credentials were always null.  Feel kind of embarrased for even posting this post.   Smile



    Wednesday, May 28, 2008 3:29 PM
  • i'm having the same issue but didn't get it of how you solve it.. it's long as i see the date here.. but i hope you can answer me
    Mai Omar | Senior Solutions Developer | ITEgyptCorp | Email: maio@ITegyptCorp.com | Blog: http://maiomar.itegyptcorp.com
    Tuesday, June 8, 2010 10:20 AM