Programmatically disable/enable users
Overview
After performing an upgrade, you may want to let a limited set of users into the system to perform some level of validation (smoke testing) without allowing access to all active users access. Currently, there is not a mode that allows for a select and limited amount of users to have access to the system. This topic provides the SQL to run against one of the operations databases to disable and enable active user accounts.
Programmatically disable/enable active user accounts
These are the steps to disable/enable all active users except coreuser
. The intent is to limit user access and perform smoke testing.
If additional accounts need to be used for smoke testing, that would require manually activating the accounts in RPI using coreuser
or additional scripting.
All of these steps are performed in the PULSE Operations Database:
Backup all active users but
coreuser
- we want to keepcoreuser
active.Disable all active users in the backup table (not
coreuser
).Enable all active users in the backup table (not
coreuser
).Drop the active user backup table.
SQL statements:
/* Disable/Enable Active Users
** This is intended to support smoke testing and prevent users from logging in
1. Backup all active users but coreuser - We want to keep coreuser active
2. Disable all active users in the backup table (not coreuser)
3. Enable all active users in the backup table (not coreuser)
4. Drop active user backup table
*/
-- Create backup of approved/active useers that are not coreuser
SELECT * INTO [Pulse].[dbo].[AspNetUsers_Upgrade_Backup]
FROM [Pulse].[dbo].[AspNetUsers]
WHERE
IsApproved = 1
and UserName != 'coreuser'
-- Disable useers that are not coreuser based on backup table
UPDATE [Pulse].[dbo].[AspNetUsers] SET IsApproved = 0
WHERE
UserName in (SELECT UserName from [Pulse].[dbo].[AspNetUsers_Upgrade_Backup])
-- Perform after testing is complete.
-- Enable useers that are not coreuser based on backup table
UPDATE [Pulse].[dbo].[AspNetUsers] SET IsApproved = 1
WHERE
UserName in (SELECT UserName from [Pulse].[dbo].[AspNetUsers_Upgrade_Backup])
--Cleanup Backup Table
Drop Table [Pulse].[dbo].[AspNetUsers_Upgrade_Backup]