/// <summary> /// GetUserStoredCredentials method implementation /// </summary> public List <WebAuthNCredentialInformation> GetUserStoredCredentials(AuthenticationContext ctx) { List <WebAuthNCredentialInformation> wcreds = new List <WebAuthNCredentialInformation>(); var user = RuntimeRepository.GetUser(Config, ctx.UPN); List <MFAUserCredential> creds = RuntimeRepository.GetCredentialsByUser(Config, user); if (creds.Count == 0) { return(wcreds); } foreach (MFAUserCredential st in creds) { WebAuthNCredentialInformation itm = new WebAuthNCredentialInformation() { CredentialID = HexaEncoding.GetHexStringFromByteArray(st.Descriptor.Id), AaGuid = st.AaGuid, CredType = st.CredType, RegDate = st.RegDate, SignatureCounter = st.SignatureCounter }; if (st.Descriptor.Type != null) { itm.Type = EnumExtensions.ToEnumMemberValue(st.Descriptor.Type.Value); } wcreds.Add(itm); } return(wcreds.OrderByDescending(c => c.RegDate).ToList <WebAuthNCredentialInformation>()); }
/// <summary> /// GetUserStoredCredentials method implementation /// </summary> public List <WebAuthNCredentialInformation> GetUserStoredCredentials(string upn) { List <WebAuthNCredentialInformation> wcreds = new List <WebAuthNCredentialInformation>(); try { MFAWebAuthNUser user = RuntimeRepository.GetUser(Config, upn); if (user != null) { List <MFAUserCredential> creds = RuntimeRepository.GetCredentialsByUser(Config, user); if (creds.Count == 0) { return(null); } // return wcreds; foreach (MFAUserCredential st in creds) { WebAuthNCredentialInformation itm = new WebAuthNCredentialInformation() { CredentialID = HexaEncoding.GetHexStringFromByteArray(st.Descriptor.Id), AaGuid = st.AaGuid, CredType = st.CredType, RegDate = st.RegDate, SignatureCounter = st.SignatureCounter, NickName = st.NickName }; if (st.Descriptor.Type != null) { itm.Type = EnumExtensions.ToEnumMemberValue(st.Descriptor.Type.Value); } wcreds.Add(itm); } return(wcreds.OrderByDescending(c => c.RegDate).ToList()); } else { Log.WriteEntry(string.Format("{0}\r\n{1}", upn, "User does not exists !"), EventLogEntryType.Error, 5000); throw new ArgumentNullException(string.Format("{0}\r\n{1}", upn, "User does not exists !"));; } } catch (Exception e) { Log.WriteEntry(string.Format("{0}\r\n{1}", upn, e.Message), EventLogEntryType.Error, 5000); throw e; } }