0

I used to connect to this testing application, a week later I return and have now issues authenticating. Getting a System.InvalidOperationException details below

(Exception e) {
e.Message = "Metadata contains a reference that cannot be resolved: 'https://ORGNAME.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl'."

e.InnerException = "The remote server returned an error: (407) Proxy Authentication Required."
e.InnerException.InnerException = "The logon attempt failed."

}

since I am on the domain and need the proxy to see the Organization.svc I have the following in App.config to cater for this:

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy bypassonlocal="True" proxyaddress="http://PROXYURI:8080"   />
  </defaultProxy>
</system.net>
<connectionStrings>
  <!-- using online -->
  <add name="Server=CRM Online, organization=contoso,user=someone" connectionString="Url=https://contoso.crm.dynamics.com;Username=someone@contoso.onmicrosoft.com; Password=password;"/>
</connectionStrings>

I can browse to the Organization.svc?wsdl using the browser. but not in Code c#:

// Establish a connection to the organization web service (using the above connection string).
var connection = CrmConnection.Parse(ConfigurationManager.ConnectionStrings[1].ConnectionString);

using (_orgService = new OrganizationService(connection))
{
...

    var context = new OrganizationServiceContext(_orgService);
    //than as soon as I use _orgService I get the Exception 
    List<Contact> firstNameContacts = (from c in context.CreateQuery<Contact>()
                            where c.FirstName == "Shane"
                            select c).ToList();


  ...
}

like I say nothing has changed since I last used it to connect to online MSCRM 2015 service, but for a password reset on the domain (see my comment confirming this is the issue old password seemed to be cashed only when creating the service call in code).

 `Edit`

further investigation shows that it seems to be environmental, below the trace when I run the `PluginregistrationTool`, confirming the exceptions I am getting in code (BUT WHY?)

Inner Exception<b> Level 1:</b> 
    Source  : System
    Method  : GetResponse
    Error   : `The remote server returned an error: (407) Proxy Authentication Required.`
    Stack Trace : at System.Net.HttpWebRequest.GetResponse()
    ...
    Source  : System.serviceModel
    Method  : Retrieve
    Error   : Metadata contains a reference that cannot be resolved: 'https://dev.crm4.dynamics.com/XRMServices/2011/Discovery.svc?wsdl'.
    ...
    Inner Exception <b>Level 1</b>:
    Source  : System
    Method  : GetResponse
    Error   : `The remote server returned an error: (407) Proxy Authentication Required.`
    Stack Trace : at System.Net.HttpWebRequest.GetResponse()
    ...
    Inner Exception <b>Level 2</b>  :
    Source  : System
    Error   : `The logon attempt failed`
    Stack Trace : at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode)
    ...
Shane_Yo
  • 770
  • 8
  • 24
  • So this does come down to the password change done on AD. I had to convince IT to not let my password expire and ask them if I could change my password back to last weeks password - this solved the problem, but the question remains: This is not our company policy on AD users and I cannot do this going forward. Does anyone know how and why this happened - why does the proxy try and use my old password and subsequently fail? - I'll change my original question to be more relevant to this issue. – Shane_Yo Apr 23 '15 at 06:39

1 Answers1

0

Proxy keeps username and passwords from Active Directory and should be flushed, Doing development one should use network accounts *Accounts that does not expire and would not change passwords over any period of time.

Shane_Yo
  • 770
  • 8
  • 24
  • I am facing the same issue but with other apps such as Android Studio, Eclipse, etc. Do you know how can i fix that? – thunderbird Mar 16 '17 at 07:14
  • The correct way in connecting is using a service account that is set in AD to not expire – Shane_Yo Mar 16 '17 at 07:41
  • thanks but i cant get such an account as per the IT policy.. the thing is this issue does not show up if i use the domain account to login to windows. this only shows up if i use a local account and then use the domain account to sign in to the proxy. – thunderbird Mar 16 '17 at 07:45
  • Check your registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] "ProxyEnable"=dword:00000001 "ProxyServer"=":" "ProxyOverride"="" "DisablePasswordCaching"=dword:00000001 – Shane_Yo Mar 16 '17 at 07:55
  • that didnt work either, i guess my issue is different. Proxy Authentication on IE always fails the first time and passes the second time i enter my credentials. This has something to do with domain password change. – thunderbird Mar 16 '17 at 08:46