Widzę, że zaniedbałem temat

.
Postaram się teraz to wynagrodzić.
oto klasa napisana przeze mnie której używam do komunikacji z ldap
<?php
class Ldap
{
private $ds;
private $ldapHost;
private $ldapRdn;
private $ldapPass;
private $ldapBind;
private $compare;
private $bind;
public $error;
//----------------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------------
public function Ldap()
{
$this->ldapHost="ldap://host";
$this->ldapRdn="twoj_rdn";
$this->ldapPass="twoj_haslo";
$this->ds=ldap_connect($this->ldapHost);
if(!$this->ds)
{
$this->error="Błąd połączenia z serwerem LDAP";
return false;
}
else
{
ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
{
$this->error="Failed to set LDAP Protocol version to 3, TLS not supported.";
return false;
}
return true;
}
}
//----------------------------------------------------------------------------
// Getting connection
//----------------------------------------------------------------------------
private function isConnected() {if (!$this->ds) return false; return true;}
//----------------------------------------------------------------------------
// Reconnect
//----------------------------------------------------------------------------
private function reconnect()
{
$this->ds=ldap_connect($this->ldapHost);
if(!$this->ds)
{
$this->error="Błąd połączenia z serwerem LDAP";
return false;
}
else
{
ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
{
$this->error="Failed to set LDAP Protocol version to 3, TLS not supported.";
return false;
}
return true;
}
}
//----------------------------------------------------------------------------
// Bind
//----------------------------------------------------------------------------
private function ldapBind($rdn='',$pass='')
{
if(!$this->isConnected())
$this->reconnect();
if($rdn=='' && $pass=='')
$this->bind=ldap_bind($this->ds,$this->ldapRdn,$this->ldapPass);
else
$this->bind=ldap_bind($this->ds,$rdn,$pass);
return $this->bind;
}
//----------------------------------------------------------------------------
// Login
//----------------------------------------------------------------------------
public function ldapLogin($user,$password)
{
$filtr="uid=".$user;
$search=$this->ldapSearch($filtr);
$info = $this->ldapEntries($search);
if($info && $info['count']==1)
if($this->ldapBind($info[0]['dn'],$password))
return $info[0]['uidnumber'][0];
return false;
}
//----------------------------------------------------------------------------
// Search
//----------------------------------------------------------------------------
private function ldapSearch($filtr)
{
if(!$this->bind)
$this->ldapBind();
return ldap_search($this->ds,"ciag_dla_twojego_ldapa",$filtr);
}
//----------------------------------------------------------------------------
// Get entries
//----------------------------------------------------------------------------
private function ldapEntries($search)
{
return ldap_get_entries($this->ds, $search);
}
//----------------------------------------------------------------------------
// Search
//----------------------------------------------------------------------------
public function ldapWyszukaj($filtr)
{
if(!$this->bind)
$this->ldapBind();
$szukaj=$this->ldapSearch($filtr);
return $this->ldapEntries($szukaj);
}
}//class
?>
Jest na tyle prosta, że chyba obędzie się bez zbędnych pytań, jeżeli ktoś jednak będzie chciał się czegoś więcej dowiedzieć proszę napisz pytanie tutaj i daj znak na PW żebym wszedł tutaj i odpowiedział ( w miarę możliwości ).