Recipe17.12.Deleting a User s Mailbox


Recipe 17.12. Deleting a User's Mailbox

Problem

You want to delete a user's mailbox. This is also known as mailbox-disabling a user.

Solution

Using a graphical user interface

  1. Open the ADUC snap-in.

    This needs to be run on a workstation or server that has the Exchange Management Tools loaded (see Recipe 17.6).


  2. If you need to change domains, right-click on Active Directory Users and Computers in the left pane, select Connect to Domain, enter the domain name, and click OK.

  3. In the left pane, browse to the parent container of the user, right-click on the user, and select Exchange Tasks.

  4. On the Welcome screen, click Next.

  5. Select Remove Exchange Attributes and click Next.

  6. Read the warning and click Next.

  7. On the Completion screen, click Finish.

Using a command-line interface

See the command-line example for Recipe 17.10.

Using VBScript
' This code mail disables a user. ' ------ SCRIPT CONFIGURATION ------ strUserDN = "<UserDN>"   ' e.g., cn=jsmith,cn=Users,dc=rallencorp,dc=com ' ------ END CONFIGURATION --------- set objUser = GetObject("LDAP://" & strUserDN) objUser.DeleteMailbox objUser.SetInfo( ) Wscript.Echo "Successfully deleted user's mailbox."

Discussion

Although the recipe title is "Deleting a User's Mailbox," these solutions don't really delete the mailbox. They actually just clear the Exchange attributes from the user object and that disassociates the mailbox from the user. The mailbox will still exist in the Exchange store. The length of time it will exist depends on the mailbox retention period, which is, by default, 30 days. While the mailbox exists in that state, it can be reconnected to the same or a different user object.

Deleting user mailboxes requires Exchange Data Administrator permissions. See the Discussion for Recipe 17.7.


Using a graphical user interface

This process in ADUC is identical to that of mail-disabling a user (see Recipe 17.10).

Using VBScript

The VBScript solution leverages the CDOEXM DeleteMailbox method to delete the mailbox for the user. Unfortunately, you cannot use this method to mail-disable a user. So when you call this method, you should be sure that the user is mailbox-enabled versus mail-enabled. If you use this method on a mail-enabled user, you will get an error, such as "This user does not have a mailbox." The quick way to ascertain whether or not a user has a mailbox or is simply mail-enabled is to check for the existence of the homeMDB attribute. If a user object has homeMDB populated, there is an associated mailbox for that account.

See Also

Recipe 17.13, and Recipe 17.14, MS KB 307350 (XGEN: Using the "Remove Exchange Attributes" Option), and MS KB 274343 (How to Recover a Deleted Mailbox in Exchange)



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