Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

debug MembershipProvider.cs

is there a way to attach to (in the debugger), the MembershipProvdider.cs.? I'm trying to figure out why it always fails during the authenticate method. i'd like to step into it to see where the failure is occuring.
0
Michael Sterling
Asked:
Michael Sterling
  • 13
  • 7
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
Which MembershipProvider.cs? If you mean the one underlying the built-in sql membership provider then no, because it's compiled into the framework. Or do you mean something else?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
nah i think that's the one i meant...i thought i could step through it, but maybe i can't. i can't figure out, for the life of me, why my Membership.ValidateUser always fails. i'm using a MySql db, i've got all my tables generated and the site administrator tool allows me to add and remove users and roles correctly. i've checked the db and they do exist. all of the control fields (IsLockedOut etc...) are set correctly but it fails, with out fail, every time. so i thought i could step through it and see where it was failing but i guess not...any suggestions would help...
0
 
Carl TawnSystems and Integration DeveloperCommented:
Do you have ay kind of database profiling tool yu can use to see if the membership provider is actually hitting your database when you try and authenticate?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dacITCommented:
I wonder if you could build and implement a custom provider, but inherit sqlmembershipprovider and assign each method the base.[methodname]. Then you could put in breakpoints and debug your provider, but it would still be using the built in methods. Worth a shot anyway.
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@dacIT i kind of tried that and i'm actually completely buggered up now and am in barney as i now can't even successfully add users anymore. any suggestions how to get back to square 1? anyone?
Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Web.Administration.WebAdminMembershipProvider.CallWebAdminMembershipProviderHelperMethodOutParams(String methodName, Object[] parameters, Type[] paramTypes) at System.Web.Administration.WebAdminMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.WebControls.Wizard.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Open in new window

0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
attached is my web.config
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="STTEntities" connectionString="metadata=res://*/STTE.csdl|res://*/STTE.ssdl|res://*/STTE.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;User Id=root;password=apswrd;Persist Security Info=True;server=0.0.0.0;database=myMySQLDB&quot;" providerName="System.Data.EntityClient" />
    <remove name="LocalMySqlServer"/>
    <add name="LocalMySqlServer"
         connectionString="Server=localhost;Database=myMySQLDB;User Id=root;Password=apswrd;"
    providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="MySql.Data, Version=6.3.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
      </assemblies>
    </compilation>
    <authentication mode="Forms">
      <forms loginUrl="~/Admin/Login.aspx" defaultUrl="~/Admin/Default.aspx" timeout="2880"/>
    </authentication>
    <!--<authorization>
      <deny users="?" />
      <allow users="*"/>
    </authorization>-->
    <membership defaultProvider="MySqlMembershipProvider">
      <providers>
        <clear/>
        <remove name="MySqlMembershipProvider"/>
        <add name="MySqlMembershipProvider"
             connectionStringName="LocalMySqlServer"
             applicationName="myMySQLDB"
             type="MySql.Web.Security.MySqlMembershipProvider"
             passwordFormat="Encrypted"
             writeExceptionsToEventLog="true"
             autogenerateschema="true"/>
      </providers>
    </membership>
    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
        <add name="MySqlProfileProvider" type="MySql.Web.Security.MySqlProfileProvider, MySql.Web, Version=6.3.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="myMySQLDB" autogenerateschema="true"/>
      </providers>
    </profile>
    <roleManager enabled="true" defaultProvider="MySqlRoleProvider">
      <providers>
        <clear />
        <!--<add connectionStringName="ApplicationServices" applicationName="/"
          name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />-->
        <add applicationName="/" name="AspNetWindowsTokenRoleProvider"
          type="System.Web.Security.WindowsTokenRoleProvider" />
        <add connectionStringName="LocalMySqlServer" applicationName="myMySQLDB"
          autogenerateschema="true" name="MySqlRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.3.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
      </providers>
    </roleManager>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <location path="Admin/Default.aspx" allowOverride="true">
    <system.web>
      <!--<authorization>
        <deny users="?"/>
        <allow users="*"/>
      </authorization>-->
    </system.web>
  </location>
</configuration>

Open in new window

