This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
internet:mail:zimbra:zimbra_password_policy [2019/06/07 09:04] gcooper |
internet:mail:zimbra:zimbra_password_policy [2022/03/30 08:55] (current) gcooper |
||
---|---|---|---|
Line 70: | Line 70: | ||
===== Expiring Passwords Notification ===== | ===== Expiring Passwords Notification ===== | ||
- | http://jogi-sysadmin.blogspot.com/2015/06/password-expiry-notification-for-users.html | + | **Original**: |
+ | |||
+ | < | ||
+ | cd / | ||
+ | wget https:// | ||
+ | chown zimbra.zimbra passpoll.sh | ||
+ | chmod +x passpoll.sh | ||
+ | su - zimbra | ||
+ | vi passpoll.sh | ||
+ | </ | ||
+ | |||
+ | Modify **at least**: | ||
+ | |||
+ | < | ||
+ | FROM=" | ||
+ | ADMIN_RECIPIENT=" | ||
+ | SENDMAIL=$(ionice | ||
+ | </ | ||
+ | |||
+ | Modify the '' | ||
+ | |||
+ | < | ||
+ | crontab -e | ||
+ | </ | ||
+ | |||
+ | Append at the bottom: | ||
+ | |||
+ | < | ||
+ | # Password Expiration Notifications | ||
+ | 0 8 * * * / | ||
+ | </ | ||
+ | |||
+ | ==== Modified passpoll.sh ==== | ||
+ | |||
+ | This script has been **modified from the original** in several ways, including: | ||
+ | |||
+ | * **Number of user notifications** | ||
+ | * Four including final on last day | ||
+ | * **Content of user notifications** | ||
+ | * Instructions to change password | ||
+ | * Zimbra URL | ||
+ | * **Content of admin notifications** | ||
+ | * Include log | ||
+ | * **Daily expired password notifications** | ||
< | < | ||
#!/bin/bash | #!/bin/bash | ||
- | #Script | + | # TDH 2015-04-27 |
- | # Meant to be performed as daily cronjob run as zimbra user. | + | # Messy script |
+ | # Meant to be performed as daily cronjob run as zimbra user. | ||
# redirect output to a file to get a 'log file' of sorts. | # redirect output to a file to get a 'log file' of sorts. | ||
+ | |||
+ | # Start in tmp folder to eliminate permissions warnings | ||
+ | cd /tmp | ||
# Time taken of script; | # Time taken of script; | ||
- | echo "$SECONDS | + | echo " |
- | # Set variables: | + | |
- | # First notification | + | # Set some vars: |
- | FIRST=" | + | # Notifications |
+ | FIRST=" | ||
+ | SECOND=" | ||
LAST=" | LAST=" | ||
- | # pass expiry in days, we are assuming passwd exiry is 150 Days | ||
- | POLICY=" | ||
# Sent from: | # Sent from: | ||
- | FROM=" | + | FROM=" |
+ | # Domain to check, e.g. ' | ||
+ | DOMAIN="" | ||
+ | # Recipient who should receive an email with all expired accounts | ||
+ | ADMIN_RECIPIENT=" | ||
+ | # URL for your Zimbra in message body | ||
+ | URL=" | ||
+ | |||
+ | # Sendmail executable | ||
+ | SENDMAIL=$(ionice -c3 find / | ||
# Get all users - it should run once only. | # Get all users - it should run once only. | ||
- | USERS=$(ionice -c3 / | + | USERS=$(ionice -c3 / |
#Todays date, in seconds: | #Todays date, in seconds: | ||
DATE=$(date +%s) | DATE=$(date +%s) | ||
+ | |||
# Iterate through them in for loop: | # Iterate through them in for loop: | ||
for USER in $USERS | for USER in $USERS | ||
do | do | ||
# When was the password set? | # When was the password set? | ||
- | USERINFO=$(ionice -c3 / | + | USERINFO=$(ionice -c3 / |
PASS_SET_DATE=$(echo " | PASS_SET_DATE=$(echo " | ||
+ | PASS_MAX_AGE=$(echo " | ||
NAME=$(echo " | NAME=$(echo " | ||
+ | |||
+ | # Check if we have set the account to no-expire | ||
+ | if [[ " | ||
+ | then | ||
+ | continue | ||
+ | fi | ||
# Make the date for expiry from now. | # Make the date for expiry from now. | ||
- | #echo PASS_SET_DATE is $PASS_SET_DATE | + | EXPIRES=$(date -d " |
- | EXPIRES=$(date -d " | + | |
- | #echo PASS_SET_DATE is $PASS_SET_DATE | + | |
- | #echo EXPIRES DAYS is $EXPIRES | + | |
# Now, how many days until that? | # Now, how many days until that? | ||
DEADLINE=$(( (($DATE - $EXPIRES)) / -86400 )) | DEADLINE=$(( (($DATE - $EXPIRES)) / -86400 )) | ||
- | # Email to send to users... | + | # Email to send to victims, ahem - users... |
SUBJECT=" | SUBJECT=" | ||
BODY=" | BODY=" | ||
Hi $NAME, | Hi $NAME, | ||
- | Your account password will expire in "$DEADLINE" | + | |
- | You may also enter a zimbra calendar event to remind you. | + | Your Zimbra e-mail |
- | Thanks, | + | |
- | Email Admin team | + | You can change your password in the Zimbra Web Client by clicking Preferences -> Change Password. |
+ | |||
+ | If you are seeing this message in any other mail client, click here to open the ZWC: | ||
+ | |||
+ | $URL | ||
+ | |||
+ | Thanks, | ||
+ | Your Zimbra | ||
" | " | ||
# Send it off depending on days, adding verbose statements for the ' | # Send it off depending on days, adding verbose statements for the ' | ||
Line 122: | Line 193: | ||
if [[ " | if [[ " | ||
then | then | ||
- | echo " | + | |
- | echo " | + | echo " |
# Second | # Second | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | echo " | ||
+ | # Third | ||
elif [[ " | elif [[ " | ||
then | then | ||
- | echo " | + | |
- | echo " | + | echo " |
# Final | # Final | ||
elif [[ " | elif [[ " | ||
then | then | ||
- | echo " | + | echo " |
- | echo "Last chance for: $USER - $DEADLINE days left" | + | echo "Last chance for: $USER - $DEADLINE days left" |
- | + | ||
- | # Check for Expired accounts, get last logon date add them to EXP_LIST2 | + | # Check for Expired accounts, get last logon date add them to EXP_LIST2 |
- | elif [[ " | + | #elif [[ " |
- | | + | elif [[ " |
+ | then | ||
LASTDATE=$(echo " | LASTDATE=$(echo " | ||
LOGON=$(date -d " | LOGON=$(date -d " | ||
- | EXP_LIST=$(echo " | + | |
- | | + | EXP_LIST2=" |
- | else | + | else |
# > /dev/null for less verbose logs and a list of users. | # > /dev/null for less verbose logs and a list of users. | ||
echo " | echo " | ||
Line 151: | Line 228: | ||
done | done | ||
+ | echo "" | ||
echo " | echo " | ||
- | # Send off list using hardcoded email addresses. | + | # Send off list using hardcoded email addresses. |
EXP_BODY=" | EXP_BODY=" | ||
- | Hello Email Admin team, | + | Hello Admin team, |
- | This is the monthly list of expired passwords and their last recorded login date: | + | |
+ | List of expired passwords and their last recorded login date: | ||
$(echo -e " | $(echo -e " | ||
- | Regards, | + | |
- | Email Admin Team. | + | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
+ | |||
+ | Log file: | ||
+ | |||
+ | $(cat / | ||
" | " | ||
- | echo " | + | echo " |
# Expired accts, for the log: | # Expired accts, for the log: | ||
echo -e " | echo -e " | ||
echo " | echo " | ||
- | echo "Thank you" | + | echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" |
</ | </ |