Welcome to MSDN Blogs Sign in | Join | Help

News

  • <font color="WHITE">Le Café Central de DeVa</font> DeVa rocks

    Bookmark and Share Bookmark and Share

    I changed the way of blogging, re-designed along with Windows 7 launch!!
    Additionally added feature, so that you can try to view the page in your language (any one of them)

    Deva Gnanam

    உங்கள் பேட்ஜை உருவாக்குங்கள்
    Translate into your language

    My XBOX Live

    XBox Live

    Disclaimer:

    This weblog/blog is solely my opinion.The information in this weblog/blog is provided "AS IS" with no warranties, and confers no rights. This weblog/blog does not represent the thoughts, intentions, plans or strategies of my employer. Inappropriate comments will be deleted at the authors discretion.

    Use of included script samples are subject to the terms specified in theTerms of Use

    .

    Privacy Statement:
    I do not collect personal data associated with comments posted to this site.


    Comments:
    We would like to hear your comments, reviews & valuable constructive opinion....


    Site Statistics
    Locations of visitors to this page





    Make a difference


    Subscription offer


    Developer resources



    Students free software

    Try & Test Drive Online

    More about Windows 7



    Experiences

    Go Green!!




    Get Microsoft Silverlight

Adding delegates in Exchange Web Services (Exchange Server 2007 SP1)

Delegates & Exchange Web Services 

In Microsoft Exchange Server 2007 SP1, you can use Exchange Web Services to add, update, and remove delegates.

Code sample

Please find the code example that shows you how to add delegates that can take actions on behalf of a principal. In this code it shows how to add two delegate users to an account.

static void AddDelegate()
{
    // Set the version, credentials, and Client Access server on ExchangeServiceBinding.
    ExchangeServiceBinding esb = new ExchangeServiceBinding();
    esb.RequestServerVersionValue = new RequestServerVersion();
    esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
    esb.Credentials = new NetworkCredential("username", "password", "domain");
    esb.Url = "https://example.com/ews/exchange.asmx";

    // Create the request.
    AddDelegateType request = new AddDelegateType();

    // Identify the principal's mailbox.
    request.Mailbox = new EmailAddressType();
    request.Mailbox.EmailAddress = "user1@example.com";

    // Identify the delegates who are given access to the principal's mailbox.
    request.DelegateUsers = new DelegateUserType[2];
    request.DelegateUsers[0] = new DelegateUserType();
    request.DelegateUsers[0].UserId = new UserIdType();
    request.DelegateUsers[0].UserId.PrimarySmtpAddress = "user2@example.com";
    request.DelegateUsers[1] = new DelegateUserType();
    request.DelegateUsers[1].UserId = new UserIdType();
    request.DelegateUsers[1].UserId.PrimarySmtpAddress = "user3@example.com";
   
    // Specify the permissions that are granted to each delegate.
    request.DelegateUsers[0].DelegatePermissions = new DelegatePermissionsType();
    request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevelType.Reviewer;
    request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevelSpecified = true;
    request.DelegateUsers[1].DelegatePermissions = new DelegatePermissionsType();
    request.DelegateUsers[1].DelegatePermissions.TasksFolderPermissionLevel = DelegateFolderPermissionLevelType.Author;
    request.DelegateUsers[1].DelegatePermissions.TasksFolderPermissionLevelSpecified = true;
    request.DelegateUsers[1].DelegatePermissions.InboxFolderPermissionLevel = DelegateFolderPermissionLevelType.Editor;
    request.DelegateUsers[1].DelegatePermissions.InboxFolderPermissionLevelSpecified = true;

    // Specify whether the principal recieves meeting requests.
    request.DeliverMeetingRequests = DeliverMeetingRequestsType.DelegatesAndSendInformationToMe;
    request.DeliverMeetingRequestsSpecified = true;

    try
    {
        // Send the request and get the response.
        AddDelegateResponseMessageType response = esb.AddDelegate(request);
        DelegateUserResponseMessageType[] responseMessages = response.ResponseMessages;

        // One DelegateUserResponseMessageType exists for each attempt to add a delegate user to an account.
        foreach (DelegateUserResponseMessageType user in responseMessages)
        {
            Console.WriteLine("Results of adding user: " + user.ResponseClass.ToString());
            Console.WriteLine(user.DelegateUser.UserId.DisplayName);
            Console.WriteLine(user.DelegateUser.UserId.PrimarySmtpAddress);
            Console.WriteLine(user.DelegateUser.UserId.SID);
            if (user.DelegateUser.ReceiveCopiesOfMeetingMessagesSpecified)
            {
                Console.WriteLine("Does the delegate receive copies of meeting related messages: " + user.DelegateUser.ReceiveCopiesOfMeetingMessages);
            }
            if (user.DelegateUser.ViewPrivateItemsSpecified)
            {
                Console.WriteLine("Can the delegate view private items in the principal's mailbox: " + user.DelegateUser.ViewPrivateItems);
            }
        }
        Console.ReadLine();
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

For more information refer this article

Posted: Tuesday, January 29, 2008 2:13 AM by Deva Gnanam .J

Comments

subject: exchange said:

Restore Exchange Server data with recovery storage groups Adding delegates in Exchange Web Services

# February 2, 2008 5:03 AM
New Comments to this post are disabled
Page view tracker