1. Home
  2. Docs
  3. Migration
  4. Moving a company to a new reseller
  5. Update the Database

Update the Database

Now that you have moved the organizational unit in Active Directory, CloudPanel will no longer be able to manage this company for you. So we now need to go into SQL Server Management Studio and update the sql tables. To do this, please open SQL Server Management Studio, click on New Query, and make sure you select your CloudPanel database from the dropdown:

Step 1:

First thing we need to do is update the company to be under the new reseller. Change the  ResellerCode value to your NEW reseller and the CompanyCode value to your company in the script below before executing:

UPDATE cp_Companies SET ResellerCode='TEN' WHERE CompanyCode='COM'

Step 2:

Now that we have changed the reseller association for that company in the database, you should see it listed under the proper reseller in CloudPanel. However, there are still other objects we need to migrate. Next, we need to update the user’s distinguished name:

UPDATE cp_Users SET DistinguishedName=replace(distinguishedname, 'OU=LAB', 'OU=TEN') WHERE CompanyCode='COM'

Notice in the command above that OU=LAB contains the old reseller code “LAB” and we are replacing it with the new reseller code “TEN”.

Step 3:

UPDATE ad_SecurityGroups SET DistinguishedName=replace(distinguishedname, 'OU=LAB', 'OU=TEN') WHERE CompanyId=(SELECT ID FROM cp_Companies WHERE CompanyCode='COM')

Notice in the command above that OU=LAB contains the old reseller code “LAB” and we are replacing it with the new reseller code “TEN”.

Step 4:

Next is to update any Exchange mail contacts you may have:

UPDATE exch_Contacts SET DistinguishedName=replace(distinguishedname, 'OU=LAB', 'OU=TEN') WHERE CompanyCode='COM'

Notice in the command above that OU=LAB contains the old reseller code “LAB” and we are replacing it with the new reseller code “TEN”.

Step 5:

Next is to update any Exchange distribution groups you may have:

UPDATE exch_DistributionGroups SET DistinguishedName=replace(distinguishedname, 'OU=LAB', 'OU=TEN') WHERE CompanyCode='COM'

Notice in the command above that OU=LAB contains the old reseller code “LAB” and we are replacing it with the new reseller code “TEN”.

Step 6:

If you have any public folder mailboxes then those will have to be updated as well:

UPDATE exch_PublicFolderMailboxes SET DistinguishedName=replace(distinguishedname, 'OU=LAB', 'OU=TEN') WHERE CompanyID=(SELECT CompanyId FROM cp_Companies WHERE CompanyCode='COM')

Notice in the command above that OU=LAB contains the old reseller code “LAB” and we are replacing it with the new reseller code “TEN”.

Step 7:

Update any resource mailboxes that you may have:

UPDATE exch_ResourceMailboxes SET DistinguishedName=replace(distinguishedname, 'OU=LAB', 'OU=TEN') WHERE CompanyCode='COM'

Notice in the command above that OU=LAB contains the old reseller code “LAB” and we are replacing it with the new reseller code “TEN”.

Was this article helpful to you? Yes No

How can we help?