This now re-looks up the username and returns that for use.
Signed-off-by: Insanemal <insanemal@gmail.com>
*/
$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);
+ }
+
}
}
<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>
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;
// 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