Shore Up
A row of identical geometric containers with one opened and marked differently
CentOSLinuxWindowsZimbra Server

Zimbra User Management – Batch File

Ketan Aagja12 min read
No ratings yet

Everybody loves Zimbra. The best in class Zimbra Collaboration Open Source Email server with contacts, tasks and calendar management on your finger tips. I indeed love it and recommend it to small and medium businesses when they ask me how can we achieve best in-house Email server. Even many big data enterprises are also using this feature rich daemon.

Find our more information about Zimbra here – Zimbra Collaboration Open Source Edition

System / email administrators manages users from Zimbra Admin Panel where they can create / modify  and delete users and do many things.  However I find it quite lazy myself when administering users using Zimbra Admin Panel. Believe me, login on to Zimbra Admin panel, issuing admin user ID / password, searching users and managing specific tasks for users is so long.  My IT team who are working under me believes, I always find shortcuts to do tasks. Well, I think its good to save time so that you can focus on something important… !!! This is why I created this Zimbra User Management – Batch file by using which you can directly manage users.

Following activities can be done from Zimbra User Management – Batch File using SSH from any windows PC:

  • Reset User Password
  • Unlock User Account
  • Disable User Account
  • Create new Email ID

This is my guaranty, this batch file neither will affect any of your server operation nor it will modify any core configurations. It will only do the things that you are asking it to do!

Here are the basic requirements that you need when you use this batch file:

  • Install PUTTY on your windows PC where you will be using this batch file. (Get PUTTY – Free SSH and telnet Client for Windows – HERE)
  • Only use installer / setup of Putty, not the standalone Putty EXE
  • After installing Putty, just connect your Zimbra mail server first time using Putty from your Windows PC with ROOT User ID so that Putty can negotiate and accept ECDSA key fingerprint. Once done exit Putty.

My Zimbra Version - Release 8.7.3_GA_1750 (Centos 7 x64 - FOSS Edition)

Copy / Paste below batch file in notepad or any text editor.

Save as .bat file, modify below stated two lines and start using it confidently…!!!

You only have to change following  in batch file nothing else:

Line No: 9 —  srv=Your Server’s IP

Line No: 11 — pws=Your Server’s ROOT User Password

Go for it…!!!

@echo off
SETLOCAL EnableDelayedExpansion
color 1f
mode con: cols=90 lines=35
title Zimbra Server Management Script - By: Ketan Aagja
set zmp=/opt/zimbra/bin/zmprov

::Change your zimbra server IP below
set srv=MY ZIMBRA SERVER IP
:: Change your zimbra server password below
set pws=ROOT PASSWORD

echo.
echo.
echo 		   ****** PLEASE SELECT APPROPRIATE OPERATION ******
echo. 	
echo.
echo.
echo.
echo.
echo				  PRESS 1 - TO RESET USER PASSWORD
echo. 
echo.
echo.
echo. 
echo				  PRESS 2 - TO UNLOCK USER ACCOUNT
echo.
echo.
echo.
echo.  	
echo				  PRESS 3 - TO DISABLE USER ACCOUNT
echo.
echo.
echo.
echo.
echo				  PRESS 4 - TO CREATE NEW E-MAIL ID
echo.
echo. 	
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid=SELECT OPTION :      

cls

IF %vid%==1 GOTO reset
IF %vid%==2 GOTO unlock
IF %vid%==3 GOTO disab
IF %vid%==4 GOTO newacc
IF NOT DEFINED %vid% GOTO away


:reset
cls
echo.
echo.
echo 			    *** PLEASE ENTER EMAIL ID ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid1= E-MAIL ID :        
echo.
echo.
cls
echo.
echo.
echo 	*** PLEASE PROVIDE PASSWORD FOR %VID1% ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p "vid3= Password :        "
echo.
echo.
IF EXIST %TMP%\reset.log del /F %TMP%\reset.log
echo !zmp! sp !vid1! !vid3! >> %TMP%\reset.log
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh root@%srv% -pw %pws% -m %TMP%\reset.log

CLS
color 2f
echo. 	
echo.
echo.
echo 	             *** !vid3! PASSWORD HAS BEEN SET ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo 			  *** PRESS ANY KEY TO EXIT ***
pause >nul
exit


:unlock
cls
echo.
echo.
echo 		      *** PLEASE ENTER EMAIL ID TO UNLOCK ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid1= E-MAIL ID :     
echo.
echo.
IF EXIST %TMP%\unlock.log del /F %TMP%\unlock.log
echo %zmp% ma %vid1% zimbraAccountStatus active >> %TMP%\unlock.log
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh root@%srv% -pw %pws% -m %TMP%\unlock.log
CLS
color 2f
echo.
echo.
echo.
echo 	     *** %VID1% HAS BEEN SET ACTIVE ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo 			   *** PRESS ANY KEY TO EXIT ***
pause >nul
IF EXIST %TMP%\unlock.log del /F %TMP%\unlock.log
exit


