Jump to content

Recommended Posts

Hello Everybody,

I'm having trouble with this class I'm making for doing LDAP authentication and Lookups.  However, I cannot output my results.  Can somebody shed some light on this please?

[code]
<?PHP
class ldap
{
  var $ldapconn; //ldap connection storage variable
  var $ldap_bind; //ldap bind storage variable
  var $entries;  //ldap entries variable
  var $dc = "my dc server";
  var $port = 389;
  var $ldapLookupUser = "ldaplookupuser";
  var $ldapLookupPass = "ldaplookup pass";
 
  function ldapConn()
  {
    $this->ldapconn = @ldap_connect($dc,$port);
  }
  function ldapBind()
  {
    $this->ldap_bind = @ldap_bind($this->ldapconn,$ldapLookupUser,$ldapLookupPass);
  }
  function ldapAuthenticate()
  {
    if(@ldap_bind($this->ldapconn,$username,$password))
      return true;
    else
      return false;
  }
  function ldapSearch($by,$search,$ou)
  {
    $read = @ldap_search($this->ldapconn, "ou=$ou,dc=mydc,dc=net", "samaccountname=*$search*");
    $entries = @ldap_get_entries($this->ldapconn, $read);
    for ($i=0; $i<$entries["count"]; $i++)
    {
      if($entries[$i][$by][0])
        $values = $values.$entries[$i][$by][0];
    }
    return $values;
  }
}
$ldap = new ldap;
$ldap->ldapConn();
$ldap->ldapBind();
$results = $ldap->ldapSearch("mail","myusrname","myou");
echo $results;
?>
[/code]
I know the ldap searches are working because it is not erroring out anymore.  Any help would be appreciated.
Link to comment
https://forums.phpfreaks.com/topic/13792-help-creating-an-ldap-class/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.