Skip to content
Snippets Groups Projects
Commit c945989a authored by Insanemal's avatar Insanemal Committed by Robin Appelman
Browse files

Total rewite of fix.

This now re-looks up the username and returns that for use.

Signed-off-by: default avatarInsanemal <insanemal@gmail.com>
parent 8d092434
No related branches found
No related tags found
No related merge requests found
......@@ -22,16 +22,19 @@
*/
$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter', 'ldap_display_name', 'ldap_tls', 'ldap_nocase');
foreach($params as $param){
if(isset($_POST[$param])){
OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
}
elseif('ldap_tls' == $param) {
// unchecked checkboxes are not included in the post paramters
OC_Appconfig::setValue('user_ldap', $param, 0);
}
elseif('ldap_nocase' == $param) {
OC_Appconfig::setValue('user_ldap', $param, 0);
if ($_POST) {
foreach($params as $param){
if(isset($_POST[$param])){
OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
}
elseif('ldap_tls' == $param) {
// unchecked checkboxes are not included in the post paramters
OC_Appconfig::setValue('user_ldap', $param, 0);
}
elseif('ldap_nocase' == $param) {
OC_Appconfig::setValue('user_ldap', $param, 0);
}
}
}
......
......@@ -11,7 +11,7 @@
<p><label for="ldap_display_name"><?php echo $l->t('Display Name Field');?></label><input type="text" id="ldap_display_name" name="ldap_display_name" value="<?php echo $_['ldap_display_name']; ?>" />
<small><?php echo $l->t('Currently the display name field needs to be the same you matched %%uid against in the filter above, because ownCloud doesn\'t distinguish between user id and user name.');?></small></p>
<p><input type="checkbox" id="ldap_tls" name="ldap_tls" value="1"<?php if ($_['ldap_tls']) echo ' checked'; ?>><label for="ldap_tls"><?php echo $l->t('Use TLS');?></label></p>
<p><input type="checkbox" id="ldap_nocase" name="ldap_nocase" value="1"<?php if ($_['ldap_nocase']) echo ' checked'; ?>><label for="ldap_nocase"><?php echo $l->t('Conver UID lowercase');?></label></p>
<p><input type="checkbox" id="ldap_nocase" name="ldap_nocase" value="1"<?php if ($_['ldap_nocase']) echo ' checked'; ?>><label for="ldap_nocase"><?php echo $l->t('Case insensitve LDAP server (Windows)');?></label></p>
<input type="submit" value="Save" />
</fieldset>
</form>
......@@ -117,7 +117,21 @@ class OC_USER_LDAP extends OC_User_Backend {
return false;
if($this->ldap_nocase) {
return strtolower($uid);
$filter = str_replace('%uid', $uid, $this->ldap_filter);
$sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
$entries = ldap_get_entries( $this->getDs(), $sr );
if( $entries['count'] == 1 ) {
foreach($entries as $row) {
$ldap_display_name = strtolower($this->ldap_display_name);
if(isset($row[$ldap_display_name])) {
return $row[$ldap_display_name][0];
}
}
}
else {
return $uid;
}
}
else {
return $uid;
......@@ -155,13 +169,7 @@ class OC_USER_LDAP extends OC_User_Backend {
// TODO ldap_get_entries() seems to lower all keys => needs review
$ldap_display_name = strtolower($this->ldap_display_name);
if(isset($row[$ldap_display_name])) {
if($this->ldap_nocase) {
$users[] = strtolower($row[$ldap_display_name][0]);
}
else
{
$users[] = $row[$ldap_display_name][0];
}
$users[] = $row[$ldap_display_name][0];
}
}
// TODO language specific sorting of user names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment