Lock Unlock Zimbra Account: 6 Easy Steps, 3 Mistakes
To lock unlock Zimbra account access from the command line you only need one command, zmprov ma <account> zimbraAccountStatus <status>, run as the zimbra user. Locking is the fastest safe reaction when a mailbox looks compromised: the user can no longer log in, but incoming mail keeps arriving, so nothing is lost while you investigate. This guide shows the exact steps on a real server with the account huupv02@mail.huuphan.com, the screenshots from that run, and the account statuses as the official Zimbra Administrator Guide defines them.
The old version of this article said that a locked account queues its incoming mail. That is wrong for the locked status and is corrected below.
Contents
- Zimbra account statuses explained
- Prerequisites
- Step 1: check the account status
- Step 2: lock the account
- Step 3: unlock the account
- Lock unlock Zimbra account after a compromise: what else to do
- When not to lock: maintenance, closed and failed login lockout
- Advanced: lock unlock Zimbra account lists in bulk
- Common mistakes when you lock unlock Zimbra account status
- FAQ
- Can I lock unlock Zimbra account status from a script?
- What happens when a Zimbra account is locked?
- How do I check the status of one account?
- Where are changes to accounts logged?
- References
Zimbra account statuses explained
Before you lock unlock Zimbra account settings, know what each status does. The table follows the Zimbra Administrator Guide:
| Status | Login | Incoming mail |
|---|---|---|
| active | allowed | delivered |
| locked | disabled | still delivered to the mailbox |
| maintenance | disabled | queued at the MTA |
| pending | disabled | bounced |
| closed | disabled | bounced (soft delete before removing the account) |
There is also a lockout state. It is set automatically when a user types a wrong password too often, it cannot be assigned by an administrator, and an administrator can remove it at any time. The number of failed logins and the lockout time are set in the Class of Service (Admin Console: Home, Configure, Class of Service, Advanced, Failed Login Policy). The documented defaults are 10 failed attempts and a one hour lockout.
Use locked when you suspect a compromised account and want the user out without losing mail. Use maintenance for backup or restore work, and closed before you delete an account.
Prerequisites
- Shell access to the Zimbra mailbox server with a user that can run
su - zimbra. - The Zimbra command line tools in
/opt/zimbra/bin, which are on the path of thezimbrauser. - The full address of the account. In this example it is
huupv02@mail.huuphan.com.
These three items are everything you need to lock unlock Zimbra account status on a single server or a multi server setup. Log in to the mailbox server and switch to the Zimbra user:
su - zimbra
Step 1: check the account status
Read the current value of the attribute zimbraAccountStatus with zmprov ga (getAccount) and filter it with grep. Note the @ in the address; the old article had a typo in this command.
zmprov ga huupv02@mail.huuphan.com | grep zimbraAccountStatus
The command prints one line in the form attribute: value, as in the screenshot below:
A second way to see the status is zmaccts. The Administrator Guide describes it as a report that lists all accounts, their status, when they were created and the last time anyone logged on, followed by a domain summary with the number of accounts per status:
Step 2: lock the account
To lock unlock Zimbra account access, you modify the account with zmprov ma (modifyAccount) and set the status attribute. Locking:
zmprov ma huupv02@mail.huuphan.com zimbraAccountStatus locked
Check the status again with the command from step 1. It now reports locked, and the user gets a login failure in webmail, IMAP and POP, while new mail still reaches the mailbox:
Step 3: unlock the account
Setting the status back to active finishes the lock unlock Zimbra account cycle. It takes effect for new logins; the user does not need a new password unless you also reset it.
zmprov ma huupv02@mail.huuphan.com zimbraAccountStatus active
Lock unlock Zimbra account after a compromise: what else to do
A lock stops logins, but it does not fix the cause. If the reason to lock unlock Zimbra account access was a stolen password, work through a short list before you set the status back to active:
- Lock the account with
zimbraAccountStatus lockedas in step 2, so the attacker cannot log in while mail keeps arriving for the real user. - Set a new password. The Administrator Guide gives the command form
zmprov sp user@domain.com newpassword(setPassword), which you run as thezimbrauser. - Check the mailbox for forwarding addresses and filters the attacker may have added, for example in the Admin Console under Home, Manage, Accounts.
- Unlock the account with
zimbraAccountStatus activeand tell the user the new password through another channel.
The same Admin Console path, Home, Manage, Accounts, also lets you change the account status in the graphical interface. The command line is still the better choice for scripts, bulk changes and servers where you only have a shell.
When not to lock: maintenance, closed and failed login lockout
Every tutorial about how to lock unlock Zimbra account status should say when a different status fits better. Setting maintenance keeps login disabled and queues incoming mail at the MTA, which is why Zimbra sets it during backup, import, export and restore of an account. Setting closed disables login and bounces mail; the guide describes it as a soft delete before the account is removed. Finally, do not try to set the automatic lockout state by hand, because it only appears when the failed login policy of the Class of Service triggers it.
Advanced: lock unlock Zimbra account lists in bulk
When an incident touches many mailboxes, put the addresses in a text file, one per line, and loop over them as the zimbra user:
while read -r account; do
zmprov ma "$account" zimbraAccountStatus locked
done < accounts.txt
Replace locked with active to unlock the same list. To list the accounts of a domain first, use zmprov -l gaa domain.com; the Administrator Guide notes that gaa must include the -l (LDAP) option when used as shown in its command reference.
A scheduled unlock can be done with cron in the crontab of the zimbra user. This example unlocks one address at 08:00 every day, so use it only for a deliberate, temporary lock:
0 8 * * * /opt/zimbra/bin/zmprov ma user@example.com zimbraAccountStatus active
Common mistakes when you lock unlock Zimbra account status
These are the errors that most often break a lock unlock Zimbra account change:
- Missing @ or wrong domain. The command fails if the address is not an existing account, so copy the address from
zmaccts. - Running as root. Run
zmprovas thezimbrauser (su - zimbra). - Using maintenance instead of locked. Maintenance queues mail at the MTA and is meant for backup and restore; do not use it as a security lock.
- Locking the only admin. Locking an administrator account can stop the admin console and delegated tasks, so keep a second admin.
- Waiting for the lockout. Failed login lockout is automatic and temporary; a compromised account needs an explicit
lockedstatus plus a password change.
FAQ
Can I lock unlock Zimbra account status from a script?
Yes. Both directions are one zmprov ma call, so a shell script, a cron job or a monitoring hook can lock unlock Zimbra account status as long as it runs as the zimbra user and passes the full address.
What happens when a Zimbra account is locked?
The user cannot log in, but mail continues to be delivered to the account, according to the Zimbra Administrator Guide. Messages are bounced only for the pending and closed statuses.
How do I check the status of one account?
Run zmprov ga user@example.com | grep zimbraAccountStatus as the zimbra user, or look at the full report from zmaccts. For a report on all accounts, see the guide on how to check Zimbra account status.
Where are changes to accounts logged?
Zimbra writes audit information to /opt/zimbra/log/audit.log, which the Administrator Guide mentions for actions such as View Mail. Check that file together with the mailbox log if you need to know who changed a status.
References
- Zimbra Collaboration Administrator Guide (account statuses, zmprov, zmaccts, failed login policy)
- Zimbra wiki: zmprov
That is all you need to lock unlock Zimbra account access from the shell: check the status, set locked or active with zmprov ma, and verify with zmprov ga.





This comment has been removed by a blog administrator.
ReplyDelete