List:Eventum General Discussion« Previous MessageNext Message »
From:Marcio Merlone Date:September 11 2009 5:55pm
Subject:[Fwd: RE: LDAP auth]
View as plain text  
Hi,

Thanks. Just curious, why doesn't it get into the main code once for all?
Didn't try yet, too busy now. As soon as I make it work I'll post 
results here.

Best regards.

-------- Mensagem original --------
Assunto: 	RE: LDAP auth
Data: 	Fri, 11 Sep 2009 13:49:38 +0200
De: 	Gopalakrishnan.Krithivasan@stripped 
<Gopalakrishnan.Krithivasan@stripped>
Para: 	<marcio.merlone@stripped>
Referências: 	<4AAA3455.7070009@stripped>



Hi,
In login page :

$userid = $_POST['userid'];


$_POST['email'] = User::ldapmail($_POST['userid']);  /* entered userid in login page
searched via ldap and return email */
/* this is needed as $_POST['email'] is used in eventum  */

if (!Auth::userExists($_POST["email"])) {
    Auth::saveLoginAttempt($_POST["email"], 'failure', 'unknown user');
    Auth::redirect(APP_RELATIVE_URL . "index.php?err=3");
}
// check if the password matches
/* ldap code   */

if (!User::ldapauth($userid, $_POST["passwd"])) {
    Auth::saveLoginAttempt($_POST["email"], 'failure', 'wrong password');
    Auth::redirect(APP_RELATIVE_URL . "index.php?err=3&uid=" . $userid);
}  
------
In include :class.user.php
 function ldapauth($username, $pw)
   {
    $rc = false;
   	$host          = "host ur";
    $baseDn        = "ou=people,o=xyz;
    $username_attr = 'uid';
    $number        = 'sn';
    $ldap_status   = NULL;
    $ldap = ldap_connect($host)   or die("Could not connect to $ldaphost");
		$filter = "$username_attr=$username";
  	$results = ldap_search($ldap, $baseDn, $filter, array('dn','sn', 'cn',
'username','mail'));
    $info = ldap_get_entries($ldap, $results);
    $count = $info['count'];
    $dn = $info[0]['dn'];
   
        if (!isset($dn) || $dn == '' || !isset($pw) || $pw == '') {
            $rc = ldap_bind($ldap);
            $bind_dn = 'anonymous';
            return false;
        }
        else {
            $rc = @ldap_bind($ldap, $dn, $pw);
            $bind_dn = $dn;
            if( $rc == "true" )
              {
            return true;
           }
           else {
           	return false;
          }
        }
     
     }

Rgs
K.Gopalakrishnan
-----Original Message-----
From: ext Marcio Merlone [mailto:marcio.merlone@stripped] 
Sent: Friday, September 11, 2009 4:58 PM
To: eventum-users@stripped
Subject: LDAP auth

Hi all,

I need LDAP auth, but the docs did not help me. I made the changes as per Bieber Labs doc,
but it does not work, it stops on Auth::userExists, which does not check against the LDAP
db.

How's the status for LDAP auth as per Eventum 2.2? Any chance to make it work?

Thanks and best regards.

-- 
Marcio Merlone

Thread
[Fwd: RE: LDAP auth]Marcio Merlone11 Sep