UseDefaultCredentials with Exchange Web Services

二次信任 提交于 2019-12-07 11:58:37

问题


I'm a pretty new programmer. One of the things I've been tasked with at work is getting our custom tools to create draft emails and drop them into the draft email folder of the user running the tool. We presently use Exchange Server 2010 (but are in the process of migrating over to Exchange Online).

This link talks about a UseDefaultCredentials but I can't seem to work out how to implement it. I created an ExchangeService object called service and managed to interact with our Exchange server using this for credentials:

service.Credentials = new WebCredentials("my login name", "my password");

I'd like to be able to eliminate that from the code and have it use the credentials of the logged-in user who is using the tool. Is that possible?


回答1:


ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials(CredentialCache.DefaultNetworkCredentials);



回答2:


if you use the defaultcredentials you can eliminate your posted code. Just set "UseDefaultCredentials" to True and don't set the Credentials manually. In this case the credentials of the User who is running your tool will be taken. I use that on my own and it works finde for me.

Greets, J



来源:https://stackoverflow.com/questions/15296720/usedefaultcredentials-with-exchange-web-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!