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

Mail-Disabling a User

Now that you have seen how to mail-enable a user, it is a good time to show a code sample illustrating mail-disabling a user:

    ' This code mail disables a user.
    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.MailDisable
    objUser.SetInfo(  )
    WScript.Echo "Successfully mail-disabled user."

Tip

Mail-disabling a user requires Exchange Data Administrator permissions.

Once again, this is a very simple script with one new method, the MailDisable method. This method is aptly named in that it mail-disables a user, and that is all it does. Unfortunately, you cannot use this method to mailbox-disable a user. So when you call this method, you should be sure that the user is mail-enabled versus mailbox-enabled. If you use this method on a mailbox-enabled user, you will get an error such as "E-mail addresses cannot be removed from this user because it has a mailbox." The quick way to ascertain whether a user has a mailbox versus being 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.

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