1

Topic: Disabling a User via CLI Instead of iRedAdmin

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.3.2 OPENLDAP edition
- Deployed with iRedMail Easy or the downloadable installer? downloadable installer
- Linux/BSD distribution name and version: Ubuntu 20.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx):Nginx
- Manage mail accounts with iRedAdmin-Pro? no
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Hi, I'd like to know how to disable one of my users from the CLI instead of using iRedAdmin. For example, I know there is a Python command to disable 2FA with sudo /usr/sbin/sogo-tool user-preferences set defaults user1@mailsrv.com SOGoGoogleAuthenticatorEnabled":0}'.

I’ve already tried using curl with the postmaster credentials, but that didn’t work. I need a solution for scripting purposes. Could you please guide me on how to achieve this?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Disabling a User via CLI Instead of iRedAdmin

Simply remove ldap attribute/value pair "accountStatus=active" from LDAP user object, or replace value "active" by "disabled".
Use ldapmodify command to modify LDAP data.

3

Re: Disabling a User via CLI Instead of iRedAdmin

got ldap_modify: Insufficient access (50) after running :

ldapmodify -D "cn=vmail,dc=mailsrv,dc=com" -w "your_password" <<EOF
dn: mail=user1@mailsrv.com,dc=mailsrv,dc=com
changetype: modify
replace: accountStatus
accountStatus: disabled
EOF

tried with ldif file too
the Manager and vmailadmin have write access but the password is hashed
Would it be possible to create a new LDAP user with write access without affecting the current installation or is there another way to achieve this?
Thanks for your help!

4

Re: Disabling a User via CLI Instead of iRedAdmin

sloxx wrote:

the Manager and vmailadmin have write access but the password is hashed

In the installation directory there is a file iRedMail.tips which contains all the passwords.

5

Re: Disabling a User via CLI Instead of iRedAdmin

sloxx wrote:

got ldap_modify: Insufficient access (50) after running :
ldapmodify -D "cn=vmail,dc=mailsrv,dc=com"

cn=vmail is a read-only account, please use either 'cn=vmailadmin' or 'cn=manager' instead.

6

Re: Disabling a User via CLI Instead of iRedAdmin

Solved! I'll leave this here in case anyone else needs it.

sudo ldapmodify -D "cn=vmailadmin,dc=mailsrv,dc=com" -w "your_password" <<EOF
dn: mail=user1@mailsrv.com,dc=mailsrv,dc=com
changetype: modify
replace: accountStatus
accountStatus: disabled
EOF

The passwords are in /home/ubuntu/iRedMail-1.3.2/iRedMail.tips
ZhangHuangbin papas Thanks, I really appreciate it