views:

851

answers:

2

Has anyone used delegates with exchnage web services? I would like one user to be able to control other users' calendars in Exchange. I'm finding this problem to be a little tricky, and I'd like to see how others have been able to get it to work properly.

+3  A: 

I'm just getting started here, but i managed to get access to Resource calendars via a delegate account.

I used the recommendations from this article about delegate account and resource accounts. (Resource accounts are tricky because they are disabled in the AD, and you have to use a delegate account to get access to them)

After setting up the delegate account on the server, I set up the ExchangeServerBinding using the credentials of the delegate account:

ExchangeServiceBinding binding = new ExchangeServiceBinding();
binding.Url = @"https://dc1.litwareinc.com/ews/exchange.asmx";
// Setup binding with username and password of the delegate account
binding.Credentials = 
    new NetworkCredential(delegateuserName, delegatepassword, "litwareinc.com");

(I'm using Microsofts prepared virtual server image for testing)

Then when accessing the mailbox, I set up a FindItemType request and use the smtp address of the account i want to access:

// Prepare request
var findItemRequest = new FindItemType();
// Setup the mailbox using the smtp address of the account wanted
var mailbox = new EmailAddressType {EmailAddress = mailboxId};
findItemRequest.ParentFolderIds = 
    new[] {new DistinguishedFolderIdType {Mailbox = mailbox}};
((DistinguishedFolderIdType) findItemRequest.ParentFolderIds[0]).Id = 
    DistinguishedFolderIdNameType.calendar;
findItemRequest.Traversal = ItemQueryTraversalType.Shallow;

// Add ItemResponseShapeType and Calendarview to request here ...

// The create a FindItemResponseType using the binding and the request
var response = binding.FindItem(findItemRequest);

So in short:

  1. Setup an account with delegate access on the Exchange server, this can be done via owa or with a Exchange Shell script
  2. Use the account with delegate access on the ExchangeServiceBinding object
  3. Access target account using a FindItemType with the target account smtp-addres as EmailAddressType

Regards Jesper Hauge

Hauge
A: 

nice explanation

rahul