local result=
local cmd_base="ldapsearch -LLL -o ldif-wrap=no "
- cmd_base+="-h \"${LDAP_HOST}\" -p ${LDAP_PORT} -b \"${LDAP_BASE}\" "
+ cmd_base+="-H \"${LDAP_URL}\" -b \"${LDAP_BASE}\" "
cmd_base+="-x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\""
local filter="(&(|(uid=${OBJECT_TOKEN})(mail=${OBJECT_TOKEN}))(userPassword=*))"
# LDAP Defaults
LDAP_USR="cn=admin"
-LDAP_PWD_FILE="${HOME}/.private/ldap-admin-wonl.txt"
+LDAP_PWD_FILE="${HOME}/.private/dirsrv-prd-dpx-admin-pwd-wonl.txt"
LDAP_BASE="o=isp"
LDAP_HOST="ldap.pixelpark.com"
-LDAP_PORT=389
+LDAP_PORT=
+LDAP_SSL="y"
+LDAP_URL=
# shellcheck disable=SC2034
LDAP_STD_OPTS_SHORT="D:y:H:P:b:"
# shellcheck disable=SC2034
-LDAP_STD_OPTS_LONG="bind-dn:,password-file:,ldap-host:,ldap-port:,base-dn:"
+LDAP_STD_OPTS_LONG="bind-dn:,password-file:,ldap-host:,ldap-port:,base-dn:,no-ldap-ssl"
# shellcheck disable=SC2034
LDAP_USAGE_MSG=$( cat <<-EOF
-H|--ldap-host HOSTNAME
The hostname or IP address of the LDAP-Server (Default: '${LDAP_HOST}').
-P|--ldap-port PORT
- The port number of the LDAP-Server (Default: ${LDAP_PORT}).
+ The port number of the LDAP-Server, if it is not the standard port.
-b|--base-dn SEARCH_BASE
The starting point for the LDAP search (Default: '${LDAP_BASE}')
+ --no-ldap-ssl Disable LDAPS on all LDAP actions.
EOF
)
shift
shift
;;
+ --no-ldap-ssl)
+ LDAP_SSL='n'
+ shift
+ ;;
--) shift
break
;;
exit 3
fi
+ if [[ "${LDAP_SSL}" == "n" ]] ; then
+ LDAP_URL="ldap://${LDAP_HOST}"
+ if [[ -n "${LDAP_PORT}" && "${LDAP_PORT}" != "389" ]] ; then
+ LDAP_URL+=":${LDAP_PORT}"
+ fi
+ else
+ LDAP_URL="ldaps://${LDAP_HOST}"
+ if [[ -n "${LDAP_PORT}" && "${LDAP_PORT}" != "636" ]] ; then
+ LDAP_URL+=":${LDAP_PORT}"
+ fi
+ fi
+
}
#------------------------------------------------------------------------------
local filter=
local cmd_base="ldapsearch -LLL -o ldif-wrap=no "
- cmd_base+="-h \"${LDAP_HOST}\" -p ${LDAP_PORT} -b \"${LDAP_BASE}\""
+ cmd_base+="-H \"${LDAP_URL}\" -b \"${LDAP_BASE}\""
cmd_base+=" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" "
for token in "${TOKENS[@]}" ; do
local result=
local cmd_base="ldapsearch -LLL -o ldif-wrap=no "
- cmd_base+="-h \"${LDAP_HOST}\" -p ${LDAP_PORT} -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" "
+ cmd_base+="-H \"${LDAP_URL}\" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" "
for token in "${TOKENS[@]}" ; do
local filter=
local cmd_base="ldapsearch -LLL -o ldif-wrap=no "
- cmd_base+="-h \"${LDAP_HOST}\" -p ${LDAP_PORT} -b \"${LDAP_BASE}\""
+ cmd_base+="-H \"${LDAP_URL}\" -b \"${LDAP_BASE}\""
cmd_base+=" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" "
for token in "${TOKENS[@]}" ; do
info "Getting DN of LDAP-Object with E-Mail address or UID '${CYAN}${user_id}${NORMAL}' ..."
- cmd="ldapsearch -LLL -o ldif-wrap=no -h \"${LDAP_HOST}\" -p ${LDAP_PORT} -b \"${LDAP_BASE}\""
+ cmd="ldapsearch -LLL -o ldif-wrap=no -H \"${LDAP_URL}\" -b \"${LDAP_BASE}\""
cmd+=" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" \"${filter}\" dn"
debug "Executing: ${cmd}"
for line in $( eval ${cmd} | grep -i '^dn:' | sed -e 's/^dn:[ ]*//i' ) ; do
ldap_filter_oclass+=")"
local filter="(&${ldap_filter_oclass}(|(uniqueMember=${dn})(member=${dn})))"
- cmd="ldapsearch -LLL -o ldif-wrap=no -h \"${LDAP_HOST}\" -p ${LDAP_PORT} -b \"${LDAP_BASE}\""
+ cmd="ldapsearch -LLL -o ldif-wrap=no -H \"${LDAP_URL}\" -b \"${LDAP_BASE}\""
cmd+=" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" \"${filter}\""
cmd+=" dn cn description mail mailAlternateAddress mailEquivalentAddress"
debug "Executing: ${cmd}"