{"id":19,"date":"2007-06-14T12:16:29","date_gmt":"2007-06-14T12:16:29","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=19"},"modified":"2023-01-16T07:53:34","modified_gmt":"2023-01-16T07:53:34","slug":"adding-exchange-mailboxes-to-existing-accounts","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/adding-exchange-mailboxes-to-existing-accounts","title":{"rendered":"Adding Exchange 2003 Mailboxes to Existing Accounts"},"content":{"rendered":"<p><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">Here&#8217;s another trick that is really very simple, but, for reasons I can&#8217;t figure out, difficult to find out about. Despite what the documentation seems to say (and despite what I have read MS employees categorically stating), you CAN add an Exchange mailbox to an account that already exists in AD.<\/span><\/span><\/p>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">Bundled with MIIS are various programming extensions we make use of, including the <\/span><a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/mmsdev\/mms\/example__mailbox.asp\"><span style=\"font-family: Times New Roman;\">ExchangeUtils<\/span><\/a><span style=\"font-family: Times New Roman;\">. This collection of methods simplifies the creation of Exchange users, contacts and distribution lists &#8211; but like all these things it has its own quirks and apparent oversights.<\/span><\/span> <\/span><\/p>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">You may well think, on first glance, that ExchangeUtils.CreateMailEnabledUser would create a User+Mailbox, and ExchangeUtils.CreateMailbox would just create a mailbox, however this is not the case. If you want to create a User+Mailbox then what you need is actually ExchangeUtils.CreateMailbox. Don&#8217;t ask me what ExchangeUtils.CreateMailEnabledUser is for &#8211; I never did find a use for it.<\/span><\/span> <\/span><\/p>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">So, if you just need to create brand new users, complete with mailbox, then you&#8217;re set &#8211; use ExchangeUtils.CreateMailbox in your provisioning code, as per the examples in the Developers Reference.<\/span><\/span> <\/span><\/p>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">BUT this isn&#8217;t always enough. There are plenty of cases where you may want to add a mailbox to an existing user account. You don&#8217;t want to create a new one, because then the poor ole user will lose her password and profile. Happily it is perfectly possible to do, you just use the export flow rules in your MAExtension to set the following values:<\/span><\/span><\/span><\/span><\/p>\n<ul style=\"margin-top: 0cm;\" type=\"disc\">\n<li class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">homeMDB<\/span><\/span><\/li>\n<li class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt;\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">mDBUseDefaults<\/span><\/span><\/li>\n<\/ul>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">You&#8217;re going to need some tests before you can decide if a mailbox is needed. The first question to answer is <em>does the user already have a mailbox?<\/em> I like to use msExchMailboxGUID for this. I flow the value from AD into the metaverse, and then it&#8217;s a simple matter of checking<\/span><\/span><\/span><\/p>\n<blockquote><p><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">If mventry(&#8220;msExchMailboxGUID&#8221;).IsPresent<\/span><\/span><\/p><\/blockquote>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">Your next question is <em>should the user have a mailbox?<\/em> This is a test you can perform either in the MVExtension or in the MAExtension, though if you use the MAExtension you will have to repeat the test for each export flow rule. If you make the decision in the MVExtension then use a <\/span><a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/mmsdev\/mms\/utils_transactionproperties.asp\"><span style=\"font-family: Times New Roman;\">Utils.TransactionProperties<\/span><\/a><span style=\"font-family: Times New Roman;\"> to set a flag:<\/span><\/span><\/span><\/p>\n<blockquote><p><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">If &lt;&lt;some condition&gt;&gt; Then<\/span><\/span><br \/>\n<span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">Utils.TransactionProperties(&#8220;CreateMailbox&#8221;) = TRUE<\/span><\/span><br \/>\n<span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">End If<\/span><\/span><\/p><\/blockquote>\n<p><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">The MAExtension code will then look something like this:<\/span><\/span><\/p>\n<blockquote><p><span style=\"font-size: 8pt; color: #0000ff; font-family: 'Courier New';\">Public<\/span><span style=\"font-size: 8pt; font-family: 'Courier New';\"> <span style=\"color: #0000ff;\">Sub<\/span> MapAttributesForExport(<span style=\"color: #0000ff;\">ByVal<\/span> FlowRuleName <span style=\"color: #0000ff;\">As<\/span> <span style=\"color: #0000ff;\">String<\/span>, <span style=\"color: #0000ff;\">ByVal<\/span> <\/span><span style=\"font-size: 8pt; font-family: 'Courier New';\">mventry <span style=\"color: #0000ff;\">As<\/span> MVEntry, <span style=\"color: #0000ff;\">ByVal<\/span> csentry <span style=\"color: #0000ff;\">As<\/span> CSEntry) <\/span><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">Implements<\/span> <\/span><span style=\"font-size: 8pt; font-family: 'Courier New';\">IMASynchronization.MapAttributesForExport()<\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">Select<\/span> <span style=\"color: #0000ff;\">Case<\/span> FlowRuleName<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">Case<\/span> &#8220;exportHomeMDB&#8221;<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">If<\/span> Utils.TransactionProperties(\u00e2\u20ac\u0153CreateMailbox\u00e2\u20ac\u009d) <span style=\"color: #0000ff;\">Then<\/span> <\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\">csentry(&#8220;homeMDB&#8221;).Value = &#8220;CN=&#8221; &amp; _<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\">mventry(&#8220;MDB&#8221;).Value &amp; &#8220;,CN=&#8221; &amp; _<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\">mventry(&#8220;StorageGroup&#8221;).Value &amp; _<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\">&#8220;,CN=InformationStore,&#8221; &amp; _<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\">&#8220;CN=&#8221; &amp; mventry(&#8220;MailServer&#8221;).Value &amp; &#8220;,&#8221; &amp; _<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\">EXCHANGE_DN<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">End<\/span> <span style=\"color: #0000ff;\">If<\/span><\/span><\/span><\/p>\n<p><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">Case<\/span> &#8220;exportMDBUseDefaults&#8221;<\/span><br \/>\n<\/span><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">If<\/span> Utils.TransactionProperties(\u00e2\u20ac\u0153CreateMailbox\u00e2\u20ac\u009d) <span style=\"color: #0000ff;\">Then<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\">csentry(&#8220;mDBUseDefaults&#8221;).Value = <span style=\"color: #0000ff;\">True<\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">End<\/span> <span style=\"color: #0000ff;\">If<\/span><\/span><\/p>\n<p><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">Case<\/span> <span style=\"color: #0000ff;\">Else<\/span><\/span><\/span><br \/>\n<span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"color: #0000ff;\">Throw<\/span> <span style=\"color: #0000ff;\">New<\/span> UnexpectedDataException(&#8220;Unexpected flow rule name: &#8221; &amp; FlowRuleName)<\/span> <\/span><\/p>\n<p><span style=\"font-size: 8pt; font-family: 'Courier New';\"><span style=\"font-size: 8pt; color: #0000ff; font-family: 'Courier New';\">End<\/span><span style=\"font-size: 8pt; font-family: 'Courier New';\"> <span style=\"color: #0000ff;\">Sub<\/span><\/span><br \/>\n<\/span><\/p><\/blockquote>\n<p><span lang=\"EN-GB\"><span lang=\"EN-GB\"><span style=\"font-family: Times New Roman;\">The flow rule for homeMDB looks a bit complicated, but we&#8217;re really just constructing a long string. Use your preferred LDAP tool (I like <\/span><a href=\"http:\/\/www.ldapbrowser.com\/\"><span style=\"font-family: Times New Roman;\">Softerra<\/span><\/a><span style=\"font-family: Times New Roman;\">, but you can use <\/span><a href=\"http:\/\/support.microsoft.com\/kb\/224543\"><span style=\"font-family: Times New Roman;\">Ldp<\/span><\/a><span style=\"font-family: Times New Roman;\"> if you must) to have a look at some existing homeMDB settings in your AD forest. In my example I have the values for MDB, StorageGroup and MailServer already in the metaverse, but you may be looking them up in an XML file or something &#8211; whatever suits your installation best.<\/span><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s another trick that is really very simple, but, for reasons I can&#8217;t figure out, difficult to find out about. Despite what the documentation seems to say (and despite what I have read MS employees categorically stating), you CAN add an Exchange mailbox to an account that already exists in AD. Bundled with MIIS are&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[24,27,34,28],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-ad","category-exchange2003","category-ilm2007","category-miis2003"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-j","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":5,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":3348,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/19\/revisions\/3348"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}