• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

FOG Login with spaces in username

Scheduled Pinned Locked Moved
General Problems
5
24
3.0k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    Sebastian Roth Moderator
    last edited by Oct 21, 2019, 3:12 PM

    @kek said in FOG Login with spaces in username:

    Yes i put the username in that field with a dot instead of a space but it is also not working.

    What do you mean by that?

    Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

    Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

    K 1 Reply Last reply Oct 22, 2019, 7:06 AM Reply Quote 0
    • W
      Wayne Workman
      last edited by Oct 22, 2019, 2:26 AM

      Set the username manually in the database? That’s what I’d think about doing for this very rare one-off. I can help you try that.

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
      Daily Clean Installation Results:
      https://fogtesting.fogproject.us/
      FOG Reporting:
      https://fog-external-reporting-results.fogproject.us/

      1 Reply Last reply Reply Quote 0
      • S
        Sebastian Roth Moderator
        last edited by Oct 22, 2019, 6:33 AM

        @Wayne-Workman Which database? If I get this right the OP want to use LDAP auth.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        1 Reply Last reply Reply Quote 0
        • K
          kek @Sebastian Roth
          last edited by Oct 22, 2019, 7:06 AM

          @Sebastian-Roth said in FOG Login with spaces in username:

          @kek said in FOG Login with spaces in username:

          Yes i put the username in that field with a dot instead of a space but it is also not working.

          What do you mean by that?

          I thought i could put the username separated with a dot in the Web Page field in the AD user properties page because only some persons need access to the FOG Server, but it is also is not working because the LDAP Plugin looks if this username exists in the AD but this name does only exists in the web page field in some users.

          1 Reply Last reply Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by Oct 22, 2019, 7:16 AM

            @kek said in FOG Login with spaces in username:

            but it is also is not working because the LDAP Plugin looks if this username exists in the AD but this name does only exists in the web page field in some users.

            Can you be more specific on how you know this? You seem to have a lot of detail knowledge about how this works but you don’t post any of the details. Please share more of the information here. Reading between the lines I guess you have looked through the FOG (LDAP plugin) code already. Please let us know where you see it’s doing the wrong thing.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            K 1 Reply Last reply Oct 22, 2019, 8:23 AM Reply Quote 0
            • K
              kek @Sebastian Roth
              last edited by kek Oct 22, 2019, 2:26 AM Oct 22, 2019, 8:23 AM

              @Sebastian-Roth said in FOG Login with spaces in username:

              @kek said in FOG Login with spaces in username:

              but it is also is not working because the LDAP Plugin looks if this username exists in the AD but this name does only exists in the web page field in some users.

              Can you be more specific on how you know this? You seem to have a lot of detail knowledge about how this works but you don’t post any of the details. Please share more of the information here.

              I made a lot of error_logs to see what the Plugin is searching for, but then i saw the Plugin is not the problem.
              I know that because the user got put in the Database after i tried to login a user, but it is not logging in.

              Reading between the lines I guess you have looked through the FOG (LDAP plugin) code already.

              Yes i looked in the LAP Plugin code to see what is the problem, but as already said the Plugin does it’s Job right.
              I error_log ged the search thats is executed when you try to Login.

              Please let us know where you see it’s doing the wrong thing.

              The problem lies by the FOG Login, and because i dont see in the Code why spaces aren’t allowed i made that post.

              I think this PHP Class is for the login: processlogin.class.php

              1 Reply Last reply Reply Quote 0
              • S
                Sebastian Roth Moderator
                last edited by Oct 22, 2019, 10:01 AM

                @kek said in FOG Login with spaces in username:

                I error_log ged the search thats is executed when you try to Login.

                Can you share this?

                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                1 Reply Last reply Reply Quote 0
                • Q
                  Quazz Moderator
                  last edited by Quazz Oct 22, 2019, 4:09 AM Oct 22, 2019, 10:07 AM

                  https://github.com/FOGProject/fogproject/blob/master/packages/web/lib/fog/user.class.php#L214

                  This function is where it validates the username.

                  It uses the same regex as the javascript that checks when you try and manually create an account.

                  @kek can you share some examples that failed so we could potentially modify it?

                  It doesn’t seem difficult, but we need to know if it’s valid for your case.

                  1 Reply Last reply Reply Quote 1
                  • W
                    Wayne Workman
                    last edited by Oct 23, 2019, 12:57 AM

                    Didn’t read enough - carry on.

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                    Daily Clean Installation Results:
                    https://fogtesting.fogproject.us/
                    FOG Reporting:
                    https://fog-external-reporting-results.fogproject.us/

                    1 Reply Last reply Reply Quote 0
                    • T
                      Tom Elliott
                      last edited by Oct 23, 2019, 12:46 PM

                      I just want to understand the use case for a requirement to have spaces in the Username?

                      The regex doesn’t allow for spaces, and creating usernames with spaces isn’t allowed as well.

                      How is this a bug if this is intended? Too my knowledge, you cannot create an active directory | ldap user name (userprincipalname) with spaces.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                      T 1 Reply Last reply Oct 23, 2019, 1:02 PM Reply Quote 0
                      • T
                        Tom Elliott @Tom Elliott
                        last edited by Oct 23, 2019, 1:02 PM

                        @Quazz @Sebastian-Roth @Wayne-Workman @kek

                        This isn’t a normal situation in my eyes. That’s not to say you can’t get spaces in your usernames.

                        Change the relevant regex from: (?=^.{3,40}$)^[\w][\w0-9]*[._-]?[\w0-9]*[._-]?[\w0-9]+$ to:
                        (?=^.{3,40}$)^[\w][\w0-9]*[ ._-]?[\w0-9]*[ ._-]?[\w0-9]+$

                        And you should be able to create and use usernames with spaces. But again, this isn’t very common, especially when paired with AD logins. The userPrincipalName will still be without spaces.

                        Probably a better method would be:
                        (?=^.{3,40}$)^(?!.*[_\s-\.]{2,})[a-zA-Z0-9][a-zA-Z0-9_\s\-\.]*[a-zA-Z0-9]$ as it allows multiple spaces

                        If you need the username to be longer or shorter than 40, 3 respectively just remove the first part of the line, or make the relevant numerical changes.

                        the (?=^.{3,40}$) means Must be at least 3 characters and cannot exceed 40 characters (this includes spaces, dots, dashes, and underscores.

                        Seeing as our schema for Usernames is set to 50 characters, you can’t have anything more than 50. So you could adjust the first part to simply be:
                        (?=^.{1,50}$).

                        It won’t show as invalid if you remove the line, but the database won’t be able to store the field.

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        Q 1 Reply Last reply Oct 23, 2019, 2:10 PM Reply Quote 4
                        • S
                          Sebastian Roth Moderator
                          last edited by Oct 23, 2019, 2:08 PM

                          @Tom-Elliott When reading the topic at first I though this ought to be a bug. But learning more about it I don’t see it as a bug anymore. Moved it back to problems. I think you instructions will help the OP to make this work for his situation. Thanks!

                          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                          1 Reply Last reply Reply Quote 0
                          • Q
                            Quazz Moderator @Tom Elliott
                            last edited by Quazz Oct 23, 2019, 8:11 AM Oct 23, 2019, 2:10 PM

                            @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)

                            T 1 Reply Last reply Oct 23, 2019, 3:50 PM Reply Quote 0
                            • T
                              Tom Elliott @Quazz
                              last edited by Oct 23, 2019, 3:50 PM

                              @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

                              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                              Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                              Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                              K 1 Reply Last reply Oct 24, 2019, 11:39 AM Reply Quote 1
                              • K
                                kek @Tom Elliott
                                last edited by Oct 24, 2019, 11:39 AM

                                @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.

                                1 Reply Last reply Reply Quote 0
                                • K
                                  kek
                                  last edited by Jan 27, 2020, 1:50 PM

                                  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.

                                  1 Reply Last reply Reply Quote 0
                                  • 1
                                  • 2
                                  • 1 / 2
                                  • First post
                                    Last post

                                  190

                                  Online

                                  12.0k

                                  Users

                                  17.3k

                                  Topics

                                  155.2k

                                  Posts
                                  Copyright © 2012-2024 FOG Project