View Single Post
  #3 (permalink)  
Old 05-13-2008, 02:55 PM
madmaxious madmaxious is offline
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default Found the answer for me!!

Hello,

It is always the way that writing your problem down helps solve it.

If you do the following

PHP Code:
$auth Zend_Auth::getInstance();
$adapter = new Zend_Auth_Adapter_Ldap($options$username$password);

try {
        
$result $auth->authenticate($adapter);
    }
    catch (
Zend_Auth_Adapter_Exception $e)
    {
            print 
$e;
    }

$result->isValid() 
This does the check and if the user is valid creates a Session with the NameSpace of Zend_Auth

All you then need to do is create a new Zend_Session object with the namespace of Zend_Auth.

I used the code below to extract the userid of the authenticated login

PHP Code:

    $auth 
= new Zend_Session_Namespace('Zend_Auth');

    
### CHECK IF USER IS AUTHENTICATED ###
    
if (isset($auth->storage))
    {
        
$User $auth->storage;
    }
    else 
    {
        
$User 'nobody';
    } 
Thanks

Madmaxious
Reply With Quote