views:

1263

answers:

1

I am trying to use EWS, first time trying to use the ExchangeServiceBinding. The code I am using is below:

_service = new ExchangeServiceBinding();
//_service.Credentials = new NetworkCredential(userName, userPassword, this.Domain);
_service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
_service.Url = this.ServiceURL;

ExchangeImpersonationType ei = new ExchangeImpersonationType();
ConnectingSIDType sid = new ConnectingSIDType();
sid.PrimarySmtpAddress = this.ExchangeAccount;
ei.ConnectingSID = sid;            
_service.ExchangeImpersonation = ei;

The application is an aspnet 3.5 trying to create a task using EWS. I have tried to use impersonation because I will not know the logon user's domain password, so I thought impersonation would be the best fit. Any thoughts on how I can utilize impersonation? Am I setting this correctly, I get an error while trying to run my application. I also tried without impersonation just to try to see if I can create a task, no luck either. Any help would be appreciated. Thanks.

A: 

Without broader context of your code snip, I can't tell for sure what's wrong, but here are a few things you might find useful...

You mention you had trouble connecting without impersonation. I'm assuming you are using Exchange Server 2007 SP1, yes?

Do you have a mailbox for which you do know the username and password? If so, consider trying to connect to that mailbox, just to see if you can send an email or query for inbox count. That will help verify your connection at least.

As to exchange impersonation,

  • have the permissions been set on the Client Access Server (CAS) to enable impersonation?
  • Have the permissions been set on either the mailbox or mailbox database (containing the mailbox you are attempting to access)?
  • are you in a cross-forest scenario that requires additional trust relationships?

If not, that might explain why you cannot connect.

Some links you might find useful

Alice