I’ve got a project where we needed to make sure the user had to be authenticated against Windows Active Directory. This is what helped me.

Install the LDAP tools:
(Example in Debian)
apt-get install ldap-utils

Command to authenticate
Note: the user(Username) registered in Active Directory DN(DC=ad,DC=domain,DC=net).
(Return code of command should be 0 if successful)

ldapsearch -n -x -b 'DC=ad,DC=domain,DC=net' -H 'ldaps://my.ad.server.com' -D '{Username}' -w '{Password}' &>/dev/null

This command can then be used inside a bash script which asks first for the user and password and uses the info in the command as variables.

Example:

echo -n "Please enter you username"; read username
echo -n "Please enter you password";read passwd
if ! (ldapsearch -n -x -b 'DC=ad,DC=domain,DC=net' -H 'ldaps://my.ad.server.com' -D "$username" -w "$passwd" &>/dev/null); then
# Here goes the code if the authentication is successful
................
................
fi