概述
///
<summary>
/// 检查用户名密码是否匹配
/// </summary>
/// <param name="user"> 用户名 </param>
/// <param name="pass"> 用户密码 </param>
/// <returns> 是否匹配 </returns>
public Boolean CheckPasswordByUser( string user, string pass)
{
string sqlstring = string.Format( " select Password from [User accounts] where [User]='{0}' ", user);
object o=dbServU.GetSingle(sqlstring);
if (o != null)
{
string dbPass = ( string)o;
if (dbPass.Length > 32)
{
char a, b;
a = dbPass[ 0];
b = dbPass[ 1];
string password = string.Format( " {0}{1}{2} ", a, b, pass);
password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, " MD5 ");
password = string.Format( " {0}{1}{2} ", a, b, password.ToUpper());
if (dbPass == password)
return true;
}
}
return false;
}
/// <summary>
/// 生成新ServU格式密码
/// </summary>
/// <param name="pass"> 密码 </param>
/// <returns> 生成的新密码 </returns>
public string GenNewPass( string pass)
{
Random rnm = new Random();
char a = ( char)(rnm.Next( 97, 123));
char b = ( char)(rnm.Next( 97, 123));
string password = string.Format( " {0}{1}{2} ", a, b, pass);
password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, " MD5 ");
pass = string.Format( " {0}{1}{2} ", a, b, password.ToUpper());
return pass;
}
/// <summary>
/// 更改密码
/// </summary>
/// <param name="user"> 用户名 </param>
/// <param name="newPass"> 新密码 </param>
/// <returns> 是否成功 </returns>
public Boolean ResetPass( string user, string newPass)
{
string sqlstring = string.Format( " select Password from [User accounts] where [User]='{0}' ", user);
object o=dbServU.GetSingle(sqlstring);
if (o != null)
{
sqlstring = string.Format( " update [User accounts] set password='{0}' where [User]='{1}' ", GenNewPass(newPass), user);
if (dbServU.ExcuteSQL(sqlstring) > 0)
return true;
}
return false;
}
/// 检查用户名密码是否匹配
/// </summary>
/// <param name="user"> 用户名 </param>
/// <param name="pass"> 用户密码 </param>
/// <returns> 是否匹配 </returns>
public Boolean CheckPasswordByUser( string user, string pass)
{
string sqlstring = string.Format( " select Password from [User accounts] where [User]='{0}' ", user);
object o=dbServU.GetSingle(sqlstring);
if (o != null)
{
string dbPass = ( string)o;
if (dbPass.Length > 32)
{
char a, b;
a = dbPass[ 0];
b = dbPass[ 1];
string password = string.Format( " {0}{1}{2} ", a, b, pass);
password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, " MD5 ");
password = string.Format( " {0}{1}{2} ", a, b, password.ToUpper());
if (dbPass == password)
return true;
}
}
return false;
}
/// <summary>
/// 生成新ServU格式密码
/// </summary>
/// <param name="pass"> 密码 </param>
/// <returns> 生成的新密码 </returns>
public string GenNewPass( string pass)
{
Random rnm = new Random();
char a = ( char)(rnm.Next( 97, 123));
char b = ( char)(rnm.Next( 97, 123));
string password = string.Format( " {0}{1}{2} ", a, b, pass);
password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, " MD5 ");
pass = string.Format( " {0}{1}{2} ", a, b, password.ToUpper());
return pass;
}
/// <summary>
/// 更改密码
/// </summary>
/// <param name="user"> 用户名 </param>
/// <param name="newPass"> 新密码 </param>
/// <returns> 是否成功 </returns>
public Boolean ResetPass( string user, string newPass)
{
string sqlstring = string.Format( " select Password from [User accounts] where [User]='{0}' ", user);
object o=dbServU.GetSingle(sqlstring);
if (o != null)
{
sqlstring = string.Format( " update [User accounts] set password='{0}' where [User]='{1}' ", GenNewPass(newPass), user);
if (dbServU.ExcuteSQL(sqlstring) > 0)
return true;
}
return false;
}
密码修改成功后,在注意在ServU中设置Allow user to change password。不然,修改之后密码和新密码都无法正常登录FTP。
转载于:https://www.cnblogs.com/leotan/archive/2012/10/24/2736633.html
最后
以上就是闪闪香氛为你收集整理的在线修改ServU密码注意问题。的全部内容,希望文章能够帮你解决在线修改ServU密码注意问题。所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复