/// <summary> /// RemoveUserKey method implementation /// </summary> public override bool RemoveUserKey(string upn) { try { List <MFAUserKeys> _lst = _mfakeysusers.GetData(); int res = _lst.RemoveAll(s => s.UserName.ToLower().Equals(upn.ToLower())); _mfakeysusers.SetData(_lst); return(res > 0); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
/// <summary> /// AddCredential method implementation /// </summary> public bool AddUserCredential(MFAWebAuthNUser user, MFAUserCredential credential) { try { credential.UserId = user.Id; List <MFAUserCredential> _lst = _mfacredusers.GetData(); _lst.Add(credential); _mfacredusers.SetData(_lst); return(true); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
/// <summary> /// SetMFAUser method implementation /// </summary> public override MFAUser SetMFAUser(MFAUser reg, bool resetkey = false, bool caninsert = true, bool disableoninsert = false) { if (!IsMFAUserRegistered(reg.UPN)) { if (caninsert) { return(AddMFAUser(reg, resetkey, false)); } else { return(GetMFAUser(reg.UPN)); } } try { MFAUser usr = GetMFAUser(reg.UPN); if (!disableoninsert) // disable change if not explicitely done { if (reg.Enabled) { usr.Enabled = true; } else { usr.Enabled = false; } } else { usr.Enabled = false; } usr.IsRegistered = true; usr.MailAddress = reg.MailAddress; usr.PhoneNumber = reg.PhoneNumber; usr.PreferredMethod = reg.PreferredMethod; usr.PIN = reg.PIN; if (string.IsNullOrEmpty(reg.OverrideMethod)) { usr.OverrideMethod = string.Empty; } else { usr.OverrideMethod = reg.OverrideMethod; } if (resetkey) { this.OnKeyDataEvent(reg.UPN, KeysDataManagerEventKind.add); } List <MFAUser> _lst = _mfausers.GetData(); _lst.Where(s => s.UPN.ToLower().Equals(reg.UPN.ToLower())).ToList().ForEach(s => { s.Enabled = usr.Enabled; s.MailAddress = usr.MailAddress; s.PhoneNumber = usr.PhoneNumber; s.PreferredMethod = usr.PreferredMethod; s.OverrideMethod = usr.OverrideMethod; s.PIN = usr.PIN; }); _mfausers.SetData(_lst); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } return(GetMFAUser(reg.UPN)); }