]> source.dussan.org Git - nextcloud-server.git/commitdiff
Total rewite of fix.
authorInsanemal <insanemal@gmail.com>
Tue, 22 Nov 2011 01:08:27 +0000 (11:08 +1000)
committerRobin Appelman <icewind1991@gmail.com>
Thu, 24 Nov 2011 01:57:53 +0000 (02:57 +0100)
This now re-looks up the username and returns that for use.

Signed-off-by: Insanemal <insanemal@gmail.com>
apps/user_ldap/settings.php
apps/user_ldap/templates/settings.php
apps/user_ldap/user_ldap.php

index 4be36b0444098c87728348d11362d744eb468bd1..1f2d8ed9af312e9261456c4d788aa50402d7e876 100644 (file)
  */
 $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);
+               }
+               
        }
 }
 
index 587e94e013a92e0260650e78d34a5873930f391c..2abb0b4729161efa497b8bc6c46b5eabb771d75c 100644 (file)
@@ -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>
index d35cefcaae18afc1b14862b3ce9057d59aa15df8..106240e74b84b0378ba44231b01582479f64fb9d 100644 (file)
@@ -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