有时候我们会忘记DotNetNuke的host密码,这是一件很头疼的事,这时我们可以通过下面这一段SQL 把host密码重置为一个已知用户的密码(假设这个已知用户名为m2land)。原理其实很简单,这段 会把aspnet_membership表中的"m2land"用户的password和password_salt值拷贝并覆盖host对应的值。
使用方法请参考 中的说明。
/*
-- Data Utility ---------------------------------------------------------------------------
De ion : Reset a Password in a DotNetNuke data
Author : Tony Tullemans
Date Created : 18.04.2007
Note/s : Before you run this you must know the UserName and Password of another
registered DNN user in the data you wish to affect.
-----------------------------------------------------------------------------------------------
*/
DECLARE @data Name VARCHAR(128)
SELECT @data Name = DB_NAME()
PRINT 'RESET PASSWORD IN DATA : ' + @data Name
PRINT '-----------------------------' + REPLICATE('-', DATALENGTH(@data Name ));
DECLARE @knownUserName NVARCHAR(128)
DECLARE @lostUserName NVARCHAR(128)
DECLARE @lostUserId NVARCHAR(128)
DECLARE @knownPassword NVARCHAR(128)
DECLARE @knownSalt NVARCHAR(128)
SET @knownUserName = 'm2land'
SET @lostUserName = 'host'
SELECT @knownPassword = Password, @knownSalt = PasswordSalt
FROM aspnet_Membership
INNER JOIN aspnet_users
ON aspnet_Membership.UserId = aspnet_users.UserId
where UserName = @knownUserName;
PRINT ''
PRINT 'Known Password for "' + @knownUserName + '" is : ' + @knownPassword
PRINT 'Known Password Salt for "' + @knownUserName + '" is : ' + @knownSalt
SELECT @lostUserId = aspnet_Membership.UserId
FROM aspnet_Membership
INNER JOIN aspnet_users
ON aspnet_Membership.UserId = aspnet_users.UserId
WHERE UserName = @lostUserName;
PRINT ''
PRINT 'UserID for "' + @lostUserName + '" is : ' + @lostUserId
PRINT ''
IF (DATALENGTH(@lostUserName) <= 0 OR @lostUserName IS NULL)
PRINT 'Invalid Lost User Name ' + @lostUserName
ELSE BEGIN
IF (DATALENGTH(@knownUserName) <= 0 OR @knownUserName IS NULL)
PRINT 'Invalid Lost User Name ' + @lostUserName
ELSE BEGIN
IF (DATALENGTH(@knownPassword) <= 0 OR @knownPassword IS NULL)
PRINT 'Invalid Known Password ' + @knownPassword
ELSE BEGIN
IF (DATALENGTH(@knownSalt) <= 0 OR @knownSalt IS NULL)
PRINT 'Invalid Known Salt ' + @knownSalt
ELSE BEGIN
PRINT ''
PRINT 'BEFORE'
SELECT left(UserName, 12) as UserName, aspnet_Membership.UserId, left(Email, 20) as Email, Password, PasswordSalt
FROM aspnet_Membership INNER JOIN aspnet_users ON aspnet_Membership.UserId = aspnet_users.UserId
WHERE UserName IN ( @knownUserName, @lostUserName );
PRINT ''
PRINT 'Changing Password for User Id : "' + @lostUserId + '" to "' + @knownPassword + '"'
PRINT ''
UPDATE aspnet_Membership
SET Password = @knownPassword,
PasswordSalt = @knownSalt
-- SELECT UserId, Password, PasswordSalt
-- FROM aspnet_Membership
WHERE UserId = @lostUserId;
PRINT ''
PRINT 'AFTER'
SELECT left(UserName, 12) as UserName, aspnet_Membership.UserId, left(Email, 20) as Email, Password, PasswordSalt
FROM aspnet_Membership INNER JOIN aspnet_users ON aspnet_Membership.UserId = aspnet_users.UserId
WHERE UserName IN ( @knownUserName, @lostUserName );
END
END
END
END
GO
PRINT ''
PRINT ' * * * END OF * * *'
PRINT ''
GO
-- Data Utility ---------------------------------------------------------------------------
De ion : Reset a Password in a DotNetNuke data
Author : Tony Tullemans
Date Created : 18.04.2007
Note/s : Before you run this you must know the UserName and Password of another
registered DNN user in the data you wish to affect.
-----------------------------------------------------------------------------------------------
*/
DECLARE @data Name VARCHAR(128)
SELECT @data Name = DB_NAME()
PRINT 'RESET PASSWORD IN DATA : ' + @data Name
PRINT '-----------------------------' + REPLICATE('-', DATALENGTH(@data Name ));
DECLARE @knownUserName NVARCHAR(128)
DECLARE @lostUserName NVARCHAR(128)
DECLARE @lostUserId NVARCHAR(128)
DECLARE @knownPassword NVARCHAR(128)
DECLARE @knownSalt NVARCHAR(128)
SET @knownUserName = 'm2land'
SET @lostUserName = 'host'
SELECT @knownPassword = Password, @knownSalt = PasswordSalt
FROM aspnet_Membership
INNER JOIN aspnet_users
ON aspnet_Membership.UserId = aspnet_users.UserId
where UserName = @knownUserName;
PRINT ''
PRINT 'Known Password for "' + @knownUserName + '" is : ' + @knownPassword
PRINT 'Known Password Salt for "' + @knownUserName + '" is : ' + @knownSalt
SELECT @lostUserId = aspnet_Membership.UserId
FROM aspnet_Membership
INNER JOIN aspnet_users
ON aspnet_Membership.UserId = aspnet_users.UserId
WHERE UserName = @lostUserName;
PRINT ''
PRINT 'UserID for "' + @lostUserName + '" is : ' + @lostUserId
PRINT ''
IF (DATALENGTH(@lostUserName) <= 0 OR @lostUserName IS NULL)
PRINT 'Invalid Lost User Name ' + @lostUserName
ELSE BEGIN
IF (DATALENGTH(@knownUserName) <= 0 OR @knownUserName IS NULL)
PRINT 'Invalid Lost User Name ' + @lostUserName
ELSE BEGIN
IF (DATALENGTH(@knownPassword) <= 0 OR @knownPassword IS NULL)
PRINT 'Invalid Known Password ' + @knownPassword
ELSE BEGIN
IF (DATALENGTH(@knownSalt) <= 0 OR @knownSalt IS NULL)
PRINT 'Invalid Known Salt ' + @knownSalt
ELSE BEGIN
PRINT ''
PRINT 'BEFORE'
SELECT left(UserName, 12) as UserName, aspnet_Membership.UserId, left(Email, 20) as Email, Password, PasswordSalt
FROM aspnet_Membership INNER JOIN aspnet_users ON aspnet_Membership.UserId = aspnet_users.UserId
WHERE UserName IN ( @knownUserName, @lostUserName );
PRINT ''
PRINT 'Changing Password for User Id : "' + @lostUserId + '" to "' + @knownPassword + '"'
PRINT ''
UPDATE aspnet_Membership
SET Password = @knownPassword,
PasswordSalt = @knownSalt
-- SELECT UserId, Password, PasswordSalt
-- FROM aspnet_Membership
WHERE UserId = @lostUserId;
PRINT ''
PRINT 'AFTER'
SELECT left(UserName, 12) as UserName, aspnet_Membership.UserId, left(Email, 20) as Email, Password, PasswordSalt
FROM aspnet_Membership INNER JOIN aspnet_users ON aspnet_Membership.UserId = aspnet_users.UserId
WHERE UserName IN ( @knownUserName, @lostUserName );
END
END
END
END
GO
PRINT ''
PRINT ' * * * END OF * * *'
PRINT ''
GO
附:还有一个版本的 ,这个版本是直接调用Asp.net的存储过程来修改密码,在我看来更方便,但不知为什么不起作用,望赐教!
另一个方法:
As there arefrequent requests from users, who lost the password of the host account(and you cannot request the host password by email), the followingsolution will help for all DNN 3 and 4 installation. Please note, thatyour need direct access to the data to suceed with the issue:
- if "register" is not displayed for the portal, go to table "Portals" in your data and enter value "2" into column "Registration".
- create a new user account by registration (this time, please remember the password you enter!)
- go to data , enter table "ASPNet_Membership"
- go to new user account (usually the last one) and copy the encrypted values of columns "Password" and "PasswordSalt" into the same columns of user account "host" (usually th first entry in this table)
- login as user "host" using the new password and delete the reshly created other user.
- Keep remembering your password ;)
继续阅读与本文标签相同的文章
下一篇 :
如何在Firefox方便的抓取网页上的Flash
-
C# 面试题解析-请遍历页面上所有的TextBox控件并给它赋值为string.Empty
2026-05-25栏目: 教程
-
DNN使用非80端口和总是跳转到http://localhost问题的解决(翻译)
2026-05-25栏目: 教程
-
如何使用DNN中的Calendar控件
2026-05-25栏目: 教程
-
模块开发中一点疑惑?
2026-05-25栏目: 教程
-
对DNN的理解:
2026-05-25栏目: 教程
