Last active
August 22, 2019 15:29
-
-
Save kieran23101/cb523b3293999fd8e64651af211a76e4 to your computer and use it in GitHub Desktop.
A sql script that can be run and will remove a user from every dnn installation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Better Version | |
EXEC sp_MSforeachdb | |
--Declaring Variables | |
DECLARE @var2 VARCHAR(50) | |
SET @var2 = ''andrew@purplecs.com'' | |
DECLARE @var1 int | |
--Checking to see if Andrew exists | |
IF EXISTS (SELECT * FROM Users WHERE Email = @var2) | |
--If Andrew Exists, Run this | |
BEGIN | |
--Getting Andrews UserID by searching via email | |
SELECT @var1 = UserID FROM Users WHERE Email = @var2 | |
--After getting the UserID, use that to run the stored proceedure | |
--and remove the specified user account | |
EXEC dbo.DeleteFolderPermissionsByUserID 0, @var1 | |
EXEC dbo.RemoveUser @var1, null | |
--Printing to the results view what site has been removed | |
PRINT DB_NAME(DB_ID(''?'')) + '' has an account with Andrew on it, REMOVED'' | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment