in CustomSecuritySample/AuthenticationExtension.cs [146:178]
public static bool VerifyUser(string userName)
{
bool isValid = false;
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.Database_ConnectionString))
{
SqlCommand cmd = new SqlCommand("LookupUser", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter sqlParam = cmd.Parameters.Add("@userName",
SqlDbType.VarChar,
255);
sqlParam.Value = userName;
try
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
// If a row exists for the user, then the user is valid.
if (reader.Read())
{
isValid = true;
}
}
}
catch (Exception ex)
{
throw new Exception(string.Format(CultureInfo.InvariantCulture,
CustomSecurity.VerifyError + ex.Message));
}
}
return isValid;
}