忘记DotNetNuke的host密码?-如何恢复丢失的DNN密码

忘记host密码? 有时候我们会忘记DotNetNuke的host密码,这是一件很头疼的事,这时我们可以通过下面这一段SQL Script把host密码重置为一个已知用户的密码(假设这个已知用户名为m2land)。

原理其实很简单,这段Script会把aspnet_membership表中的"m2land"用户的password和password_salt值拷贝并覆盖host对应的值。
使用方法请参考script中的说明。


/*
 -- Database Utility ---------------------------------------------------------------------------
 Description : Reset a Password in a DotNetNuke database
 Author : Tony Tullemans
 Date Created : 18.04.2007
 Note/s : Before you run this script you must know the UserName and Password of another
 registered DNN user in the database you wish to affect.
 -----------------------------------------------------------------------------------------------
 
*/
 
DECLARE   @databaseName   VARCHAR ( 128 )
SELECT   @databaseName   =   DB_NAME ()
 
PRINT   ' RESET PASSWORD IN DATABASE :  '   +   @databaseName
PRINT   ' ----------------------------- '   +   REPLICATE ( ' - ' DATALENGTH ( @databaseName  ));
 
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 SCRIPT * * * '
PRINT   ''
GO

附:还有一个版本的Script,这个版本是直接调用Asp.net的存储过程来修改密码,在我看来更方便,但不知为什么不起作用,望赐教!

SQL Script recovering host password use asp.net store procedure
-------------------------------------------------------------------------------------

Declare @UserName NVarChar(255)
Declare @NewPassword NVarChar(255)
Declare @PasswordSalt NVarChar(128)
Declare @Application NVarChar(255)

-- Enter the user name and new password between ''
--
 do not leave any spaces unless intended to do so.
--
 Edit only between single quote characters
Set @UserName = 'host' -- This default DNN host user
Set @NewPassword = 'newpassword' --New password
--
 Do modify any code below this line

Set @Application = (SELECT [ApplicationID] FROM aspnet_Users WHERE UserName=@UserName)
Set @PasswordSalt = (SELECT PasswordSalt FROM aspnet_Membership WHERE UserID IN (SELECT UserID FROM aspnet_Users WHERE UserName=@UserName))

Exec dbo.aspnet_Membership_ResetPassword @Application@UserName@NewPassword1010@PasswordSalt-5

-------------------------------------------------------------------------------------

另一个方法:

As there are frequent requests from users, who lost the password of the host account (and you cannot request the host password by email), the following solution will help for all DNN 3 and 4 installation. Please note, that your need direct access to the database to suceed with the issue:

  • if "register" is not displayed for the portal, go to table "Portals"  in your database and enter value "2" into column "Registration".
  • create a new user account by registration (this time, please remember the password you enter!)
  • go to database, 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 ;)
来自: http://www.deutschnetnuke.de/tabid/183/Default.aspx


转载于:https://www.cnblogs.com/DotNetNuke/archive/2007/12/01/979233.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值