Convert Forms user to Windows user

To change the authentication type of a user from formsĀ to windows you have to run the provided sql script :


USE [TeamPulse]
GO

DECLARE @Domain nvarchar(128) = 'DOMAIN' /* CHANGE THIS to the DOMAIN that the new user will use */

DECLARE @UserID int = 0 /* CHANGE THIS to the UserID (from the User table) of the user that is being converted */
DECLARE @AspnetUserID uniqueidentifier
DECLARE @Username nvarchar(256)

/* Get the current user's information */
SELECT
 @AspnetUserID = u.StsUserID,
 @Username = u.Username
FROM [TeamPulse].[dbo].[User] u
WHERE u.UserID = @UserID

/* Modify user in User table */
UPDATE [User]
SET Domain = @Domain,
    Provider = 'Windows'
WHERE UserID = @UserID


/* Modify user in aspnet_Users table */
UPDATE [aspnet_Users]
SET UserName = @Username + '@' + @Domain,
    LoweredUserName = LOWER(@Username + '@' + @Domain)
WHERE UserName = @Username