LiveUser and LDAP
| From: | Christine Jones | Date: | Wed, 06 Jun 2007 23:13:56 +0000 |
| Subject: | LiveUser and LDAP | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-27433@lists.php.net to get a copy of this message | ||
Hello,
This is the list that was listed at the LiveUser wiki as the place to post general LiveUser questions. I have been using LiveUser for a year now. I was able to build two different proof of concept applications with it using DB containers. I have also used PEAR::Auth for authenticating against LDAP. Now I would like to use LiveUser to authenticate against LDAP, but am having some trouble. Any help would be much appreciated. If this is the wrong place to send this, would you please be so kind as to direct me to a more appropriate list. Thanks in advance. - Christine
I cannot seem to get by these errors:
15:25:28.79 LiveUser Critical The session cannot be started because the output already begun (i.e. headers were sent)
15:25:28.86 LiveUser Critical There is an error in the configuration parameters
Time Ident Priority Message
15:25:28.86 LiveUser Critical An error occurred Could not instanciate auth container: AuthLDAP
The first one I suspect I can figure out but the second I cannot.
Then when I try to login in my debug backtrace looks like this:
Debug Backtrace:
@ PEAR.php:908 -- call_user_func(eHandler, Object)
@ PEAR.php:572 -- pear_error->pear_error(Auth_Container_LDAP: Could not connect to server., 41, 16, eHandler, )
@ LDAP.php:291 -- pear::raiseerror(Auth_Container_LDAP: Could not connect to server., 41)
@ LDAP.php:259 -- auth_container_ldap->_connect()
@ LDAP.php:550 -- auth_container_ldap->_prepare()
@ Auth.php:519 -- auth_container_ldap->fetchdata(cjjones, xxx, )
@ Auth.php:491 -- auth->login()
@ PEARAuth.php:160 -- auth->start()
@ Common.php:340 -- liveuser_auth_pearauth->readuserdata(cjjones, xxx, )
@ LiveUser.php:1131 -- liveuser_auth_pearauth->login(cjjones, xxx, )
@ conf.php:324 -- liveuser->login(cjjones, xxx, )
@ index.php:17 -- require_once(/web/WWW/htdocs.bigsys/lu-test/ldap-eg/conf.php)
My config file contains this:
<code>
require_once 'PEAR.php';
require_once 'DB.php';
require_once 'Auth/Container/LDAP.php';
</code>
<code>
// container is passed in params and to the Auth constructor
$container = 'LDAP';
$params = array(
'url' => 'ldap://ldap.lib.ucdavis.edu:389',
'version' => 3,
'basedn' => 'dc=lib,dc=ucdavis,dc=edu',
'userattr' => 'uid',
'debug' => true,
'pearAuthContainer' => 'AuthLDAP',
);
$liveuserConfig = array(
'debug' => true,
'session' => array('name' => 'PHPSESSID','varname' => 'loginInfo'),
'logout' => array('destroy' => true),
'cookie' => array(
'name' => 'loginInfo',
'path' => null,
'domain' => null,
'secure' => false,
'lifetime' => 30,
'secret' => 'mysecretkey',
'savedir' => '.',
),
'authContainers' => array(
'AuthLDAP' => array(
'type' => 'PEARAuth',
'container' => 'LDAP',
'options' => $params,
'passwordEncryptionMode' => 'plain',
),
),
),
'permContainer' => array(
'type' => 'Complex',
'storage' => array(
'DB' => array(
'dsn' => $dsn,
'prefix' => 'liveuser_',
'alias' => array(),
'fields' => array(),
'tables' => array(),
),
),
),
); //end of config array
// Get LiveUser class definition
require_once 'LiveUser.php';
// The error handling stuff is not needed and used only for debugging
// while LiveUser is not yet mature
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'eHandler');
function eHandler($errObj)
{
echo('<hr /><span style="color: red;">' . $errObj->getMessage() . ':<br />' . $errObj->getUserInfo() . '</span><hr />');
$debug_backtrace = debug_backtrace();
array_shift($debug_backtrace);
$message= 'Debug backtrace:'."\n";
foreach ($debug_backtrace as $trace_item) {
$message.= "\t" . ' @ ';
if (array_key_exists('file', $trace_item)) {
$message.= basename($trace_item['file']) . ':' . $trace_item['line'];
} else {
$message.= '- PHP inner-code - ';
}
$message.= ' -- ';
if (array_key_exists('class', $trace_item)) {
$message.= $trace_item['class'] . $trace_item['type'];
}
$message.= $trace_item['function'];
if (array_key_exists('args', $trace_item) && is_array($trace_item['args'])) {
$message.= '('.@implode(', ', $trace_item['args']).')';
} else {
$message.= '()';
}
$message.= "\n";
}
echo "<pre>$message</pre>";
}
// Create new LiveUser object
//both factory and singleton work here
$LU =& LiveUser::factory($liveuserConfig);
$LU->getErrors();
if (!$LU->init()) {
var_dump($LU->getErrors());
die();
}
$handle = (array_key_exists('handle', $_REQUEST)) ? $_REQUEST['handle']
: null;
$passwd = (array_key_exists('passwd', $_REQUEST)) ? $_REQUEST['passwd']
: null;
$logout = (array_key_exists('logout', $_REQUEST)) ? $_REQUEST['logout']
: false;
$remember = (array_key_exists('rememberMe', $_REQUEST)) ? $_REQUEST['rememberMe'] : false;
if ($logout) {
$LU->logout(true);
} elseif(!$LU->isLoggedIn() || ($handle && $LU->getProperty('handle') != $handle)) {
if (!$handle) {
$LU->login(null, null, true);
} else {
$LU->login($handle, $passwd, $remember);
}
}
require_once 'LiveUser/Admin.php';
$luadmin =& LiveUser_Admin::factory($liveuserConfig);
$luadmin->init();
</code>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Systems
Shields Library, University of California, Davis
cjjones at ucdavis dot edu