]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added option to lowercase all usernames.
authorInsanemal <insanemal@gmail.com>
Mon, 21 Nov 2011 02:51:13 +0000 (12:51 +1000)
committerRobin Appelman <icewind1991@gmail.com>
Thu, 24 Nov 2011 01:57:53 +0000 (02:57 +0100)
This resolves bug with Windows AD servers as LDAP server.
Windows is case insensitve on logon requests.
If users are stored camel case and logon using all lower it causes issues
as OwnCloud is configured to be case sensitive.

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 e61d82bf8beacd64cd1d72e904283e5ed9968402..4be36b0444098c87728348d11362d744eb468bd1 100644 (file)
@@ -20,7 +20,7 @@
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter', 'ldap_display_name', 'ldap_tls');
+$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])){
@@ -28,6 +28,9 @@ foreach($params as $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 5f25570e229d6dc87b499b542234a5a0376598af..587e94e013a92e0260650e78d34a5873930f391c 100644 (file)
@@ -11,6 +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>
                <input type="submit" value="Save" />
        </fieldset>
 </form>
index 249def7a1c8c90c99de5172154f19bbb6582cf3d..0b309fd99d57d10edd467f72dab52d66ffc8530e 100644 (file)
@@ -34,6 +34,7 @@ class OC_USER_LDAP extends OC_User_Backend {
        protected $ldap_base;
        protected $ldap_filter;
        protected $ldap_tls;
+       protected $ldap_nocase;
        protected $ldap_display_name;
 
        function __construct() {
@@ -44,6 +45,7 @@ class OC_USER_LDAP extends OC_User_Backend {
                $this->ldap_base = OC_Appconfig::getValue('user_ldap', 'ldap_base','');
                $this->ldap_filter = OC_Appconfig::getValue('user_ldap', 'ldap_filter','');
                $this->ldap_tls = OC_Appconfig::getValue('user_ldap', 'ldap_tls', 0);
+               $this->ldap_nocase = OC_Appconfig::getValue('user_ldap', 'ldap_nocase', 0);
                $this->ldap_display_name = OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME);
 
                if( !empty($this->ldap_host)
@@ -146,7 +148,13 @@ 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])) {
-                                       $users[] = $row[$ldap_display_name][0];
+                                       if($this->ldap_nocase) {
+                                               $users[] = strtolower($row[$ldap_display_name][0]);
+                                       }
+                                       else 
+                                       {
+                                               $users[] = $row[$ldap_display_name][0];
+                                       }
                                }
                        }
                        // TODO language specific sorting of user names