0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
sometimes when i go to create a new user, i get this:
Value cannot be null. Parameter name: virtualPath at 
System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) at 
System.Web.VirtualPath.CreateAbsolute(String virtualPath) at 
System.Web.Hosting.ApplicationManager.CreateObject(String appId, Type type, String virtualPath, String physicalPath, Boolean failIfExists, Boolean throwOnError) at 
System.Web.Hosting.ApplicationManager.CreateObject(String appId, Type type, String virtualPath, String physicalPath, Boolean failIfExists, Boolean throwOnError) at 
System.Web.Administration.WebAdminRemotingManager.CreateConfigurationHelper() at 
System.Web.Administration.WebAdminRemotingManager.get_ConfigurationHelperInstance() at 
System.Web.Administration.WebAdminMembershipProvider.GetWebAdminMembershipProviderHelperProperty(String propertyName) at 
System.Web.Administration.WebAdminMembershipProvider.get_RequiresQuestionAndAnswer() at 
System.Web.UI.WebControls.CreateUserWizard.get_QuestionAndAnswerRequired() at 
System.Web.UI.WebControls.CreateUserWizard.UpdateValidators() at 
System.Web.UI.WebControls.CreateUserWizard.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at 
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at
 System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Control.InitRecursive(Control namingContainer) at
 System.Web.UI.Control.InitRecursive(Control namingContainer) at 
System.Web.UI.Page.ProcessRequestMain(Boolean 
includeStagesBeforeAsyncPoint, Boolean
 includeStagesAfterAsyncPoint)

Open in new window

0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
i figured it out. in my membership provider in my web.config file, it really didn't like the passwordFormat being set to "Encrypted" (i set it to Hashed and now I'm back to square one). I've been having issues with this for a while now, (the whole: "Your login attempt was unsuccessful. Please try again." error) and i can't for 100% sure say that my passwordFormat property has always been "Hashed", but maybe it has? I'm wondering if this has anything to do with my current problem of not being able to authenticate and getting the: "Your login attempt was unsuccessful. Please try again." erro? Any ideas?
0
 
Carl TawnSystems and Integration DeveloperCommented:
How are you trying to authenticate? Are you using the built-in login control or are you using the FormsAuthentication.Authenticate() method?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
i'm using the built in login control. and have tried both methods (below) with no success.

        if (Membership.ValidateUser(lgAdmin.UserName, lgAdmin.Password))
        {
            e.Authenticated = true;
        }
        else { e.Authenticated = false; }    

        //bool authenticated = ValidateUser(lgAdmin.UserName, lgAdmin.Password);
        //e.Authenticated = authenticated;

        //if (authenticated)
        //{
        //    FormsAuthentication.SetAuthCookie(lgAdmin.UserName, true);
        //    Response.Redirect("~/Admin/Default.aspx");
        //    //anything else you need to do
        //}
        //else
        //{
        //    //authentication failed ... do something
        //}
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
@carl tawn: the line above that reads:

//bool authenticated = ValidateUser(lgAdmin.UserName, lgAdmin.Password);

should read:

//bool authenticated = Membership.ValidateUser(lgAdmin.UserName, lgAdmin.Password);

i understand that the "block" of code that this resides in is commented out but, I've made it live code, and tried to use it with no success...
0
 
Carl TawnSystems and Integration DeveloperCommented:
Have you tried using it with clear text passwords? That will at least rule out it being an issue with the hashing.
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
yes. the clear password does work. but why does the Hashed not work? or am i making a mountain out of a mole hill, and should "let this one go" and move on?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
i take that back...i just tried the clear and it does not work either.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Well the simple answer is because your Authenticate method isn't managing to generate the same hash value as the one stored in the database. Why it isn't is another matter. I assume you're not implementing your own hashing routine?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
hold on...that's not true. i was operating against a user that i'd created with the "Hashed" password....let me try this again.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Oh, OK. That at least makes it a more general login problem. How did you generate the schema for your membership database?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
yes, the clear does work, as stated above. and i am not implementing my own hashing routine.
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
i used a script to generate the tables as the "autogenerateschema" did not seem to work. and my understanding as to why it didn't was that the particular version of MySqlConnector that I'm using had a bug that didn't generate the tables. so the schema that i generated works with regards to inserting and removing users and adding roles etc. so it does recognize it and communicates with it correctly on those levels...
0
 
Carl TawnSystems and Integration DeveloperCommented:
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
FLIPPIN FANTASTIC! been trying to solve this for a solid 2 weeks so it seems (maybe less, feels like more ;-), but it always does...) thanks again!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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