#!/bin/sh
#
# Univention System Role Package
#  helper script: checks the connection to the LDAP server.
#
# SPDX-FileCopyrightText: 2010-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

eval "$(/usr/sbin/univention-config-registry shell 'ldap/server/.*')"

# shellcheck disable=SC2154
for h in $ldap_server_name $ldap_server_addition
do
	[ -n "$h" ] &&
		netcat -q0 -w4 "$h" "${ldap_server_port:-7389}" </dev/null >/dev/null 2>&1 &&
		exit 0
done
exit 1
