Recipe 5.11. Creating a Mail-Enabled ContactProblemYou want to create a contact (or custom recipient, in Exchange 5.5 parlance) that can receive mail but that doesn't have a mailbox. SolutionUsing a graphical user interface
Figure 5-3. Specifying the alias and email address for a mail-enabled contactUsing a command-line interfaceTo create a mail-enabled contact from the command line, you need to combine the dsadd utility (which creates the contact) with exchmbx (which adds the necessary attributes for the actual mail enablement): > dsadd contact "<contactDN>" -fn "<FirstName>" -ln "<LastName>" -display "<DisplayName>" -email "<Email>" > exchmbx -b "<contactDN>" -me For example, these commands add a new contact entry for James Bond: > Dsadd contact "cn=James Bond,cn=users,dc=Robichaux,dc=net" -fn "James" -ln "Bond" -display "James Bond (007)" -email "007@secret-service.gov.uk" > Exchmbx -b "cn=James Bond,cn=users,dc=Robichaux,dc=net" -me Using VBScript' This code creates a new contact object ' ------ SCRIPT CONFIGURATION ------ strDCName = "<ServerName>" ' e.g., batman strContainer= "<container>" ' e.g., "/CN=Users, dc=robichaux, dc=net" strContactName = "<contactName>" ' e.g., "John Doe" strContactAlias = "<contactAlias>" ' e.g., "JDoe" strContactProxyAddr = "<contactSMTP>" ' e.g., "SMTP:jdoe@oreilly.com" ' ------ END CONFIGURATION --------- Set objContainer = GetObject("LDAP://" & strDCName & strContainer) Set objContact = objContainer.Create("Contact", "cn=" & strContactName) objContact.Put "mailNickname", strContactAlias With objContact .Put "mailNickname", strContactAlias .Put "displayName", strContactName .Put "targetAddress", strContactProxyAddr .Put "systemFlags", 1610612736 .SetInfo End With WScript.Echo "Created contact " & strContactAlias & " at " &_ strContactProxyAddr DiscussionContacts differ from actual user objects in several ways, all of which are related to the set of attributes associated with the respective objects. Contacts aren't security principals and don't have any of the security principals' attributes, so they cannot be used to assign privileges or to log on, nor do they have any of the SID-related attributes (SAMAccountName, objectSID, userAccountControl, and userPrincipalName) that user accounts have. They also don't have mailboxes; instead, they use the proxy address field, familiar to us as the placeholder for the address of an account's mailbox, to forward mail sent to the contact. The advantage of this approach: contacts can appear in address lists, so they look just like every other mail-enabled object. When you create a contact via ADSI, the Dsadd utility, or CSV import, you only have to specify two attributes: the DN (specified by combining the contact object's mailNickname attribute with its container path) and the primary email proxy address are required, but other attributes (including the display name, first name, last name, telephone number, and so on) are all optional. There are several important additional attributes (notably showInAddressBook, mAPIRecipient, and InternetEncoding) that will not be populated by the RUS when it next runs; you must stamp these values manually. See AlsoMS KB 275636 (Creating Exchange Mailbox-Enabled and Mail-Enabled Objects in Active Directory), MS KB 233209 (Windows 2000 Contacts and Users), and MS KB 327620 (How to use Csvde to import contacts and user objects into Active Directory) |