summaryrefslogtreecommitdiff
path: root/lib/plugins/authad
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/authad')
-rw-r--r--lib/plugins/authad/action.php91
-rw-r--r--lib/plugins/authad/auth.php31
-rw-r--r--lib/plugins/authad/lang/de/lang.php8
-rw-r--r--lib/plugins/authad/lang/en/lang.php10
-rw-r--r--lib/plugins/authad/lang/es/lang.php8
-rw-r--r--lib/plugins/authad/lang/es/settings.php2
-rw-r--r--lib/plugins/authad/lang/hu/settings.php6
-rw-r--r--lib/plugins/authad/lang/ko/lang.php10
-rw-r--r--lib/plugins/authad/lang/sl/settings.php8
-rw-r--r--lib/plugins/authad/plugin.info.txt2
10 files changed, 169 insertions, 7 deletions
diff --git a/lib/plugins/authad/action.php b/lib/plugins/authad/action.php
new file mode 100644
index 000000000..97be9897e
--- /dev/null
+++ b/lib/plugins/authad/action.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * DokuWiki Plugin addomain (Action Component)
+ *
+ * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
+ * @author Andreas Gohr <gohr@cosmocode.de>
+ */
+
+// must be run within Dokuwiki
+if(!defined('DOKU_INC')) die();
+
+/**
+ * Class action_plugin_addomain
+ */
+class action_plugin_authad extends DokuWiki_Action_Plugin {
+
+ /**
+ * Registers a callback function for a given event
+ */
+ public function register(Doku_Event_Handler &$controller) {
+
+ $controller->register_hook('AUTH_LOGIN_CHECK', 'BEFORE', $this, 'handle_auth_login_check');
+ $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_html_loginform_output');
+
+ }
+
+ /**
+ * Adds the selected domain as user postfix when attempting a login
+ *
+ * @param Doku_Event $event
+ * @param array $param
+ */
+ public function handle_auth_login_check(Doku_Event &$event, $param) {
+ global $INPUT;
+
+ /** @var auth_plugin_authad $auth */
+ global $auth;
+ if(!is_a($auth, 'auth_plugin_authad')) return; // AD not even used
+
+ if($INPUT->str('dom')) {
+ $usr = $auth->cleanUser($event->data['user']);
+ $dom = $auth->_userDomain($usr);
+ if(!$dom) {
+ $usr = "$usr@".$INPUT->str('dom');
+ }
+ $INPUT->post->set('u', $usr);
+ $event->data['user'] = $usr;
+ }
+ }
+
+ /**
+ * Shows a domain selection in the login form when more than one domain is configured
+ *
+ * @param Doku_Event $event
+ * @param array $param
+ */
+ public function handle_html_loginform_output(Doku_Event &$event, $param) {
+ global $INPUT;
+ /** @var auth_plugin_authad $auth */
+ global $auth;
+ if(!is_a($auth, 'auth_plugin_authad')) return; // AD not even used
+ $domains = $auth->_getConfiguredDomains();
+ if(count($domains) <= 1) return; // no choice at all
+
+ /** @var Doku_Form $form */
+ $form =& $event->data;
+
+ // any default?
+ $dom = '';
+ if($INPUT->has('u')) {
+ $usr = $auth->cleanUser($INPUT->str('u'));
+ $dom = $auth->_userDomain($usr);
+
+ // update user field value
+ if($dom) {
+ $usr = $auth->_userName($usr);
+ $pos = $form->findElementByAttribute('name', 'u');
+ $ele =& $form->getElementAt($pos);
+ $ele['value'] = $usr;
+ }
+ }
+
+ // add select box
+ $element = form_makeListboxField('dom', $domains, $dom, $this->getLang('domain'), '', 'block');
+ $pos = $form->findElementByAttribute('name', 'p');
+ $form->insertElement($pos + 1, $element);
+ }
+
+}
+
+// vim:ts=4:sw=4:et: \ No newline at end of file
diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php
index e1d758fb8..0860e5756 100644
--- a/lib/plugins/authad/auth.php
+++ b/lib/plugins/authad/auth.php
@@ -332,11 +332,11 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin {
* @param array $filter array of field/pattern pairs, null for no filter
* @return array userinfo (refer getUserData for internal userinfo details)
*/
- public function retrieveUsers($start = 0, $limit = -1, $filter = array()) {
+ public function retrieveUsers($start = 0, $limit = 0, $filter = array()) {
$adldap = $this->_adldap(null);
if(!$adldap) return false;
- if($this->users === null) {
+ if(!$this->users) {
//get info for given user
$result = $adldap->user()->all();
if (!$result) return array();
@@ -357,7 +357,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin {
}
if($this->_filter($user, $info)) {
$result[$user] = $info;
- if(($limit >= 0) && (++$count >= $limit)) break;
+ if(($limit > 0) && (++$count >= $limit)) break;
}
}
return $result;
@@ -512,6 +512,31 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin {
}
/**
+ * Returns a list of configured domains
+ *
+ * The default domain has an empty string as key
+ *
+ * @return array associative array(key => domain)
+ */
+ public function _getConfiguredDomains() {
+ $domains = array();
+ if(empty($this->conf['account_suffix'])) return $domains; // not configured yet
+
+ // add default domain, using the name from account suffix
+ $domains[''] = ltrim($this->conf['account_suffix'], '@');
+
+ // find additional domains
+ foreach($this->conf as $key => $val) {
+ if(is_array($val) && isset($val['account_suffix'])) {
+ $domains[$key] = ltrim($val['account_suffix'], '@');
+ }
+ }
+ ksort($domains);
+
+ return $domains;
+ }
+
+ /**
* Check provided user and userinfo for matching patterns
*
* The patterns are set up with $this->_constructPattern()
diff --git a/lib/plugins/authad/lang/de/lang.php b/lib/plugins/authad/lang/de/lang.php
new file mode 100644
index 000000000..eea511d1b
--- /dev/null
+++ b/lib/plugins/authad/lang/de/lang.php
@@ -0,0 +1,8 @@
+<?php
+
+/**
+ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ *
+ * @author Andreas Gohr <gohr@cosmocode.de>
+ */
+$lang['domain'] = 'Anmelde-Domäne';
diff --git a/lib/plugins/authad/lang/en/lang.php b/lib/plugins/authad/lang/en/lang.php
new file mode 100644
index 000000000..e2967d662
--- /dev/null
+++ b/lib/plugins/authad/lang/en/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * English language file for addomain plugin
+ *
+ * @author Andreas Gohr <gohr@cosmocode.de>
+ */
+
+$lang['domain'] = 'Logon Domain';
+
+//Setup VIM: ex: et ts=4 :
diff --git a/lib/plugins/authad/lang/es/lang.php b/lib/plugins/authad/lang/es/lang.php
new file mode 100644
index 000000000..c5b242cba
--- /dev/null
+++ b/lib/plugins/authad/lang/es/lang.php
@@ -0,0 +1,8 @@
+<?php
+
+/**
+ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ *
+ * @author Juan De La Cruz <juann.dlc@gmail.com>
+ */
+$lang['domain'] = 'Dominio de inicio';
diff --git a/lib/plugins/authad/lang/es/settings.php b/lib/plugins/authad/lang/es/settings.php
index 98b78056b..9dbd44be8 100644
--- a/lib/plugins/authad/lang/es/settings.php
+++ b/lib/plugins/authad/lang/es/settings.php
@@ -5,6 +5,7 @@
*
* @author monica <may.dorado@gmail.com>
* @author Antonio Bueno <atnbueno@gmail.com>
+ * @author Juan De La Cruz <juann.dlc@gmail.com>
*/
$lang['account_suffix'] = 'Su cuenta, sufijo. Ejem. <code> @ my.domain.org </ code>';
$lang['base_dn'] = 'Su base DN. Ejem. <code>DC=my,DC=dominio,DC=org</code>';
@@ -13,3 +14,4 @@ $lang['admin_username'] = 'Un usuario con privilegios de Active Directory
$lang['admin_password'] = 'La contraseña del usuario anterior.';
$lang['sso'] = 'En caso de inicio de sesión usará ¿Kerberos o NTLM?';
$lang['sso_charset'] = 'La codificación con que tu servidor web pasará el nombre de usuario Kerberos o NTLM. Si es UTF-8 o latin-1 dejar en blanco. Requiere la extensión iconv.';
+$lang['debug'] = 'Mostrar información adicional de depuración sobre los errores?';
diff --git a/lib/plugins/authad/lang/hu/settings.php b/lib/plugins/authad/lang/hu/settings.php
index 05acbdc2d..be0592d68 100644
--- a/lib/plugins/authad/lang/hu/settings.php
+++ b/lib/plugins/authad/lang/hu/settings.php
@@ -11,11 +11,11 @@ $lang['base_dn'] = 'Bázis DN, pl. <code>DC=my,DC=domain,DC=org</c
$lang['domain_controllers'] = 'Tartománykezelők listája vesszővel elválasztva, pl. <code>srv1.domain.org,srv2.domain.org</code>.';
$lang['admin_username'] = 'Privilegizált AD felhasználó, aki az összes feéhasználó adatait elérheti. Elhagyható, de bizonyos funkciókhoz, például a feliratkozási e-mailek kiküldéséhez szükséges.';
$lang['admin_password'] = 'Ehhez tartozó jelszó.';
-$lang['sso'] = 'Single-Sign-On Kerberos-szal vagy NTML használata?';
+$lang['sso'] = 'Kerberos egyszeri bejelentkezés vagy NTLM használata?';
$lang['sso_charset'] = 'A webkiszolgáló karakterkészlete megfelel a Kerberos- és NTLM-felhasználóneveknek. Üres UTF-8 és Latin-1-hez. Szükséges az iconv bővítmény.';
$lang['real_primarygroup'] = 'A valódi elsődleges csoport feloldása a "Tartományfelhasználók" csoport használata helyett? (lassabb)';
$lang['use_ssl'] = 'SSL használata? Ha használjuk, tiltsuk le a TLS-t!';
$lang['use_tls'] = 'TLS használata? Ha használjuk, tiltsuk le az SSL-t!';
-$lang['debug'] = 'Debug-üzenetek megjelenítése?';
+$lang['debug'] = 'További hibakeresési üzenetek megjelenítése hiba esetén';
$lang['expirywarn'] = 'Felhasználók értesítése ennyi nappal a jelszavuk lejárata előtt. 0 a funkció kikapcsolásához.';
-$lang['additional'] = 'Vesszővel elválasztott lista a további AD attribútumok lekéréshez. Néhány plugin használhatja.';
+$lang['additional'] = 'Vesszővel elválasztott lista a további AD attribútumok lekéréséhez. Néhány bővítmény használhatja.';
diff --git a/lib/plugins/authad/lang/ko/lang.php b/lib/plugins/authad/lang/ko/lang.php
new file mode 100644
index 000000000..1aa436708
--- /dev/null
+++ b/lib/plugins/authad/lang/ko/lang.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Korean language file for addomain plugin
+ *
+ * @author Myeongjin <aranet100@gmail.com>
+ */
+
+$lang['domain'] = '로그온 도메인';
+
+//Setup VIM: ex: et ts=4 :
diff --git a/lib/plugins/authad/lang/sl/settings.php b/lib/plugins/authad/lang/sl/settings.php
new file mode 100644
index 000000000..bae467d6d
--- /dev/null
+++ b/lib/plugins/authad/lang/sl/settings.php
@@ -0,0 +1,8 @@
+<?php
+
+/**
+ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ *
+ * @author matej <mateju@svn.gnome.org>
+ */
+$lang['debug'] = 'Ali naj bodo prikazane dodatne podrobnosti napak?';
diff --git a/lib/plugins/authad/plugin.info.txt b/lib/plugins/authad/plugin.info.txt
index 3af1ddfbe..8774fcf3c 100644
--- a/lib/plugins/authad/plugin.info.txt
+++ b/lib/plugins/authad/plugin.info.txt
@@ -1,7 +1,7 @@
base authad
author Andreas Gohr
email andi@splitbrain.org
-date 2013-04-25
+date 2014-02-14
name Active Directory Auth Plugin
desc Provides user authentication against a Microsoft Active Directory
url http://www.dokuwiki.org/plugin:authad