Skip to Main Content
Active Directory, 3rd Edition
book

Active Directory, 3rd Edition

by Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
January 2006
Beginner content levelBeginner
832 pages
27h 52m
English
O'Reilly Media, Inc.
Content preview from Active Directory, 3rd Edition

Mailbox-Disabling a User (Mailbox Deletion)

Now that you have seen how to mailbox-enable a user, it seems a good time to show a code sample illustrating this concept:

    ' This code removes a user's mailbox.
    Option Explicit
    Dim strUserDN, objUser
    ' ------ SCRIPT CONFIGURATION ------
    strUserDN = "<UserDN>"   ' e.g. cn=DrAmy,cn=Users,dc=mycorp,dc=com
    ' ------ END CONFIGURATION ---------
    Set objUser = GetObject("LDAP://" & strUserDN)
    objUser.DeleteMailBox 

    objUser.SetInfo(  )
    WScript.Echo "Successfully deleted user's mailbox."

Tip

Mailbox-disabling a user requires Exchange Data Administrator permissions.

Once again, this is a very simple script with one new method, the DeleteMailBox method. 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 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.

The DeleteMailBox method is actually not well named because it doesn't really delete the mailbox. In actuality, it disconnects the mailbox from the user. The mailbox, by default, will still exist in the exchange store for 30 days and can be reconnected to the same or any other user object that doesn't have ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory, 4th Edition

Active Directory, 4th Edition

Brian Desmond, Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
Active Directory, Second Edition

Active Directory, Second Edition

Robbie Allen, Alistair G. Lowe-Norris

Publisher Resources

ISBN: 0596101732Supplemental ContentErrata Page