PEAR::Auth - trying to add my own storange container

From: Date: Mon, 06 Jun 2005 23:25:46 +0000
Subject: PEAR::Auth - trying to add my own storange container
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19500@lists.php.net to get a copy of this message
Hi All: I'm using PHP 5.0.3 (development server). I'm trying to create a LDAP "bind driven" storange container, which will authenticate user if he can bind LDAP server. As said at http://pear.php.net/manual/en/package.authentication.auth.intro-storage.php I've made an class "MyLDAPAuth" extending "Auth_Container" : <?php include_once ("Auth/Container.php"); class MyLDAPAuth extends Auth_Container { public $MyAuth_ldapconn; public $MyAuth_binddn; public $MyAuth_basedn; public $MyAuth_userattr; function AuthContainerDatabase ($params) {
    $host = (isset ($params["host"])) ? $params["host"] : "localhost";
    $port = (isset ($params["port"])) ? $params["port"] : "389";
    $MyAuth_basedn = (isset ($params["basedn"])) ? $params["basedn"] : "o=procuradoria_rr,t=procuradoria_rr";
    $MyAuth_userattr = (isset ($param["userattr"])) ? $params["userattr"] : "cn";
    $MyAuth_ldapconn = ldap_connect ($host, $port);
} function fetchData ($username, $password) {
    $binddn = $MyAuth_serattr."=".$username.",".$MyAuth_basedn;
/* line 23: */
    $ldapbind = ldap_bind ($MyAuth_ldapconn, $binddn, $password);
    if ($ldapbind)
      return true;
    else
      return false;
} } And create the following test script: <?php include_once ("MyLDAPAuth.php"); include_once ("Auth/Auth.php"); $params = array ("host" => "AAA.BBB.CCC.DDD", /* server IP */ "basedn" => "o=procuradoria_rr,t=procuradoria_rr", "userattr" => "cn"); $myauth = new MyLDAPAuth ($params); $a = new Auth($myauth); $a->start(); if ($a->checkAuth()) { echo "<p>Authenticated !!!</p>"; } ?> of course with the right server IP address. But I always get Warning: ldap_bind() expects parameter 1 to be resource, null given in /home/lucas/public_html/teste/MyLDAPAuth.php on line 23 So I realized that MyLDAPAuth::AuthContainerDatabase wasn't called, although docs says it is the Auth_Container constructor. So I've made: $myauth = new MyLDAPAuth (); $myauth->AuthContainerDatabase ($params); $a = new Auth($myauth); And I still getting the same error. Am I missing something ? Am I messing things up? :) -- []'s Lucas Brasilino brasilino@prrr.mpf.gov.br Procuradoria da República no Estado de Roraima +55-95-6239642 LPIC-1 Certified

« previous php.pear.general (#19500) next »