Note that there are some explanatory texts on larger screens.

plurals
  1. POMembership.GetUser() // GetUser(userName) returns a null user
    text
    copied!<p>I'm trying to get a System.Web.Security.MembershipUser user so I can check it's lastPasswordChangedDate property, only problem is it's returning null.</p> <p>I've had a look around and most of the similar problems seem to be because the user is not authenticated when trying to create the object. In my case the user is authenticated directly before calling the method, albeit in another class.</p> <p>Any pointers?</p> <p>PSEUDO-CODE FOLLOWS :</p> <p>FrontEnd ----> Login.cs</p> <pre><code>string userName = txtUser.Text; string password = txtPW.Text; wsAuth = new wsAuth(); wsAuthentication.Authenticate(userName,password); </code></pre> <p>Auth service ----></p> <pre><code>public bool Authenticate(string userName, string password) { SecurityProviderSettings settings = SecurityProviderSettings.GetFromConfiguration("SecurityProviders"); ProviderSetting providerSetting = settings.Providers[providerName]; object provider = Activator.CreateInstance(providerType); return ((IAuthenticationProvider)provider).Authenticate(userName, password, providerSetting.CustomInfo, out failReason, out token); } </code></pre> <p>Specific Provider ----></p> <pre><code>public bool Authenticate(string userName, string password, out string failReason .....) { SqlMembershipProvider provider = new SqlMembershipProvider(); #region settings //blablabla #endregion provider.initialize(/*input vars*/); bool authenticated = provider.ValidateUser(userName,password); if(authenticated) { pwValidator val = new pwValidator(); if(!val.IsInLifetime(userName,password)) { failReason = "password expired"; } } } </code></pre> <p>PasswordValidator ----></p> <pre><code> public bool IsInLifetime(string userName, string password) { MembershipUser user = Membership.GetUser(userName); MembershipUser user2 = Membership.GetUser(); #bla bla bla } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload