session_auth/ldap.py
#!/usr/bin/env python
import sys
from ldap3 import Server, Connection, ALL
myserver="dc.mydomain.it"
myuser="MYDOMAIN\\"+sys.argv[1]
mypass=sys.argv[2]
s = Server(myserver, get_info=ALL,use_ssl=True)
c = Connection(s, user=myuser, password=mypass)
if not c.bind():
print("-1")
else:
print ('0')