How to configure the URLs to allow users to have the same username.
Before you begin
To enable this feature, see Configuring reseller root domains.
Configuring Identity
- Locate the STS\Web.config file, usually located in C:\Program Files (x86)\Atomia\Identity\STS.
- Set
<add key="UniqueUserMultipleReseller" value="false" />
totrue.
- Locate the
<membership>
section in the configuration and add the following element to each extra reseller root domain.
<add name="reseller2.com" connectionStringName="UserManagementConectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="reseller2.com" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="10" minRequiredPasswordLength="3" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- Locate the
<roleManager>
section in the configuration and add the following element. - Locate the UserAPI\web.config file, usually located in C:\Program Files (x86)\Atomia\Identity\UserAPI.
- Repeat the above steps for the STS configuration.
<add connectionStringName="UserManagementConectionString" applicationName="reseller2.com" name="reseller2.com" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Configuring account API and Billing API
- Locate the AccountAPI\Web.config file usually located in C:\Program Files (x86)\Atomia\BillingAPIs\AccountApi.
- Locate the BillingApi\Web.config file usually located in C:\Program Files (x86)\Atomia\BillingAPIs\BillingApi.
- Set
<add key="UniqueUserMultipleReseller" value="false" />
totrue.
- Add a new key for each extra reseller root domain. Don’t add the key for the domain that you have been using for your main installation.
<add key="reseller2.com" value="true" />
Configuring the Automation Server
- Locate the web.config in C:\Program Files (x86)\Atomia\AutomationServer\Web.
- Set
<add key="UniqueUserMultipleReseller" value="false" />
totrue.
Configuring the Billing Customer Panel and Hosting Control Panel
- Locate the appConfig.config file in C:\Program Files (x86)\Atomia\BillingCustomerPanel\App_Data.
- Set
<add key="UniqueUserMultipleReseller" value="false" />
totrue.
- Locate the appConfig.config file in C:\Program Files (x86)\Atomia\HostingControlPanel\App_Data.
- Set
<add key="UniqueUserMultipleReseller" value="false" />
totrue.
Database changes
- Start SQL Server Management Studio and execute the following query.
insert into AtomiaUserManagement.dbo.aspnet_Applications (ApplicationName, LoweredApplicationName, ApplicationId) values ('reseller2.com', 'reseller2.com', NEWID())
- To migrate existing users, modify the following SQL script to fit your needs.
-- Variables DECLARE @current_application_id UNIQUEIDENTIFIER DECLARE @new_application_id UNIQUEIDENTIFIER DECLARE @user_id UNIQUEIDENTIFIER DECLARE @current_reseller_root_domain NVARCHAR(255) DECLARE @new_reseller_root_domain NVARCHAR(255) DECLARE @name NVARCHAR(255) DECLARE @username NVARCHAR(255) DECLARE @accounts TABLE(name NVARCHAR(255)) DECLARE @usernames TABLE (username NVARCHAR(255)) -- The reseller root domain that the users have right now, before migration. If you are migrating from the default reseller/root domain this should be NULL SET @current_reseller_root_domain = NULL -- The reseller root domain that the users should have after migration SET @new_reseller_root_domain = 'reseller2.com' -- List of accounts that should be migrated INSERT INTO @accounts VALUES('100130') INSERT INTO @accounts VALUES('100131') -- -- Nothing below this line should have to be changed -- -- Let's create new application if it doesn't exist IF @new_reseller_root_domain IS NOT NULL AND NOT EXISTS (SELECT 1 FROM AtomiaUserManagement.dbo.aspnet_Applications WHERE ApplicationName = @new_reseller_root_domain) BEGIN INSERT INTO AtomiaUserManagement.dbo.aspnet_Applications (ApplicationId, ApplicationName, Description, LoweredApplicationName) VALUES(NEWID(), @new_reseller_root_domain, @new_reseller_root_domain, @new_reseller_root_domain) END -- Get current application id IF @current_reseller_root_domain IS NULL BEGIN SELECT @current_application_id = ApplicationId FROM AtomiaUserManagement.dbo.aspnet_Applications WHERE ApplicationName = 'AtomiaIdentityStS' END ELSE BEGIN SELECT @current_application_id = ApplicationId FROM AtomiaUserManagement.dbo.aspnet_Applications WHERE ApplicationName = @current_reseller_root_domain END -- Get new application id IF @new_reseller_root_domain IS NULL BEGIN SELECT @new_application_id = ApplicationId FROM AtomiaUserManagement.dbo.aspnet_Applications WHERE ApplicationName = 'AtomiaIdentityStS' END ELSE BEGIN SELECT @new_application_id = ApplicationId FROM AtomiaUserManagement.dbo.aspnet_Applications WHERE ApplicationName = @new_reseller_root_domain END -- Make sure the application has all the needed roles IF NOT EXISTS (SELECT 1 FROM AtomiaUserManagement.dbo.aspnet_Roles WHERE ApplicationId = @new_application_id AND RoleName = 'AccountOwner') BEGIN INSERT INTO AtomiaUserManagement.dbo.aspnet_Roles (ApplicationId, RoleId, RoleName, LoweredRoleName) VALUES (@new_application_id, NEWID(), 'AccountOwner', 'accountowner') END IF NOT EXISTS (SELECT 1 FROM AtomiaUserManagement.dbo.aspnet_Roles WHERE ApplicationId = @new_application_id AND RoleName = 'AccountUser') BEGIN INSERT INTO AtomiaUserManagement.dbo.aspnet_Roles (ApplicationId, RoleId, RoleName, LoweredRoleName) VALUES (@new_application_id, NEWID(), 'AccountUser', 'accountuser') END IF NOT EXISTS (SELECT 1 FROM AtomiaUserManagement.dbo.aspnet_Roles WHERE ApplicationId = @new_application_id AND RoleName = 'Administrators') BEGIN INSERT INTO AtomiaUserManagement.dbo.aspnet_Roles (ApplicationId, RoleId, RoleName, LoweredRoleName) VALUES (@new_application_id, NEWID(), 'Administrators', 'administrators') END IF NOT EXISTS (SELECT 1 FROM AtomiaUserManagement.dbo.aspnet_Roles WHERE ApplicationId = @new_application_id AND RoleName = 'Reseller') BEGIN INSERT INTO AtomiaUserManagement.dbo.aspnet_Roles (ApplicationId, RoleId, RoleName, LoweredRoleName) VALUES (@new_application_id, NEWID(), 'Reseller', 'reseller') END -- Get all usernames for the accounts DECLARE cur CURSOR FOR SELECT name FROM @accounts OPEN cur FETCH NEXT FROM cur INTO @name WHILE (@@FETCH_STATUS = 0) BEGIN -- Store users for the account name in the usernames table INSERT INTO @usernames SELECT l.username FROM AtomiaAccount.dbo.account a INNER JOIN AtomiaAccount.dbo.login l ON l.fk_account_id = a.id WHERE a.name = @name FETCH NEXT FROM cur INTO @name END CLOSE cur DEALLOCATE cur -- Iterate over the usernames DECLARE cur CURSOR FOR SELECT username FROM @usernames OPEN cur FETCH NEXT FROM cur INTO @username WHILE (@@FETCH_STATUS = 0) BEGIN -- Set reseller root domain in the login table print 'Set reseller root domain in the login table' IF @current_reseller_root_domain IS NULL BEGIN UPDATE AtomiaAccount.dbo.login SET reseller_root_domain = @new_reseller_root_domain WHERE username = @username AND (reseller_root_domain IS NULL OR reseller_root_domain = '') END ELSE BEGIN UPDATE AtomiaAccount.dbo.login SET reseller_root_domain = @new_reseller_root_domain WHERE username = @username AND reseller_root_domain = @current_reseller_root_domain END -- Set identity properties print 'Set identity properties' IF @current_reseller_root_domain IS NULL BEGIN UPDATE AtomiaIdentity.dbo.identity_properties SET value = @new_reseller_root_domain WHERE username = @username AND (reseller_root_domain IS NULL OR reseller_root_domain = '') AND property = 'resellerRootDomain' UPDATE AtomiaIdentity.dbo.identity_properties SET reseller_root_domain = @new_reseller_root_domain WHERE username = @username AND (reseller_root_domain IS NULL OR reseller_root_domain = '') END ELSE BEGIN UPDATE AtomiaIdentity.dbo.identity_properties SET value = @new_reseller_root_domain WHERE username = @username AND reseller_root_domain = @current_reseller_root_domain AND property = 'resellerRootDomain' UPDATE AtomiaIdentity.dbo.identity_properties SET reseller_root_domain = @new_reseller_root_domain WHERE username = @username AND reseller_root_domain = @current_reseller_root_domain END -- Get user id for the username print 'Get user id for the username' SELECT @user_id = UserId FROM AtomiaUserManagement.dbo.aspnet_Users WHERE UserName = @username AND ApplicationId = @current_application_id -- Change application id for the user print 'Change application id for the user' UPDATE AtomiaUserManagement.dbo.aspnet_Users SET ApplicationId = @new_application_id WHERE UserId = @user_id UPDATE AtomiaUserManagement.dbo.aspnet_Membership SET ApplicationId = @new_application_id WHERE UserId = @user_id -- Change roles for the user print 'Change roles for the user' UPDATE uir SET uir.RoleId = nr.RoleId FROM AtomiaUserManagement.dbo.aspnet_UsersInRoles uir INNER JOIN AtomiaUserManagement.dbo.aspnet_Roles cr ON cr.RoleId = uir.RoleId INNER JOIN AtomiaUserManagement.dbo.aspnet_Roles nr ON nr.RoleName = cr.RoleName AND nr.ApplicationId = @new_application_id WHERE uir.UserId = @user_id FETCH NEXT FROM cur INTO @username END CLOSE cur DEALLOCATE cur