Convert Windows user to Forms user
To change the authentication type of a user from windows to forms you have to run the provided sql script:
USE [TeamPulse]
GO
-- CHANGE THIS to the UserID (from the User table) of the user that is being converted
DECLARE @UserID int = 0
-- CHANGE THIS to the username of the person who is executing this script
DECLARE @ModifyingUserName nvarchar(128) = 'Domain\username'
DECLARE @AppID uniqueidentifier
DECLARE @AspnetUserID uniqueidentifier
DECLARE @Username nvarchar(256)
DECLARE @Email nvarchar(256)
-- Get the membership provider application ID
SELECT TOP 1 @AppID = ApplicationID FROM aspnet_Applications
-- Get the current users information
SELECT
@AspnetUserID = u.StsUserID,
@Username = u.Username,
@Email = u.Email
FROM [TeamPulse].[dbo].[User] u
WHERE u.UserID = @UserID
IF EXISTS(SELECT * FROM [aspnet_Membership] WHERE UserId = @AspnetUserID)
BEGIN
UPDATE [aspnet_Users] SET [UserName] = @Username, [LoweredUserName] = LOWER(@Username)
WHERE UserId = @AspnetUserID
UPDATE [aspnet_Membership] SET [Password] = N'0KLODDA/xUMBMpDMr50BOl7IgaM=', [PasswordSalt] = N'lEcdCghFXdqjSa4WNDu0oQ=='
WHERE UserId = @AspnetUserID
END
ELSE
BEGIN
-- Add some rows to the membership provider tables for the user (Password defaults to password. Use the app to change it)
INSERT INTO [aspnet_Users] ([ApplicationId], [LoweredUserName], [UserId], [UserName], [MobileAlias], [IsAnonymous], [LastActivityDate])
VALUES (@AppID, lower(@Username), @AspnetUserID, @Username, NULL, 0, GETDATE())
INSERT INTO [aspnet_Membership] ([UserId], [ApplicationId], [Password], [PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail], [PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate], [LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate], [FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart], [FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (@AspnetUserID, @AppID, N'0KLODDA/xUMBMpDMr50BOl7IgaM=', 1, N'lEcdCghFXdqjSa4WNDu0oQ==', NULL, @Email, lower(@Email), @Username, N'yK9d4swHm4PYBL5sqpz3/Wdxt4M=', 1, 0, GETDATE(), GETDATE(), GETDATE(), GETUTCDATE(), 0, GETUTCDATE(), 0, GETUTCDATE(), NULL)
END
-- Update the current values for the user
UPDATE [User]
SET
Domain = '',
LastModifiedBy = @ModifyingUserName,
LastModifiedDateUtc = GETUTCDATE(),
LastModifiedSystemID = 0,
Provider = 'TeamPulse'
WHERE
UserID = @UserID