• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2434
  • Last Modified:

The user account has been locked out - when trying to access ASPNET membership objects

I'm have a big problem brought the user administration part of my application down.  

I have a User Administration page that allow displays .net membership users.  I have a membership utility class that interacts with the .net membership objects, like MembershipUserCollection.  Out of the blue I got a "The user account has been locked out" message when I go to my UserAdmin.aspx page.  NOTE: My .net user is NOT locked out, I have checked and am able to see all other pages in my application.  So I'm guessing that my custom utility class is somehow locked out.  Could this be?  I hope so, because I'm really stuck.  Ideas?  How to fix?

Code below is some of the code in my custom membership utility class, that interacts with the .net membership objects.  There is much more, but this looks like the last thing to pass in the stack track message.  I can't create this error in Development so I stepping through doesn't help.

Here's the error message:
      The user account has been locked out.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Security.MembershipPasswordException: The user account has been locked out.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[MembershipPasswordException: The user account has been locked out.]
   System.Web.Security.SqlMembershipProvider.GetPassword(String username, String passwordAnswer) +1860247
   MembershipUtil.ConvertMembershipUtilMembership(MembershipUser usr) +78
   MembershipUtil.GetMembershipUtils() +124
   MembershipUtil.GetAllClients() +629

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +71
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +350
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
   System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +488
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1247
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +19
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


private static MembershipUtil ConvertMembershipUtilMembership(MembershipUser usr)
	{
        // Declare a Profile object for the user
        ProfileBase p = ProfileBase.Create(usr.UserName.ToString());
        
		MembershipUtil MembershipUtil = new MembershipUtil();
		MembershipUtil.Username = usr.UserName;
        if (Membership.Provider.GetPassword(MembershipUtil.Username, String.Empty) != null)
        {
            MembershipUtil.Password = Membership.Provider.GetPassword(MembershipUtil.Username, String.Empty);
        }
        else
            MembershipUtil.Password = "N/A";
        
        if (p.GetPropertyValue("FirstName") != null)
        { MembershipUtil.FirstName = p.GetPropertyValue("FirstName").ToString(); }
        else
        { MembershipUtil.FirstName = ""; }
        
        if (p.GetPropertyValue("LastName") != null)
        { MembershipUtil.LastName = p.GetPropertyValue("LastName").ToString(); }
        else
        { MembershipUtil.LastName = ""; }

        //if (p.GetPropertyValue("Contact") != null)
        //{ MembershipUtil.Contact = p.GetPropertyValue("Contact").ToString(); }
        //else
        //{ MembershipUtil.Contact = ""; }

        if (p.GetPropertyValue("Company") != null)
        { MembershipUtil.Company = p.GetPropertyValue("Company").ToString(); }
        else
        { MembershipUtil.Company = ""; }

        if (p.GetPropertyValue("Initials") != null)
        { MembershipUtil.Initials = p.GetPropertyValue("Initials").ToString(); }
        else
        { MembershipUtil.Initials = ""; }
        
        if (p.GetPropertyValue("Phone") != null)
        { MembershipUtil.Phone = p.GetPropertyValue("Phone").ToString(); }
        else
        { MembershipUtil.Phone = ""; }

        //if (p.GetPropertyValue("FAX") != null)
        //{ MembershipUtil.FAX = p.GetPropertyValue("FAX").ToString(); }
        //else
        //{ MembershipUtil.FAX = ""; }

        if (p.GetPropertyValue("PRO") != null)
        { MembershipUtil.PRO = p.GetPropertyValue("PRO").ToString(); }
        else
        { MembershipUtil.PRO = ""; }

        if (p.GetPropertyValue("Nickname") != null)
        { MembershipUtil.Nickname = p.GetPropertyValue("Nickname").ToString(); }
        else
        { MembershipUtil.Nickname = ""; }
       
		MembershipUtil.EmailAddress = usr.Email; 
		MembershipUtil.UserRole = GetUserRole(usr.UserName);
		MembershipUtil.IsApproved = usr.IsApproved;
		MembershipUtil.IsLockedOut = usr.IsLockedOut;
		return MembershipUtil;
	}

Open in new window

0
JT_SIRO
Asked:
JT_SIRO
  • 3
1 Solution
 
JT_SIROAuthor Commented:
I know how to reset a password for a user.  My logged in user is not locked.  How do I reset it for a class that is trying to access .net?  

It is this code that it fails on in my MembershipUtil class:

        if (Membership.Provider.GetPassword(MembershipUtil.Username, String.Empty) != null)
        {
            MembershipUtil.Password = Membership.Provider.GetPassword(MembershipUtil.Username, String.Empty);
        }

0
 
JT_SIROAuthor Commented:
It was because one of the members was locked out and I was looping through them.  My user wasn't actually logged out.
0
 
JT_SIROAuthor Commented:
It was because one of the users I looped through, was logged out.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now