开发者

What's wrong with UserDefaultCredentials

I'm using Exchange Web Service exposed from exchange 2007 SP1 server to create emails from my application and I've encounted a problem I can't figure out.

I get this response "When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids." everytime I try to CreateItem() from a web application.

This only happens on a Windows 2003 + IIS6 when UseDefaultCredentials = True. But it's fine if I set the credentials with New System.Net.NetworkCredential("user","password"). The latter is not an option in production.

The strangest thing is that UseDefaultCredentials = True works if I run it from VS2008 on my local machine (but the exchange server is the same remote machine). What is wrong?

To make this more readable I've pasted a code example that uses Exchange WS API 1.0 here below. But it's the same problem if I use the Exchange WS directly.

    Dim serviceObj As ExchangeService = _
        New ExchangeService(ExchangeVersion.Exchange2007_SP1)
    serviceObj.UseDefaultCredentials = True
    serviceObj.Url = New Uri(serviceUrl)
    Dim message = New EmailMessage(serviceObj)
    message.Subject = "Greetings"
    message.Body = New MessageBody(BodyType.Text, "Hello World")
    message.ToR开发者_如何学运维ecipients.Add("example@domain.com")
    message.SendAndSaveCopy()

Thankful for any thoughts.


Is this a desktop app or a web app? If it's the latter perhaps DefaultCredentials is using the app pool identity?

What happens if you use:

System.Net.CredentialCache.DefaultCredentials

And UseDefaultCredentials as false?


The problem was solved by using Impersonation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