Recipe17.14.Reconnecting a Deleted Mailbox


Recipe 17.14. Reconnecting a Deleted Mailbox

Problem

You want to reconnect a mailbox in the Exchange Store to a user object.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database where you want to reconnect a mailbox.

  3. In the right pane, scroll down until you find the mailbox you wish to reconnect. The mailbox should have a small red circle with a white X on it indicating it is disconnected.

  4. Right-click the mailbox and select Reconnect.

  5. Choose a user object in the directory you wish to reconnect this mailbox to.

  6. A dialog box indicating the Reconnect Operation has completed successfully should pop up. Click OK.

Using VBScript
' This code reconnects a mailbox to a user. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<Exchange Server>" ' e.g., ExchServer2 strUser = "<Userid>"              ' e.g., jsmith strMailbox = "<Mailbox Alias>"    ' e.g., jsmith ' ------ END CONFIGURATION ---------     set objWMI = GetObject("winmgmts:\\" & strComputer & _                        "\root\MicrosoftExchangeV2") set objDiscMbx = objWMI.ExecQuery("Select * from Exchange_Mailbox WHERE " _                            & "MailboxDisplayName='" & strMailbox & "'",,48) for each objMbx in objDiscMbx   objMbx.Reconnect strUser next Wscript.Echo "Successfully reconnected mailbox."

Discussion

When you tell the system to delete an Exchange mailbox, it isn't really deleted. It is simply disassociated or disconnected from the user object. These mailboxes are referred to as orphaned or disconnected. Deleted mailboxes stay in this disconnected state for a configurable period, by default 30 days, and can be recovered any time in that period. To truly remove a mailbox before that time, you must purge the mailbox after the deletion. This recipe shows how to reconnect that disconnected mailbox back to the original user object, or, if you prefer, an alternate user object.

Reconnecting a mailbox requires Exchange Service Administrator permissions plus additional permissions on user objects. See the Discussion for Recipe 17.7 and MS KB 316792.


Using a graphical user interface

You may run into a case where the ESM doesn't show you a mailbox is disconnected when, in fact, you know it is. This can happen if you delete the mailbox and immediately look at it in ESM. In order to clear that condition, you will need to right-click on the mailboxes container and select Run Cleanup Agent, causing some house cleaning to be done. The mailbox should then show up as disconnected.

On the Exchange 2000 Server CD in the Support\Utils folder, is a tool called mbconn.exe, which can also be used to reconnect mailboxes. This tool is not included on the Exchange 2003 Server CD. However, it still functions fine against Exchange 2003.


Using VBScript

The Reconnect method is part of the Exchange_Mailbox class, which is new for Exchange 2003. In Exchange 2000, there was no method available to reconnect a mailbox via a script. Unfortunately, there are some serious flaws with this implementation of the Reconnect method, which severely limits its usability in some environments.

The first flaw is that the WMI method must run directly on the Exchange Server with the disconnected mailbox, so the script must run on the Exchange server. You can't, for instance, have a script that runs from a workstation that will reconnect mailboxes on any of your Exchange servers.

The second flaw is that you cannot specify the domain of the user you want to reconnect to the mailbox. In a single domain Exchange environment, this will be fine. Trying to reconnect a mailbox in a forest with the same user name in multiple domains could give unexpected results.

See Also

Recipe 17.15, Exchange Server 2003 SDK, MS KB 274343 (How to Recover a Deleted Mailbox in Exchange), MS KB 316792 (Minimum permissions necessary to perform Exchange-related tasks), and Exchange Server 2003 SDK: WMI Reference



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net