Domain with numbers unable to create users

Discussion in 'Tips/Tricks/Mods' started by ppettigrew, Aug 3, 2006.

  1. ppettigrew

    ppettigrew New Member

    Hi,

    Sorry to be coming back to the forum with an issue - we are such grateful users of this wonderful application.

    We are unable to create a user in ISPConfig, for a domain that starts in a number. Ie:

    domain name = 12thman.com.au
    User prefix = [DOMAIN]_
    desired user email = [email protected]
    This should result in a username = 12thman.com.au_info

    However, when trying to add the user we are getting the following ISPConfig error.....
    Field: Username
    The user name has to contain a minimum of 4 and a maximum of 32 letters or figures and has to begin with a letter.

    Is there any way we can achieve the use of a domain that starts with a digit, without making a global change to the User prefix setting?

    Many thanks for your ideas on how to resolve this issue.

    Cheers,

    Paul
     
  2. falko

    falko Super Moderator Howtoforge Staff

    I don't know if this works today, but a few years ago Linux didn't allow user names that started with a digit... That's why we have this restriction in ISPConfig.
    You can try to add a user that begins with a digit with the useradd command for testing purposes. Please make sure you give that user a user ID below 10000 (otherwise it will conflict with your ISPConfig users).
     
  3. ppettigrew

    ppettigrew New Member

    Hi Falko,

    Great to receive your reply, thank you.

    Yes, our FC4 server can happily create the user with the adduser command.

    Would it be possible for us to disable the numeric prefix check/constraint ISPConfig uses (as it is not necessary on this distro)? If so, which file do we need to change?

    With many thanks,

    Paul
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Have a look at /home/admispconfig/ispconfig/lib/plugins/isp_username.plugin.php.
     
  5. ppettigrew

    ppettigrew New Member

    Thanks Falko - we are all fixed :)

    Please find below our MINI-HOWTO to help others that may search this forum looking for the solution.....
    -----------------------------------------------------
    HOWTO - Enabling numeric prefix on usernames in ISPConfig (as at Version 2.2.5)
    -----------------------------------------------------
    Target settings:
    domain name = 13thbloke.com.au
    User prefix = [DOMAIN]_
    desired user email = [email protected]
    This should result in a username = 13thbloke.com.au_info

    Issue:
    When trying to add the user will get the following ISPConfig error.....
    Field: Username
    The user name has to contain a minimum of 4 and a maximum of 32 letters
    or figures and has to begin with a letter.

    Workaround:
    # cp /home/admispconfig/ispconfig/lib/plugins/isp_username.plugin.php /home/admispconfig/ispconfig/lib/plugins/isp_username.plugin.php-ORIGINAL
    # vi /home/admispconfig/ispconfig/lib/plugins/isp_username.plugin.php

    Find the following line:
    if(!preg_match("/^[a-z][\w\.\-\_]{3,64}$/",$user_prefix . $username)) {
    $go_api->db->query("DELETE from isp_isp_user where doc_id = '$doc_id'");

    And change it to:
    if(!preg_match("/^[a-zA-Z0-9][\w\.\-\_]{3,64}$/",$user_prefix . $username)) {
    $go_api->db->query("DELETE from isp_isp_user where doc_id = '$doc_id'");

    Done :)

    PS: You will probably need to make this change each time ISPConfig is upgraded, until
    the functionality is included into the base package (assumes UNIX system of choice will
    allow numeric prefix as Fedora does).
     
  6. datayoung

    datayoung New Member

    May be more than just Number or not?

    Thanks ppettigrew,

    Can I add @ in your updated code like this for let user
    from 13thbloke.com.au_info to [email protected]

    by

    if(!preg_match("/^[a-z][\w\.\-\_\@]{3,64}$/",$user_prefix . $username)) {
    $go_api->db->query("DELETE from isp_isp_user where doc_id = '$doc_id'");


    Find the following line:
    if(!preg_match("/^[a-z][\w\.\-\_]{3,64}$/",$user_prefix . $username)) {
    $go_api->db->query("DELETE from isp_isp_user where doc_id = '$doc_id'");

    And change it to:
    if(!preg_match("/^[a-zA-Z0-9][\w\.\-\_]{3,64}$/",$user_prefix . $username)) {
    $go_api->db->query("DELETE from isp_isp_user where doc_id = '$doc_id'");

    I not test yet,anyone have comment for this
    I don't know reason of ispconfig:rolleyes: to unaccept @ in username format

    I test add user by hand into my Ubutu 6.061 Server ,it is no problem from username@xxxxx format
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    No, because linux system user accounts may not contain a @ sign.
     

Share This Page