我尝试访问我的Outlook日历(Win10)。
在方法“ AutodiscoverUrl”中,它将写入所有日志和407错误。如何获得具有普通代理设置的代理身份验证(或如何获得普通系统设置)?
(Internet Explorer在本地网络设置中选中了“自动检测设置”。)
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials("abc@def.com", "secret");
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.UseDefaultCredentials = true;
service.WebProxy = WebRequest.DefaultWebProxy;
service.AutodiscoverUrl("abc@def.com", RedirectionUrlValidationCallback);
日志(缩短):
Starting SCP lookup for domainName
Searching for SCP entries in LDAP
Scanning for SCP pointers Domain
No SCP pointers found for '
Scanning for SCP urls for the current computer
Adding (prio 1) ..[some values here].... to the top of the list (exact match)
Trying to call Autodiscover
AutodiscoverRequestHttpHeaders:
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
AutodiscoverResponseHttpHeaders:
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Proxy-Connection: close
Connection: close
failed: WebException (The remoteserver returns an error: (407) 407 Proxy authentication required)
答案 0 :(得分:0)
建议
将UseDefaultCredentials属性设置为true会自动设置 将Credentials属性设置为空引用(Visual中没有 基本)。
在您似乎通过以下方式提供凭据时,请尝试将UseDefaultCredentials
设置为false
service.Credentials = new WebCredentials("abc@def.com", "secret");
答案 1 :(得分:0)
要做的第一件事是调试代码并设置断点,然后查看一下为WebProxy返回的值。例如,您可能会返回ProxyURL,但是Proxy的凭据对象为null,因此它将使身份验证失败。因此,要解决此问题,您可能需要使用自己的IProxy接口实现(这很容易,因为它只有三个属性)。