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.

    Tip

    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, ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.