Connect to Windows Active Directory : LDAP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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]

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux