Connect to Windows Active Directory : LDAP

From: Date: Sun, 10 Jun 2007 19:14:40 +0000
Subject: Connect to Windows Active Directory : LDAP
Groups: php.windows 
Request: Send a blank email to php-windows+get-28053@lists.php.net to get a copy of this message
Hi, I am trying to connect to windows active directory to change user's password. I tried to use SSL connection to connect to the server. ldap_connect("ldaps://myhost.com","636") But, it always failed ( at bind, no connection ). I used ldp command which come from windows 2003 server and it finds connecting to the directory in SSL mode. Thank you. [code] class CUD_ldap { private $host; private $port; private $dn; private $u; private $p; private $conn; function CUD_ldap() {
     //$this->host = "localhost";
     //$this->port = "389";
     $this->host = "ldaps://mydomain.com";
     $this->port = "636";
     $this->dn = "CN=Users,DC=cud35,DC=com";
} function set_host( $host , $port , $dn ){
     $this->host = $host;
     $this->port = $port;
     $this->dn = $dn;
} function connect() {
     //connect to server
     $this->conn = ldap_connect($this->host,$this->port);
     if( !$this->conn ) return FALSE;
     ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($this->conn, LDAP_OPT_REFERRALS, 0);
         return $this->conn;
} function bind($user,$pass){
     $this->u = $user;
     $this->p = $pass;
     $rs = ldap_bind( $this->conn , $this->u  , $this->p ) ;
     return $rs;
} function search( $key ){
     $rs = ldap_search( $this->conn, $this->dn , $key);
     if( !$rs ) return FALSE;
     $info = ldap_get_entries( $this->conn , $rs );
     if( $info['count'] != 1 ) return FALSE;
     else return $info;
} function modify($dn,$entry){
     ldap_modify($this->conn,$dn,$entry);
} } [/code]

« previous php.windows (#28053) next »