FOG Login with spaces in username
-
@Tom-Elliott I agree that it’s not a bug (everything is working as designed).
I don’t have a lot of experience with AD; I was unsure what is and isn’t allowed. It seems that spaces in AD names are bad practice and cause more problems than they’re worth. (though it doesn’t seem impossible, just breaks half your stuff)
-
@Quazz The usernames, themselves, cannot have spaces. But from the overview of this, he’s using a field of the AD/LDAP that doesn’t care about spaces. For example, displayName over sAMAccountName
-
@Tom-Elliott Thank you for providing a solution for this. I will test it tomorrow. I think if i found the right file before, i could have fixed it myself :). Thanks to all for the great support. I will reply tomorrow containing the results.
-
I’m sorry I haven’t answered for so long, but I’ve been busy a lot and haven’t been able to address this issue until now.
First i only got the login of the FOG local users to work with the solution provided by @Tom-Elliott.
I could login with usernames the contain spaces with the following changes:user.class.php:
Line 214:
Change the relevant regex from:(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[._-]?[\w0-9]+$
to:
(?=^.{3,40}$)^[\w][\w0-9]*[ ._-]?[\w0-9]*[ ._-]?[\w0-9]+$
fog.user.js
Comment out://regex: /^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/
When i tried to login with a domain user that contains spaces (users without spaces worked already) i got the same problem, no error but no login.
Then i figured out that the LDAP plugin uses the same check and regex so i had to edit this too:
ldap.class.php
Comment out:/** * Test the username for funky characters and return * immediately if found. */ // $test = preg_match( // '/(?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[.]?[\w0-9]+$/i', // $user // ); // if (!$test) { // return false; // }
Now it works like a charm.
Thanks to all people that were involved in this.
This can be marked as solved.