AddDelegate 操作AddDelegate operation

AddDelegate操作将一个或多个委派添加到主体的邮箱,并设置特定的访问权限。The AddDelegate operation adds one or more delegates to a principal's mailbox and sets specific access permissions.

SOAP 标头SOAP headers

AddDelegate操作可以使用下表中列出和描述的 SOAP 标头。The AddDelegate operation can use the SOAP headers that are listed and described in the following table.

HeaderHeader 元素Element 说明Description
模拟Impersonation
ExchangeImpersonationExchangeImpersonation
标识客户端应用程序模拟的用户。Identifies the user whom the client application is impersonating.
MailboxCultureMailboxCulture
MailboxCultureMailboxCulture
标识要用于访问邮箱的 RFC3066 区域性。Identifies the RFC3066 culture to be used to access the mailbox.
RequestVersionRequestVersion
RequestServerVersionRequestServerVersion
标识操作请求的架构版本。Identifies the schema version for the operation request.
ServerVersionServerVersion
ServerVersionInfoServerVersionInfo
标识响应请求的服务器版本。Identifies the version of the server that responded to the request.

AddDelegate 请求示例AddDelegate request example

DescriptionDescription

下面的AddDelegate请求示例显示了向用户2拥有的文件夹授予对 user1 委派权限的尝试。The following example of an AddDelegate request shows an attempt to give user1 delegate permissions on folders that are owned by user2. User1 拥有对 user2's 联系人文件夹的 user2's 日历文件夹和审阅者级别权限的作者级别权限。User1 is given Author-level permissions to user2's Calendar folder and Reviewer-level permissions to user2's Contacts folder. User1 将不会收到会议邮件的副本,并且无法查看 user2's 邮箱中的私人项目。User1 will not receive copies of meeting messages and will be unable to view private items in user2's mailbox. 将向 user1 和用户2发送会议请求。Meeting requests will be sent to both user1 and user2.

代码Code

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2007_SP1"/>
  </soap:Header>
  <soap:Body xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
    <AddDelegate>
      <Mailbox>
        <t:EmailAddress>user2@example.com</t:EmailAddress>
      </Mailbox>
      <DelegateUsers>
        <t:DelegateUser>
          <t:UserId>
            <t:PrimarySmtpAddress>user1@example.com</t:PrimarySmtpAddress>
          </t:UserId>
          <t:DelegatePermissions>
            <t:CalendarFolderPermissionLevel>Author</t:CalendarFolderPermissionLevel>
            <t:ContactsFolderPermissionLevel>Reviewer</t:ContactsFolderPermissionLevel>
          </t:DelegatePermissions>
          <t:ReceiveCopiesOfMeetingMessages>false</t:ReceiveCopiesOfMeetingMessages>
          <t:ViewPrivateItems>false</t:ViewPrivateItems>
        </t:DelegateUser>
      </DelegateUsers>
      <DeliverMeetingRequests>DelegatesAndMe</DeliverMeetingRequests>
    </AddDelegate>
  </soap:Body>
</soap:Envelope>

AddDelegate 响应示例AddDelegate response example

DescriptionDescription

下面的AddDelegate响应示例显示了对AddDelegate请求的成功响应。The following example of an AddDelegate response shows a successful response to an AddDelegate request.

代码Code

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" 
                         MinorVersion="1" 
                         MajorBuildNumber="206" 
                         MinorBuildNumber="0" 
                         Version="Exchange2007_SP1" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <m:AddDelegateResponse xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                           ResponseClass="Success" 
                           xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseCode>NoError</m:ResponseCode>
      <m:ResponseMessages>
        <m:DelegateUserResponseMessageType ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:DelegateUser>
              <t:UserId>
                <t:SID>S-1-5-21-1333220396-2200287332-232816053-1116</t:SID>
                <t:PrimarySmtpAddress>User1@example.com</t:PrimarySmtpAddress>
                <t:DisplayName>User1</t:DisplayName>
              </t:UserId>
              <t:ReceiveCopiesOfMeetingMessages>false</t:ReceiveCopiesOfMeetingMessages>
            <t:ViewPrivateItems>false</t:ViewPrivateItems>
            </m:DelegateUser>
        </m:DelegateUserResponseMessageType>
      </m:ResponseMessages>
    </m:AddDelegateResponse>
  </soap:Body>
</soap:Envelope>

AddDelegate 错误响应示例AddDelegate error response example

DescriptionDescription

下面的示例演示对添加代理(已添加到主体邮箱)的请求的响应。The following example shows the response to a request to add a delegate who has already been added to the principal's mailbox.

代码Code

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" 
                         MinorVersion="1" 
                         MajorBuildNumber="206" 
                         MinorBuildNumber="0" 
                         Version="Exchange2007_SP1" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <m:AddDelegateResponse xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
                           ResponseClass="Success"
                           xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseCode>NoError</m:ResponseCode>
      <m:ResponseMessages>
        <m:DelegateUserResponseMessageType ResponseClass="Error">
          <m:MessageText>The user is already a delegate for the mailbox.</m:MessageText>
          <m:ResponseCode>ErrorDelegateAlreadyExists</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:DelegateUserResponseMessageType>
      </m:ResponseMessages>
      </m:AddDelegateResponse>
  </soap:Body>
</soap:Envelope>

备注Comments

如果在尝试添加委派时返回 ErrorDelegateAlreadyExists 响应代码,请使用GetDelegate 操作获取代理的所有当前权限,然后使用UpdateDelegate 操作来设置新权限。If the ErrorDelegateAlreadyExists response code is returned when you try to add a delegate, use the GetDelegate operation to get all the current permissions for the delegate, and then use the UpdateDelegate operation to set the new permissions.

另请参阅See also