The task is to establish a connection to an Active Directory or Lightweight Directory Access Protocol server.

include builtins/ldap.e
 
constant servers = {
"ldap.somewhere.com",
}
--...
string name="name", password="passwd"
--...
for i=1 to length(servers) do
    atom ld = ldap_init(servers[i])
    integer res = ldap_simple_bind_s(ld, name, password)
    printf(1,"%s: %d [%s]\n",{servers[i],res,ldap_err_desc(res)})
    --... after done with it...
    ldap_unbind(ld)
end for
