本文整理汇总了C#中SaveRequest.SetFlag方法的典型用法代码示例。如果您正苦于以下问题:C# SaveRequest.SetFlag方法的具体用法?C# SaveRequest.SetFlag怎么用?C# SaveRequest.SetFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaveRequest
的用法示例。
在下文中一共展示了SaveRequest.SetFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
private int Authenticate(string username, string password, LoginMode loginMode, int entityType, out SecurityEntity entity)
{
var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SecurityEntity>());
using (IDataReader dr = db.ExecuteDataReader("SPGetSecurityEntityByLoginUserName", username,entityType))
{
if (dr.Read())
{
entity = GetFromData<SecurityEntity>(dr);
//handle loginEnabled
if (!entity.LoginEnabled && loginMode != LoginMode.IAC)
{
_Log.InfoFormat("User {0} is not login enabled", username);
return AuthenticationResult.LoginDisabled;
}
else
{
var req = new SaveRequest<SecurityEntity>(entity);
if (entity.Salt != Guid.Empty)
{
// Check new style password hash
string storedHash = entity.LoginPassword;
string calculatedHash = Convert.ToBase64String(AuthenticationHelper.ComputePasswordHash(entity.Salt, password));
if (storedHash != calculatedHash)
{
return AuthenticationResult.WrongPassword;
}
//else success
}
else
{
// Check old style password hash and upgrade to new style
string saltyPassword = AuthenticationHelper.ComputeHashOldStyle(username, password);
if (entity.LoginPassword != saltyPassword)
{
return AuthenticationResult.WrongPassword;
}
else
{
// upgrade
req.SetFlag("UpdatePassword", true);
entity.LoginPassword = password; // tricky: plain text will be hashed in SaveUserSecurityEntity
// success
}
}
entity.LastLogonDate = DateTime.UtcNow;
SaveUserSecurityEntity(req);
return AuthenticationResult.Success;
}
}
entity = null;
return AuthenticationResult.SecurityEntityNotFound;
}
}