LDAPauthentication

See also:
- Documentation: LDAPauthenticationInfo
works with:
- Wikka 1.1.6.3 & 1.1.6.4 & 1.1.6.5
NOT included in any Wikka version
Last edited by DomBonj:
Replaces old-style internal links with new pipe-split links.
Fri, 20 May 2016 07:38 UTC [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
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki