Example: Exchange 5.5 Custom Recipient

This example shows how to provision an Exchange 5.5 custom recipient object.

Attribute Inclusion List

You must select the following attributes from the Select Attributes property page for your your Exchange 5.5 management agent to provision an Exchange 5.5 custom recipient:

  • uid
  • cn
  • rdn
  • mail
  • rfc822Mailbox
  • textEncodedORaddress
  • MAPI-Recipient
  • Target-Address

The following example shows how to use a rules extension to provision an Exchange 5.5 custom recipient. Be sure to add a reference to logging.dll to use the LogException method.

    Public Sub Provision(ByVal mventry As MVEntry) Implements IMVSynchronization.Provision
    
          Dim ex55MA As ConnectedMA
          Dim csentry As CSEntry
          Dim nickName, displayName, smtpAddress, orAddress As String
          Dim dn As ReferenceValue
    
          Try
             'Provisioning based upon metaverse object type person
             If "person" = mventry.ObjectType Then
    
                ex55MA = mventry.ConnectedMAs("Fabrikam Ex55 MA")
    
                nickName    = mventry("mailNickname").Value
                displayName = mventry("DisplayName").Value
                smtpAddress = mventry("SMTPAddress").Value
                orAddress   = mventry("ORaddress").Value
    
                ' Construct the distinguished name
                dn = ex55MA.EscapeDNComponent("CN=" + mventry("cn").Value).Concat("cn=Recipients,ou=fabrikam,o=com")
    
                If 0 = ex55MA.Connectors.Count Then
                   csentry = ExchangeUtils.Create55CustomRecipient(ex55MA, dn, nickName, displayName, smtpAddress, orAddress)
                End If
             End If
    
             ' Log and rethrow any exception you must include the logging DLL as a dependency
          Catch ex As Exception
             Microsoft.MetadirectoryServices.Logging.Logging.LogException(ex, "Provision", "Caught exception", False)
             Throw
          End Try
       End Sub
    void IMVSynchronization.Provision (MVEntry mventry)
           {
              ConnectedMA ex55MA;
              CSEntry csentry;
              String nickName, displayName, smtpAddress, orAddress;
              ReferenceValue dn;
    
              try
              {
                 if( "person" == mventry.ObjectType )
                 {
                    ex55MA = mventry.ConnectedMAs["Fabrikam Ex55 MA"];
    
                    nickName    = mventry["mailNickname"].Value;
                    displayName = mventry["DisplayName"].Value;
                    smtpAddress = mventry["SMTPAddress"].Value;
                    orAddress   = mventry["ORaddress"].Value;
    
                    // Construct the distinguished name
                    dn = ex55MA.EscapeDNComponent("CN=" + mventry["cn"].Value).Concat("cn=Recipients,ou=fabrikam,o=com");
    
                    if(0 == ex55MA.Connectors.Count)
                    {
                       csentry = ExchangeUtils.Create55CustomRecipient(ex55MA, dn, nickName, displayName, smtpAddress, orAddress);
                    }
                 }
              }
    
              // Log and rethrow any exception
              catch(Exception ex)
              {
                 Microsoft.MetadirectoryServices.Logging.Logging.LogException(ex, "Provision", "Caught exception", false);
                 throw;
              }
           }

See Also

Create55CustomRecipient(ConnectedMA,ReferenceValue,String,String,String,String)

Send comments about this topic to Microsoft

Build date: 2/16/2009