LDAPauthentication
NOT included in any Wikka versionLast edited by
DomBonj:
1.1.6.5 compatibility Sat, 28 Jun 2008 06:49 EDT [
diff]
This is the development page for the LDAPauthentication extension.
Installation
- Add the two code blocks below to
actions/usersettings.php
- Add the three lines below to
wikka.config.php
- Make sure PHP is compiled with
LDAP support∞
Code
1. In
actions/usersettings.php, go to line 82 [version 1.1.6.3 only] or 100 [versions 1.1.6.4 & 1.1.6.5 only] and replace the following code block:
if (!
defined('TEMP_PASSWORD_LABEL')) define('TEMP_PASSWORD_LABEL',
"Password reminder:");
//initialize variables
$params =
'';
with the following code block:
if (!
defined('TEMP_PASSWORD_LABEL')) define('TEMP_PASSWORD_LABEL',
"Password reminder:");
function LDAP_wikiname_to_login
($name)
{
return strtolower($name);
}
function LDAP_auth
($LDAPserver,
$LDAPreq,
$login,
$pwd)
{
$success =
false;
if ($ldapconn = ldap_connect
($LDAPserver))
{
// put here any LDAP option you may want to set
//ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($result = ldap_bind
($ldapconn,
sprintf($LDAPreq, LDAP_wikiname_to_login
($login)),
$pwd))
{
$success =
true;
}
ldap_close
($ldapconn);
}
return $success;
}
//initialize variables
$params =
'';
2. Go to line 389 [version 1.1.6.3 only] or 417 [versions 1.1.6.4 & 1.1.6.5 only] and replace the following code block:
case (strlen($_POST['password']) ==
0):
$error = ERROR_EMPTY_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
case (md5($_POST['password']) !=
$existingUser['password']):
with the following code block:
case (strlen($_POST['password']) ==
0):
$error = ERROR_EMPTY_PASSWORD;
$password_highlight = INPUT_ERROR_STYLE;
break;
case (isset($this->
config['user_identification']) &&
($this->
config['user_identification']==
'ldap') && LDAP_auth
($this->
config['ldap_server'],
$this->
config['ldap_name'],
$_POST['name'],
$_POST['password'])):
// authenticated by the LDAP directory
$this->
SetUser($existingUser);
$this->
Redirect($url,
'');
break;
case (md5($_POST['password']) !=
$existingUser['password']):
3. Add the following lines (with the appropriate values for the second and third lines) to
wikka.config.php:
'user_identification' => 'ldap',
'ldap_server' => 'myldapserver',
'ldap_name' => '%s',
CategoryUserContributions