LDAP Authentication Using CGI + TCL

How can I authenticate a user with LDAP using the CGI / TCL stack?

Provide a sample code snippet if needed.


I am using Apache web server on RHEL 5.0; AD exists on the remote Win2003 server.

+1


source to share


2 answers


Here is an example that will connect to an ldap server and get all ldap information about an email address:



package require ldap
set sEmailAddress "user@example.com"

set handle [::ldap::connect example.com 3268]
ldap::bind $handle

set result [::ldap::search $handle "dc=example,dc=com" "(mail=$sEmailAddress)" {sAMAccountName}]

foreach {object attributes} $result {
  foreach {name val} $attributes {
    puts "$name\t$val"
  }
}

      

+1


source


Here ldap package . You first connect with some "connected user" who can see everyone. Then you search for a user based on some attribute such as an email address or sAMAccountName . If the user exists, re-link with the given password and full user path.



+1


source







All Articles