Change a client username

Discussion in 'General' started by gbe, May 10, 2019.

  1. gbe

    gbe New Member HowtoForge Supporter

    Hi,

    I have a client with several sites set up. Each has FTP, database, db user, etc.
    All accounts start with the client username as a prefix, eg: myclient_dbuser, myclient_ftpuser, etc.
    Now the client is re-branding and needs their username to be different, eg: newname.
    They want their accounts to use the new username, eg: newname_dbuser, newname_ftpuser, etc.

    What is the process for doing this with existing sites?

    Note: I have had a look at this post but it's for changing the prefix from username to client id, so it doesn't really help.

    Many thanks
    Geoff.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The best way would probably to change the client username in client settings and then add new database user and database etc. and then move the data over to the new database. You will have to change all names within their website cms anyway.
     
  3. gbe

    gbe New Member HowtoForge Supporter

    Thanks Till. This will be a lot of work, do you think it might be possible to script this?
    The sites are all WordPress and I can take care of that side easily enough (config file is just text) but I'm not sure how I'd go about it on the ISPConfig side of things...
    Assuming I can get it right, perhaps it can help others who need this?
    Thanks
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Scripting might be possible, but I never tried that so you will have to test it if it really works. Usernames and database names that have a prefix are protected from changing the client username in that way that the prefix is stored in a separate field of the record, take a look e.g. at the ftp user, ssh user or database user and database table in the ispconfig database, you will see that they contain a field for the full username and one field for the prefix only. To get a new prefix, you will have to change both fields, the change must be done by using the ispconfig remote api. As I said above, I've never tried this so it might be that it does not work as I can't say for sure if the remote api will accept that you change the prefix field as well.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    What will work in any case is to script it in the way with the remote api:

    1) Change username in client.
    2) Create new users and database.
    3) Move database to new database with mysqldump + mysql command by script.
    4) drop old users.

    the remote api supports soap and also a REST-like approach. The documentation has just examples for SOAP, but there should be some examples posted by me in the dev forum for the REST style, the names of the functions etc. are the same, REST is just a wrapper for SOAP.
     
  6. gbe

    gbe New Member HowtoForge Supporter

    Till, thanks very much for this.
    I've decided to do this one manually and note the steps. Then if I have more of these to do in future I will use those steps as the basis for a scripted process.
     

Share This Page