Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Last active April 25, 2016 15:27
Show Gist options
  • Save Dalmirog-zz/3e69083f573ee5f8683aff61704aeecc to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/3e69083f573ee5f8683aff61704aeecc to your computer and use it in GitHub Desktop.
/*
Glossary:
- "Octopus user": A user created by the Octopus server. This user can be created when the Octopus server is in either "User/Password" or "Active Directory" authentication method. These users can be found in the table "Users"
- "AD User": An active directory user. This is the one sitting on the AD domain database
- "UserPass User": An Octopus user created when a user logs in while the Octopus Server is in User/Password authentication method.
When an "AD User" or a "UserPass User" log into the web portal for the first time, Octopus creates an "Octopus User" for them on the database. This user will have its own ID, which will grant him access to the teams. You can see this on the "Team" table on the column "MemberuserIds"
The goal of this script is to help users map an "Octopus user" to another "Octopus user". Both could have been created based on an "AD user" or as a "UserPass User"
*/
--Update the "New" user's Username & Identification Token to avoid duplicates.
UPDATE [dbo].[User]
SET [Username] = 'Username_modified'
,[IdentificationToken] = 'IdentificationToken_modified'
--No need to modify the JSON
WHERE id = 'Users-541' --ID of the new user
GO
--Update "Old" user with "New" user's Username, Identification Token and JSON
UPDATE [dbo].[User]
SET [Username] = '' --New User's Username
,[IdentificationToken] = '' --New User's IdentificationToken
,[JSON] = '' -- New User's JSON
WHERE id = '' -- Old user's ID
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment