This guide provides a script to test the connectivity to all LDAP servers in your environment.
-
Create and Run the Script:
Copy and paste the following script into your terminal or save it as a shell script (e.g.,
test_ldap_servers.sh
):univention-ldapsearch -LLLo ldif-wrap=no univentionService=LDAP cn associatedDomain | while IFS=': ' read k v do case "$k" in cn) h=$v ;; associatedDomain) d=$v ;; '') ldapsearch -LLL -o ldif-wrap=no -ZZ -D "$(ucr get ldap/hostdn)" -y /etc/machine.secret -h "$h.$d" -p 7389 -s base -b "$(ucr get ldap/hostdn)" dn >/dev/null || echo "FAILED: $h.$d" h= d= ;; esac done
-
Explanation of the Script:
- The script starts by using
univention-ldapsearch
to retrieve all LDAP services. - It reads each line of the output, extracting the common name (
cn
) and associated domain (associatedDomain
). - For each pair of
cn
andassociatedDomain
, it performs anldapsearch
command to test the connection to the LDAP server. - If the connection fails, it prints a message indicating which server failed.
- The script starts by using
-
Run the Script:
Execute the script in your terminal:
bash test_ldap_servers.sh
-
Check Results:
- The script will output “FAILED: <hostname>.<domain>” for each LDAP server it could not connect to.
- If no failures are reported, all LDAP servers are reachable.