public IList <OpenIdMembershipUser> GetAllOpenIdUsers(out int totalRecords) { var conn = new OdbcConnection(_connectionString); var cmd = new OdbcCommand("{call OpenId_Membership_GetAllUsers(?)}", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ApplicationName", OdbcType.VarChar, 255).Value = ApplicationName; IList <OpenIdMembershipUser> users = new List <OpenIdMembershipUser>(); OdbcDataReader reader = null; totalRecords = 0; try { conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { OpenIdMembershipUser u = GetUserFromReader(reader); users.Add(u); totalRecords++; } } catch (OdbcException e) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(e, "GetAllUsers "); throw new ProviderException(EXCEPTION_MESSAGE); } throw new OpenIdMembershipProviderException(e.Message, e.Source, e.StackTrace); } finally { if (reader != null) { reader.Close(); } conn.Close(); } return(users); }
private OpenIdMembershipUser GetUserFromReader(OdbcDataReader reader) { string username = reader.GetString(0); string openId = reader.IsDBNull(1) ? string.Empty : reader.GetString(1); string email = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); string passwordQuestion = ""; if (reader.GetValue(3) != DBNull.Value) passwordQuestion = reader.GetString(3); string comment = ""; if (reader.GetValue(4) != DBNull.Value) comment = reader.GetString(4); bool isApproved = reader.GetBoolean(5); DateTime creationDate = reader.GetDateTime(6); DateTime lastLoginDate = new DateTime(); if (reader.GetValue(7) != DBNull.Value) lastLoginDate = reader.GetDateTime(7); DateTime lastActivityDate = reader.GetDateTime(8); DateTime lastPasswordChangedDate = reader.GetDateTime(9); object providerUserKey = reader.GetValue(10); bool isLockedOut = reader.GetBoolean(11); DateTime lastLockedOutDate = new DateTime(); if (reader.GetValue(12) != DBNull.Value) lastLockedOutDate = reader.GetDateTime(12); OpenIdMembershipUser u = new OpenIdMembershipUser( this.Name, openId, username, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockedOutDate); return u; }
private OpenIdMembershipUser GetUserFromReader(OdbcDataReader reader) { string username = reader.GetString(0); string openId = reader.IsDBNull(1) ? string.Empty : reader.GetString(1); string email = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); string passwordQuestion = ""; if (reader.GetValue(3) != DBNull.Value) { passwordQuestion = reader.GetString(3); } string comment = ""; if (reader.GetValue(4) != DBNull.Value) { comment = reader.GetString(4); } bool isApproved = reader.GetBoolean(5); DateTime creationDate = reader.GetDateTime(6); DateTime lastLoginDate = new DateTime(); if (reader.GetValue(7) != DBNull.Value) { lastLoginDate = reader.GetDateTime(7); } DateTime lastActivityDate = reader.GetDateTime(8); DateTime lastPasswordChangedDate = reader.GetDateTime(9); object providerUserKey = reader.GetValue(10); bool isLockedOut = reader.GetBoolean(11); DateTime lastLockedOutDate = new DateTime(); if (reader.GetValue(12) != DBNull.Value) { lastLockedOutDate = reader.GetDateTime(12); } OpenIdMembershipUser u = new OpenIdMembershipUser( this.Name, openId, username, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockedOutDate); return(u); }