aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/ajax/clearMappings.php2
-rw-r--r--apps/user_ldap/ajax/getConfiguration.php2
-rw-r--r--apps/user_ldap/ajax/getNewServerConfigPrefix.php2
-rw-r--r--apps/user_ldap/ajax/setConfiguration.php2
-rw-r--r--apps/user_ldap/css/settings.css10
-rw-r--r--apps/user_ldap/group_proxy.php2
-rw-r--r--apps/user_ldap/js/settings.js9
-rw-r--r--apps/user_ldap/l10n/ru_RU.php6
-rw-r--r--apps/user_ldap/lib/connection.php21
-rw-r--r--apps/user_ldap/lib/helper.php28
-rw-r--r--apps/user_ldap/lib/proxy.php2
-rw-r--r--apps/user_ldap/settings.php2
-rw-r--r--apps/user_ldap/templates/settings.php13
-rw-r--r--apps/user_ldap/user_ldap.php10
-rw-r--r--apps/user_ldap/user_proxy.php2
15 files changed, 82 insertions, 31 deletions
diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php
index 5dab39839b6..9118d58c5cf 100644
--- a/apps/user_ldap/ajax/clearMappings.php
+++ b/apps/user_ldap/ajax/clearMappings.php
@@ -32,4 +32,4 @@ if(\OCA\user_ldap\lib\Helper::clearMapping($subject)) {
} else {
$l=OC_L10N::get('user_ldap');
OCP\JSON::error(array('message' => $l->t('Failed to clear the mappings.')));
-} \ No newline at end of file
+}
diff --git a/apps/user_ldap/ajax/getConfiguration.php b/apps/user_ldap/ajax/getConfiguration.php
index dfae68d2dc9..baca588976f 100644
--- a/apps/user_ldap/ajax/getConfiguration.php
+++ b/apps/user_ldap/ajax/getConfiguration.php
@@ -28,4 +28,4 @@ OCP\JSON::callCheck();
$prefix = $_POST['ldap_serverconfig_chooser'];
$connection = new \OCA\user_ldap\lib\Connection($prefix);
-OCP\JSON::success(array('configuration' => $connection->getConfiguration())); \ No newline at end of file
+OCP\JSON::success(array('configuration' => $connection->getConfiguration()));
diff --git a/apps/user_ldap/ajax/getNewServerConfigPrefix.php b/apps/user_ldap/ajax/getNewServerConfigPrefix.php
index 17e78f87072..1c68b2e9a76 100644
--- a/apps/user_ldap/ajax/getNewServerConfigPrefix.php
+++ b/apps/user_ldap/ajax/getNewServerConfigPrefix.php
@@ -31,4 +31,4 @@ sort($serverConnections);
$lk = array_pop($serverConnections);
$ln = intval(str_replace('s', '', $lk));
$nk = 's'.str_pad($ln+1, 2, '0', STR_PAD_LEFT);
-OCP\JSON::success(array('configPrefix' => $nk)); \ No newline at end of file
+OCP\JSON::success(array('configPrefix' => $nk));
diff --git a/apps/user_ldap/ajax/setConfiguration.php b/apps/user_ldap/ajax/setConfiguration.php
index 206487c7e0a..d850bda2470 100644
--- a/apps/user_ldap/ajax/setConfiguration.php
+++ b/apps/user_ldap/ajax/setConfiguration.php
@@ -30,4 +30,4 @@ $prefix = $_POST['ldap_serverconfig_chooser'];
$connection = new \OCA\user_ldap\lib\Connection($prefix);
$connection->setConfiguration($_POST);
$connection->saveConfiguration();
-OCP\JSON::success(); \ No newline at end of file
+OCP\JSON::success();
diff --git a/apps/user_ldap/css/settings.css b/apps/user_ldap/css/settings.css
index 185952e14bb..6086c7b74e6 100644
--- a/apps/user_ldap/css/settings.css
+++ b/apps/user_ldap/css/settings.css
@@ -3,14 +3,20 @@
max-width: 200px;
display: inline-block;
vertical-align: top;
+ text-align: right;
padding-top: 9px;
+ padding-right: 5px;
}
#ldap fieldset input, #ldap fieldset textarea {
- width: 70%;
+ width: 60%;
display: inline-block;
}
+#ldap fieldset p input[type=checkbox] {
+ vertical-align: bottom;
+}
+
.ldapIndent {
margin-left: 50px;
}
@@ -18,4 +24,4 @@
.ldapwarning {
margin-left: 1.4em;
color: #FF3B3B;
-} \ No newline at end of file
+}
diff --git a/apps/user_ldap/group_proxy.php b/apps/user_ldap/group_proxy.php
index 75e7cd46336..eb6f176c58c 100644
--- a/apps/user_ldap/group_proxy.php
+++ b/apps/user_ldap/group_proxy.php
@@ -198,4 +198,4 @@ class Group_Proxy extends lib\Proxy implements \OCP\GroupInterface {
//it's the same across all our user backends obviously
return $this->refBackend->implementsActions($actions);
}
-} \ No newline at end of file
+}
diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js
index 52d5dbc48d9..78ec71b70ad 100644
--- a/apps/user_ldap/js/settings.js
+++ b/apps/user_ldap/js/settings.js
@@ -176,6 +176,13 @@ $(document).ready(function() {
$('#ldap_submit').effect('highlight', {'color':'#A8FA87'}, 5000, function() {
$('#ldap_submit').css('background', bgcolor);
});
+ //update the Label in the config chooser
+ caption = $('#ldap_serverconfig_chooser option:selected:first').text();
+ pretext = '. Server: ';
+ caption = caption.slice(0, caption.indexOf(pretext) + pretext.length);
+ caption = caption + $('#ldap_host').val();
+ $('#ldap_serverconfig_chooser option:selected:first').text(caption);
+
} else {
$('#ldap_submit').css('background', '#fff');
$('#ldap_submit').effect('highlight', {'color':'#E97'}, 5000, function() {
@@ -204,4 +211,4 @@ $(document).ready(function() {
LdapConfiguration.refreshConfig();
}
});
-}); \ No newline at end of file
+});
diff --git a/apps/user_ldap/l10n/ru_RU.php b/apps/user_ldap/l10n/ru_RU.php
deleted file mode 100644
index 623d8f2d8ec..00000000000
--- a/apps/user_ldap/l10n/ru_RU.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-$TRANSLATIONS = array(
-"Success" => "Успех",
-"Error" => "Ошибка"
-);
-$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 36c8e648b1a..e5d9b4d5b40 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -29,6 +29,9 @@ class Connection {
private $configID;
private $configured = false;
+ //whether connection should be kept on __destruct
+ private $dontDestruct = false;
+
//cache handler
protected $cache;
@@ -77,17 +80,31 @@ class Connection {
public function __construct($configPrefix = '', $configID = 'user_ldap') {
$this->configPrefix = $configPrefix;
$this->configID = $configID;
- $this->cache = \OC_Cache::getGlobalCache();
+ $memcache = new \OC\Memcache\Factory();
+ if($memcache->isAvailable()) {
+ $this->cache = $memcache->create();
+ } else {
+ $this->cache = \OC_Cache::getGlobalCache();
+ }
$this->config['hasPagedResultSupport'] = (function_exists('ldap_control_paged_result')
&& function_exists('ldap_control_paged_result_response'));
}
public function __destruct() {
- if(is_resource($this->ldapConnectionRes)) {
+ if(!$this->dontDestruct && is_resource($this->ldapConnectionRes)) {
@ldap_unbind($this->ldapConnectionRes);
};
}
+ /**
+ * @brief defines behaviour when the instance is cloned
+ */
+ public function __clone() {
+ //a cloned instance inherits the connection resource. It may use it,
+ //but it may not disconnect it
+ $this->dontDestruct = true;
+ }
+
public function __get($name) {
if(!$this->configured) {
$this->readConfiguration();
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php
index f65f466789f..4c9dd07a12c 100644
--- a/apps/user_ldap/lib/helper.php
+++ b/apps/user_ldap/lib/helper.php
@@ -71,6 +71,34 @@ class Helper {
}
/**
+ *
+ * @brief determines the host for every configured connection
+ * @return an array with configprefix as keys
+ *
+ */
+ static public function getServerConfigurationHosts() {
+ $referenceConfigkey = 'ldap_host';
+
+ $query = '
+ SELECT DISTINCT `configkey`, `configvalue`
+ FROM `*PREFIX*appconfig`
+ WHERE `appid` = \'user_ldap\'
+ AND `configkey` LIKE ?
+ ';
+ $query = \OCP\DB::prepare($query);
+ $configHosts = $query->execute(array('%'.$referenceConfigkey))->fetchAll();
+ $result = array();
+
+ foreach($configHosts as $configHost) {
+ $len = strlen($configHost['configkey']) - strlen($referenceConfigkey);
+ $prefix = substr($configHost['configkey'], 0, $len);
+ $result[$prefix] = $configHost['configvalue'];
+ }
+
+ return $result;
+ }
+
+ /**
* @brief deletes a given saved LDAP/AD server configuration.
* @param string the configuration prefix of the config to delete
* @return bool true on success, false otherwise
diff --git a/apps/user_ldap/lib/proxy.php b/apps/user_ldap/lib/proxy.php
index c80e2163475..ae3e3be7361 100644
--- a/apps/user_ldap/lib/proxy.php
+++ b/apps/user_ldap/lib/proxy.php
@@ -101,4 +101,4 @@ abstract class Proxy {
public function clearCache() {
$this->cache->clear($this->getCacheKey(null));
}
-} \ No newline at end of file
+}
diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php
index 22e2dac6d26..7169192a18e 100644
--- a/apps/user_ldap/settings.php
+++ b/apps/user_ldap/settings.php
@@ -44,7 +44,9 @@ OCP\Util::addstyle('user_ldap', 'settings');
$tmpl = new OCP\Template('user_ldap', 'settings');
$prefixes = \OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes();
+$hosts = \OCA\user_ldap\lib\Helper::getServerConfigurationHosts();
$tmpl->assign('serverConfigurationPrefixes', $prefixes);
+$tmpl->assign('serverConfigurationHosts', $hosts);
// assign default values
if(!isset($ldap)) {
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 95aa592594b..e214d57fb1d 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -24,7 +24,7 @@
$sel = ' selected';
foreach($_['serverConfigurationPrefixes'] as $prefix) {
?>
- <option value="<?php p($prefix); ?>"<?php p($sel); ?>><?php p($i++); ?>. Server</option>
+ <option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($i++); ?>. Server: <?php p($_['serverConfigurationHosts'][$prefix]); ?></option>
<?php
}
}
@@ -51,18 +51,15 @@
<p><label for="ldap_login_filter"><?php p($l->t('User Login Filter'));?></label>
<input type="text" id="ldap_login_filter" name="ldap_login_filter"
data-default="<?php p($_['ldap_login_filter_default']); ?>"
- title="<?php p($l->t('Defines the filter to apply, when login is attempted. %%uid replaces the username in the login action.'));?>" />
- <br /><small><?php p($l->t('use %%uid placeholder, e.g. "uid=%%uid"'));?></small></p>
+ title="<?php p($l->t('Defines the filter to apply, when login is attempted. %%uid replaces the username in the login action. Example: "uid=%%uid"'));?>" /></p>
<p><label for="ldap_userlist_filter"><?php p($l->t('User List Filter'));?></label>
<input type="text" id="ldap_userlist_filter" name="ldap_userlist_filter"
data-default="<?php p($_['ldap_userlist_filter_default']); ?>"
- title="<?php p($l->t('Defines the filter to apply, when retrieving users.'));?>" />
- <br /><small><?php p($l->t('without any placeholder, e.g. "objectClass=person".'));?></small></p>
+ title="<?php p($l->t('Defines the filter to apply, when retrieving users (no placeholders). Example: "objectClass=person"'));?>" /></p>
<p><label for="ldap_group_filter"><?php p($l->t('Group Filter'));?></label>
<input type="text" id="ldap_group_filter" name="ldap_group_filter"
data-default="<?php p($_['ldap_group_filter_default']); ?>"
- title="<?php p($l->t('Defines the filter to apply, when retrieving groups.'));?>" />
- <br /><small><?php p($l->t('without any placeholder, e.g. "objectClass=posixGroup".'));?></small></p>
+ title="<?php p($l->t('Defines the filter to apply, when retrieving groups (no placeholders). Example: "objectClass=posixGroup"'));?>" /></p>
</fieldset>
<fieldset id="ldapSettings-2">
<div id="ldapAdvancedAccordion">
@@ -75,7 +72,7 @@
<p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server'));?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.'));?>" /></p>
<p><label for="ldap_tls"><?php p($l->t('Use TLS'));?></label><input type="checkbox" id="ldap_tls" name="ldap_tls" value="1" data-default="<?php p($_['ldap_tls_default']); ?>" title="<?php p($l->t('Do not use it additionally for LDAPS connections, it will fail.'));?>" /></p>
<p><label for="ldap_nocase"><?php p($l->t('Case insensitve LDAP server (Windows)'));?></label><input type="checkbox" id="ldap_nocase" name="ldap_nocase" data-default="<?php p($_['ldap_nocase_default']); ?>" value="1"<?php if (isset($_['ldap_nocase']) && ($_['ldap_nocase'])) p(' checked'); ?>></p>
- <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', $theme->getName() ));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/><small><?php p($l->t('Not recommended, use for testing only.'));?></small></p>
+ <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', $theme->getName() ));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p>
<p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live'));?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.'));?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p>
</div>
<h3><?php p($l->t('Directory Settings'));?></h3>
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 41e2926605e..850ca0df995 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -77,11 +77,6 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
}
$dn = $ldap_users[0];
- //are the credentials OK?
- if(!$this->areCredentialsValid($dn, $password)) {
- return false;
- }
-
//do we have a username for him/her?
$ocname = $this->dn2username($dn);
@@ -90,6 +85,11 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
$this->updateQuota($dn);
$this->updateEmail($dn);
+ //are the credentials OK?
+ if(!$this->areCredentialsValid($dn, $password)) {
+ return false;
+ }
+
//give back the display name
return $ocname;
}
diff --git a/apps/user_ldap/user_proxy.php b/apps/user_ldap/user_proxy.php
index 73cc0963182..0722d8871a4 100644
--- a/apps/user_ldap/user_proxy.php
+++ b/apps/user_ldap/user_proxy.php
@@ -198,4 +198,4 @@ class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
return $this->refBackend->hasUserListings();
}
-} \ No newline at end of file
+}