Change FTP username pattern

Discussion in 'Installation/Configuration' started by MrWolf, Aug 15, 2013.

  1. MrWolf

    MrWolf New Member


    prensently, when I create a ftp account, the username seems to be like this:

    is it possible to change the pattern and replace the client username prefix with a domain suffix to have something like this :



    Thank you
  2. MrWolf

    MrWolf New Member

    I found a way to do it, not really like I would like to have it but at least it works.

    what I wanted was having a suffix field in the main config
    and enter a simple username in the ftp account. then a "@" and the suffix would be added to the username to create a email like username
    or just concat the username, @ and domain name

    what I did:
    blank the ftp user prefix in the main config.
    change the varchar(64) to varchar(256) of the field username in the ftp_user table of the database.
    then replace the line 94 of the file interface/web/sites/form/ftp_user.tform.php
    'regex' => '/^[\w\.\-]{0,64}$/',
    for this line:
    'regex' => '/^[\w\.\-]{1,64}@[\w\.\-]+\.[a-zA-Z]{2,6}$/',
    then I could add a email like username in the username field of the ftp account

    there is some typo in the error message of the ftp...
    it's "character" not "charachter"
  3. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Don't know if it is what you wanted to get, but with your regex the username MUST contain an @ and a dot, i.e. an email-like name.
    So you can not enter simple usernames anymore.
  4. MrWolf

    MrWolf New Member

    Hi Croydon,

    for my own use, yes, I needed it that way. that's why I wanted something to concat the "@" and the domain name automatically

    I want to refuse all non email like username
  5. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Ok. You might put some additional code into the ftp_user_edit file in onSubmit.
    There is something like
            // Set a few fixed values
    $this->dataRecord["server_id"] = $parent_domain["server_id"];
    In latest Stable SVN this is line 104/105.

    You could just add this one after that:
    $this->dataRecord['username'] .= '@' . $parent_domain['domain'];

    Of course your changes to the form file have to remain for this to work.
    You would only have to enter a username then and you could not use foreign domain names.
    Last edited: Aug 17, 2013

Share This Page