:disab
cls
echo.
echo.
echo 		  *** PLEASE ENTER EMAIL ID TO DISABLE ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid1= E-MAIL ID :     
echo.
echo.
IF EXIST %TMP%\disable.log del /F %TMP%\disable.log
echo %zmp% ma %vid1% zimbraAccountStatus closed >> %TMP%\disable.log
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh root@%srv% -pw %pws% -m %TMP%\disable.log
CLS
color 2f
echo.
echo.
echo.
echo 	    *** %VID1% HAS BEEN DE-ACTIVATED ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo 			*** PRESS ANY KEY TO EXIT ***
pause >nul
IF EXIST %TMP%\disable.log del /F %TMP%\disable.log
exit

:newacc
cls
echo.
echo.
echo 		  *** PLEASE ENTER EMAIL ID TO DISABLE ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid1= E-MAIL ID :     
echo.
echo.

cls
echo.
echo.
echo 		  *** PLEASE ENTER FIRST NAME OF USER ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid2= First Name :     
echo.
echo.

cls
echo.
echo.
echo 		  *** PLEASE ENTER LAST NAME OF USER ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid3= Last Name :     
echo.
echo.
IF EXIST %TMP%\nacc.log del /F %TMP%\nacc.log
echo %zmp% ca %vid1% %pass% givenName %vid2% sn %vid3% displayName '%vid2% %vid3%' >> %TMP%\nacc.log
echo ping -n 3 127.0.0.1 >> %TMP%\nacc.log
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh root@%srv% -pw %pws% -m %TMP%\nacc.log
CLS
color 2f
echo.
echo.
echo.
echo             *** FOLLOWING EMAIL ID HAS BEEN CREATED FOR %vid2% %vid3% ***
echo. 	
echo.
echo.
echo. 
echo.
echo 		   	*** %vid1% ***
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo 			  *** PRESS ANY KEY TO EXIT ***
pause >nul
cls
IF EXIST %TMP%\nacc.log del /F %TMP%\nacc.log
exit

:away
color 9f
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo             			*** GO AWAY BAD GUY ***
echo. 	
echo.
echo.
echo. 
echo.
echo.

ping -n 4 127.0.0.1 >nul

Do write me or share your views/suggestions on how simply this is saving your time and helping you manage Zimbra users.

Written by
Ketan Aagja

Runs enterprise networks and security for a living, and writes Shore Up to turn two decades of hands-on Linux, Windows and mail-server work into guides you can actually use.

More about the author →

Was this article helpful?

Tap a star — no sign-in needed.

Be the first to rate this article.

Whitelist or Blacklist per IP on Zimbra Server – Batch File

Are you getting many spam requests from IP addresses? Do you want to block or allow IPs instantly? It’s been one hectic task for Email Administrators when they need to manage IP based whitelist and blacklist. Well here is the hassle free solution…!!! Check out my other Zimbra Batch files: Zimbra User Management Zimbra Group / Distribution Lists Management You will have to apply and modify some of the changes to get this work for you on your Zimbra Open Source Collaboration Server. Here is the guide that you need to follow first before going further below. Click HERE I believe you have changed your…

7 min read

Zimbra Group Management – Batch File

My another batch file to manage Groups or Distribution lists on Zimbra server from your Windows PC. Check out my Zimbra User Management – Batch File : HERE Find our more information about Zimbra here – Zimbra Collaboration Open Source Edition It is very simple batch file, just to achieve three simple activities from Zimbra Group Management – Batch File using SSH from any windows PC: Create Distribution List Add Member to Group List Remove member from Group Here are the basic requirements that you need when you use this batch file: Install PUTTY on your windows PC where you will be using this batch file. (Get PUTTY –…

9 min read

OpenLDAP Master Slave Replication In A Minute

Often I have seen that OpenLDAP Master Slave Replication seems heavy job for server administrators. Many articles are available to achieve this scenario but majority of the articles are so detailed that mostly administrators gets confused about their replication. Many time they applies replication configuration on server but loses data on either server or sometime whole database. Or gets locked out from database where they are not able to recover data. Many time, I also have made mistakes in learning OpenLDAP Master Slave Replication on my test servers, but just to understand and learn the whole process. Here is how you can achieve OpenLDAP Master Slave Replication in just a minute. Applied on CentOS Linux…

3 min read

Two way Dovecot Server Replication / Mirroring

Here is step-by-step guide to achieve two way Dovecot server replication / mirroring. I had been searching a lot to achieve two way dovecot server replication / mirroring and had been trying out many things. None methods were giving me sure shot and performance intensive results. Well you all do is, play with it more to understand it more and achieve more. This is what I did and achieved what I needed. Sharing with you all that what configuration I made with my both live production servers which are now replicating each and every emails with each other. I have not received any single email replication related issue since last 2 years. And still it is…

12 min read