SIMULATE='n'
YES="n"
-VERSION="1.2"
+VERSION="1.3"
# console colors:
RED=""
info "Setting UserStatus of '${CYAN}${USER_NAME}${NORMAL}' to '${CYAN}inactive${NORMAL}' ..."
+ debug "Trying to evaluate, whether '${CYAN}${USER_NAME}${NORMAL}' is a mail user ..."
+ local is_mail_user="n"
+
+ cmd="ldapsearch -x -LLL -o ldif-wrap=no -H '${LDAP_URL}' "
+ cmd+="-b \"${USER_DN}\" -x -D \"${BIND_DN}\" -y \"${BIND_PW_FILE}\" -s base objectClass | "
+ cmd+="grep -i '^objectClass:' | grep -q -i -w 'inetMailUser'"
+ debug "Executing: ${cmd}"
+ if $( eval ${cmd} ) ; then
+ is_mail_user="y"
+ debug "User '${CYAN}${USER_NAME}${NORMAL}' is an inetMailUser."
+ else
+ debug "User '${CYAN}${USER_NAME}${NORMAL}' is ${CYAN}not${NORMAL} an inetMailUser."
+ fi
+
cat > "${LDIF_FILE}" <<-EOF
dn: ${USER_DN}
changetype: modify
replace: inetUserStatus
inetUserStatus: inactive
-
- replace: mailUserStatus
- mailUserStatus: inactive
- -
-
EOF
+ if [[ "${is_mail_user}" == "y" ]] ; then
+ echo "replace: mailUserStatus" >> "${LDIF_FILE}"
+ echo "mailUserStatus: inactive" >> "${LDIF_FILE}"
+ echo "-" >> "${LDIF_FILE}"
+ fi
+ echo >> "${LDIF_FILE}"
+
if [[ "${VERBOSE}" == "y" ]] ; then
debug "Resulting LDIF:"
cat "${LDIF_FILE}"