Script Notify Expired Password on Zimbra

Posted by

When using password policy on Zimbra like minimum password age and maximum password age, user will not get notification when their password expire. I want users get notification when their password come near to expired. I am looking for that feature and finally get the script who can do that. The script can be found from Wuxmedia github at this link : https://github.com/wuxmedia/Zimbra_passpoll/blob/master/passpoll.sh

I am using these script with some modification for adjust with my Zimbra environment

# Download script

cd /srv/
wget -c https://raw.githubusercontent.com/imanudin11/script/master/cek-expire-password-zimbra.sh
chmod +x cek-expire-password-zimbra.sh
bash cek-expire-password-zimbra.sh

Note : The script have policy 90 days password expired. Please change and adjust with your environment.

The following is example when users get password policy and come near to expired password

Good luck and hopefully useful 😉

22 comments

  1. Hello,

    Thanks you for sharing,
    I’ve a doubt, how can I exec that script? (Correct way to do that).

    Would be like this “./cek-expire-password-zimbra.sh &” to keep in background running, because when I run using sudo script run ok, but my terminal session get stuck and whether I use crtl+c to get out terminal session script also will be closed.

    Thanks a lot!

    Luiz

    1. Hi Luiz,

      You can use screen before execute the script

      screen
      ./cek-expire-password-zimbra.sh
      

      If your terminal get stuck, you can re-ssh and view background process by type screen -x

  2. Hi Iman,
    Thanks you for answering!
    I’ve tried to do that unsuccessful, when I try to run this script, take too much longer, and I don’t know way the zimbra’s sevices begin to restart like a loop, just normalize when stop it, I’ve been testing with zimbra 8.7.0.

  3. This script will give us the details for only internal ladap ?
    How to get external ldap authuntication users password expiry using the script

  4. hello iman thanks for sharing the scripts.i ran the scripts but it shows:
    bash cek-expire-password-zimbra.sh
    0 Started on: Tue Feb 13 12:59:57 +06 2018
    Account: admin@zimbra.lan reports; 4 days on Password policy
    Account: spam.rkeza2gm@zimbra.lan reports; 4 days on Password policy
    Account: ham.yydptuor@zimbra.lan reports; 4 days on Password policy
    Account: virus-quarantine.5h2gaook2@zimbra.lan reports; 4 days on Password policy
    Account: galsync.pm_sr1hv@zimbra.lan reports; 4 days on Password policy
    Account: himel@zimbra.lan reports; 4 days on Password policy
    Account: abed@zimbra.lan reports; 4 days on Password policy
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    but no email sending towards the user.am i missing something

    1. Hi Roney,
      If you open the script, notifications will be sent before 7, 3 and 1 days from expiry.

      # First notification in days, then last warning:
      FIRST="7"
      LAST="3"
      
  5. Hello iman,
    we cant run the script. it gives errors;

    [zimbra@mail ~]$chmod +x passwordexpire.sh
    [zimbra@mail ~]$ bash passwordexpire.sh
    passwordexpire.sh: line 5: $’\r’: command not found
    0 Started on: Sat Feb 2 11:48:34 +03 2019
    passwordexpire.sh: line 19: $’\r’: command not found
    passwordexpire.sh: line 24: syntax error near unexpected token `$’do\r”
    ‘asswordexpire.sh: line 24: ` do

  6. We have multiple domains, How can I change the line below to show the correct domain for the user who’s password expired?

    You are being notified that your email password will expire in $DEADLINE days. Please change you email password via Webmail:
    – Akses : https://mail.imanudin.com

  7. Hello,
    I tried the above patch but i still has problem in the command that send the mail through the zimbra LMTP to the account that its password expired, the main issue is the folder path of the postifx/sendmail and the command, i tested outside the script and inside it same error
    echo “Subject:TestSendMail”;echo “Hi” | $SENDMAIL -f admin@admin.com
    Subject:TestSendMailFromZimbra
    -bash: -f: command not found
    also ./script.bash: line 69: -f: command not found
    Is the actual path is /opt/zimbra/common/sbin/ ?!!!
    Anyone can help me in that

    Hend

    1. Hi,
      In the script, Sendmail will automatically found by this command:

      # Sendmail executable
      SENDMAIL=$(ionice -c3 find /opt/zimbra/ -type f -iname sendmail)
      

      If you want test, you can point Sendmail at /opt/zimbra/common/sbin/sendmail (8.7 and later) or /opt/zimbra/postfix/sbin/sendmail (8.6 and below)

  8. Hello,

    Thanks for your above reply , i have zimbra version 8.8.15 and create the script in one of zimbra LDAP servers, then choose the below command in the script, but still gave me the below error:

    SENDMAIL=$(ionice -c3 find /opt/zimbra/common/sbin -type f -iname sendmail)
    Error
    line 108: -f: command not found
    script line 108
    108 echo “Subject: List of accounts with expired passwords” “$EXP_BODY” | $SENDMAIL -f “$FROM” “$ADMIN_RECIPIENT”

    What is wrong that i did?

    Regards
    Hend

  9. Hello thanks for this script is very usefully, I have a little question, Firstly i send mail no problem but i want to change sending mail to enconding to unicode and change FROM Name section and secondly if possible i want send html mail

    Thx for reply

  10. Hi Iman,
    everything works well except the admin account doesn’t receive expired account information. any suggestion.
    Thanks,
    Ritz

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.