/// <summary> /// Verifican que usuario y password sean validos /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <param name="providerName">Nombre del proveedor de membership</param> /// <returns></returns> public static Boolean ValidateUser(string userName, string password, string providerName) { SqlMembershipProvider wProvider = GetSqlMembershipProvider(providerName); TechnicalException te = null; bool isValid = wProvider.ValidateUser(userName, password); if (!isValid) { MembershipUser user = wProvider.GetUser(userName, true); if (user != null) { //User exists if (!user.IsApproved) { //Account Unapproved te = new TechnicalException("Your account is not approved."); te.ErrorId = "4011"; throw te; } else if (user.IsLockedOut) { //Account Locked te = new TechnicalException("Your account is locked."); te.ErrorId = "4012"; throw te; } else { te = new TechnicalException("Invalid username or password."); te.ErrorId = "4013"; throw te; } } else { te = new TechnicalException("Invalid username or password."); te.ErrorId = "4013"; throw te; } } return(isValid); }
/// <summary> /// /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <param name="providerName"></param> /// <returns></returns> public static MembershipEnums CheckUserStatus(string userName, string password, string providerName) { MembershipEnums status = MembershipEnums.AccountUsernameAndPassword_IS_OK; SqlMembershipProvider wProvider = GetSqlMembershipProvider(providerName); bool isValid = wProvider.ValidateUser(userName, password); if (!isValid) { MembershipUser user = wProvider.GetUser(userName, true); if (user != null) { //User exists if (!user.IsApproved) { //Account Unapproved status = MembershipEnums.AccountIsNotApproved; } else if (user.IsLockedOut) { //Account Locked status = MembershipEnums.AccountIsLockedOut; } else { //Invalid username or password status = MembershipEnums.InvalidUsernameOrPassword; } } else { status = MembershipEnums.InvalidUsernameOrPassword; } } return(status); }