Assign / Re-Assign existing client to a reseller

Discussion in 'General' started by ColdFire, Jun 28, 2012.

  1. ColdFire

    ColdFire New Member

    Hello everybody,

    I'm missing something would allow me to assign an existing customer with all of his "assets" (domains, email and website stuff) to a reseller

    How may I achieve that ?

    If not in the GUI can I handle that manually in the database?
     
  2. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    You can do that in the database only.

    1) Edit the record of the client in the client table and set the field "parent_client_id" to the client_id of the reseller.

    2) Then edit the the login user of the reseller in the "sys_user" table and add the groupid of the client (see sys_group for the id, you can look it up by using the client_id column) in the "groups" field, separated by ",".
     
  3. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    maybe open a feature request on the bugtracker.
    It seems like a feature that could come in handy for other users (me included) in the future.
     
  4. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

  5. pfaf

    pfaf New Member HowtoForge Supporter

    Move client to another reseller: Not working exaclty as it should.

    OK, it seems to work, but we cannot see the moved client under clients when we login with the new reseller. We can see the web site records under web sites. We can still see the clients that the new reseller has created.

    Moreover, the reseller cannot delete the database that was created from the old reseller for the client. The old reseller is the admin user of ISPConfig, the one that was created during setup.

    Any ideas?

    Thank you in advance for your support.

    Kind regards,

    Panos.

     
  6. pfaf

    pfaf New Member HowtoForge Supporter

    Using the main administrator we have created a client under clients and a website which belongs to the client.

    Later we created a reseller and want to assign the client and website under the reseller.

    We followed
    http://www.howtoforge.com/forums/showthread.php?t=55628
    and assigned the website to the reseller. Then we should login with the reseller id and assign the website to the client.

    We have followed the manual way of assigning a client created under the installation (main) user to a reseller we created later according to http://www.howtoforge.com/forums/showthread.php?t=57770.

    When we login with the reseller id and we go to CLIENTS then we cannot see the client under clients. We can see the client when we edit the site but when we assign the the final client, the reseller has no more access the the website data.

    Do we miss anything?
     
  7. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    The permission system in ispconfig is similar to the used in Linux for file permissions and consists of users and groups. Each client and reseller has a group in the sys_group table. To make a record visible to a reseller or client, the record must either have the userid of the client or reseller in the sys_user_id column or the groupid of the client or reseller in the sys_group_id column.

    Please check that the group_id of the sys_group of the reseller is used in the sys_group_id column of the client that is not visible when you login as reseller.
     
  8. pfaf

    pfaf New Member HowtoForge Supporter

    Move a client under a different reseller

    So, to summarize the steps in order for a Client to be moved under another Reseller :

    1.Locate the following values for the Reseller under which you want to assign the client to.
    R_userid: Search by 'username' in the 'sys_user' table and get column 'userid'
    R_groupid: Search by 'name' in the 'sys_group' table and get column 'groupid'
    R_client_id: Search by 'name' in the 'sys_group' table and get column 'client_id'

    2. Locate the following values for the Client under which you want to assign the client to.
    C_userid: Search by 'username' in the 'sys_user' table and get column 'userid'
    C_groupid: Search by 'name' in the 'sys_group' table and get column 'groupid'
    C_client_id: Search by 'name' in the 'sys_group' table and get column 'client_id'

    3. Table 'client'
    Locate the record of the client using C_client_id in column 'client_id' and modify the field 'parent_id' = R_client_id.
    Also change column 'sys_userid' to R_userid and column 'sys_groupid' to R_groupid. This is done so that the reseller sees the clients under the clients page.

    4. Table 'sys_user'
    Locate the reseller record by using column 'username' or R_userid in column 'userid'. Modify the column 'groups' so that it contains also the C_group_id. This is done in order for the reseller to see the client websites.

    I hope that the above will be of some help to others.

    Kind regards to all,

    Panos.
     
  9. jvargas

    jvargas New Member

    Thanks pfaf, I do confirm your hint works as expected.
     
  10. Cheecoh

    Cheecoh New Member

    Thank you very much for this! That helped me to move the user flawlessly!
    I've created some mysql-queries to fetch and update the data.. Simply replace the values you've mentioned already!

    Fetch relevant R_(userid|groupid|client_id) and C_(userid|groupid|client_id)
    Code:
    SELECT Rsu.userid AS R_userid, Rsg.groupid AS R_groupid, Rsg.client_id AS R_client_id, Csu.userid AS C_userid, Csg.groupid AS C_groupid, Csg.client_id AS C_client_id
    FROM sys_user AS Rsu
    	JOIN sys_group AS Rsg ON Rsu.default_group = Rsg.groupid
    	JOIN sys_user AS Csu ON Csu.username = "[COLOR="Green"]CLIENT_USERNAME[/COLOR]"
    	JOIN sys_group AS Csg ON Csu.default_group = Csg.groupid
    WHERE Rsu.username = "[COLOR="Blue"]RESELLER_USERNAME[/COLOR]";
    UPDATE client and add reseller! (to see client in the reseller view)
    Code:
    UPDATE `client`
    SET `parent_id` = "[COLOR="Blue"]R_client_id[/COLOR]",
    	`sys_userid` = "[COLOR="Blue"]R_userid[/COLOR]",
    	`sys_groupid` = "[COLOR="Blue"]R_groupid[/COLOR]"
    WHERE client_id = "[COLOR="Green"]C_client_id[/COLOR]";
    UPDATE reseller to see client's websites (It was necessary to "re-auth/login" with the reseller account to see the clients websites)
    Code:
    UPDATE `sys_user`
    	SET `groups` = CONCAT(`groups`,',','[COLOR="Green"]C_groupid[/COLOR]')
    WHERE `userid` = "[COLOR="Blue"]R_userid[/COLOR]";
    Best Regards,

    Chris
     
    Last edited: Oct 28, 2013
  11. thoatswold

    thoatswold New Member

    Many thanks for the MySQL queries, Chris! They have saved me a great deal of time. Just one comment: in ISPConfig 3.0.5.3 the 'parent_id' field has become 'parent_child_id'. With that change, the three queries worked perfectly.

    I don't understand why this obviously useful function hasn't been added to the control panel when it was first requested ages ago.

    Thanks again,
    Phil
     
  12. non7top

    non7top New Member

  13. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    You can do this right in the ispconfig interface since ispconfig 3.0.5.4.Just go to the client and select the reseller were the client belongs to. There are no external scripts or changes in the database required.
     
  14. non7top

    non7top New Member

    Oh, I somehow missed it on the second tab. Very nice feature, thanks for adding!
     

Share This Page