public abstract GetUser ( object providerUserKey, bool userIsOnline ) : System.Web.Security.MembershipUser | ||
providerUserKey | object | |
userIsOnline | bool | |
return | System.Web.Security.MembershipUser |
public override bool DeleteUser(string username, bool deleteAllRelatedData) { var conn = new OdbcConnection(_connectionString); var cmd = new OdbcCommand("{call OpenId_DeleteUserOpenIdLink(?)}", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@userId", OdbcType.VarChar, 255).Value = NonOpenIdMembershiProvider.GetUser(username, false).ProviderUserKey.ToString(); try { conn.Open(); cmd.ExecuteNonQuery(); return(NonOpenIdMembershiProvider.DeleteUser(username, deleteAllRelatedData)); } catch (OdbcException e) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(e, "DeleteUser"); } throw new OpenIdMembershipProviderException(e.Message, e.Source, e.StackTrace); } finally { conn.Close(); } }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { SqlConnection conn = new SqlConnection(_connectionString); SqlCommand cmd = new SqlCommand("OpenId_DeleteUserOpenIdLink", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@userId", SqlDbType.VarChar, 255).Value = NonOpenIdMembershiProvider.GetUser(username, false).ProviderUserKey.ToString(); try { conn.Open(); cmd.ExecuteNonQuery(); return(NonOpenIdMembershiProvider.DeleteUser(username, deleteAllRelatedData)); } catch (SqlException e) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(e, "DeleteUser"); } throw new OpenIdMembershipProviderException("DeleteUser failed.", e); } finally { conn.Close(); } }
public TransportMembershipUser GetUserByUsername(string applicationName, string username, bool userIsOnline) { _Provider.ApplicationName = _ApplicationName; var returnUser = ConvertUser(_Provider.GetUser(username, userIsOnline)); return(returnUser); }
public void Non_existing_account_returns_null() { User u = new User() { Username = "******", Password = "******" }; //session and transactions should be handled by provider implementation! MembershipUser u1 = p.GetUser(u.Username, false); Assert.IsNull(u1); }
public bool ChangePassword(string userName, string oldPassword, string newPassword) { if (String.IsNullOrEmpty(userName)) { throw new ArgumentException("Value cannot be null or empty.", "userName"); } if (String.IsNullOrEmpty(oldPassword)) { throw new ArgumentException("Value cannot be null or empty.", "oldPassword"); } if (String.IsNullOrEmpty(newPassword)) { throw new ArgumentException("Value cannot be null or empty.", "newPassword"); } // The underlying ChangePassword() will throw an exception rather // than return false in certain failure scenarios. try { MembershipUser currentUser = _provider.GetUser(userName, true /* userIsOnline */); return(currentUser.ChangePassword(oldPassword, newPassword)); } catch (ArgumentException) { return(false); } catch (MembershipPasswordException) { return(false); } }
public void Exists_UserDoesNotExist_ShouldReturnFalse(FakeMembershipUser user, MembershipProvider membershipProvider, AccountRepository repo) { membershipProvider.GetUser(Arg.Any<string>(), Arg.Any<bool>()).Returns((MembershipUser)null); membershipProvider.GetUser(@"somedomain\John", Arg.Any<bool>()).Returns(user); var context = new FakeSiteContext(new StringDictionary { {"domain", "somedomain"} }); using (new Switcher<Domain, Domain>(new Domain("somedomain"))) { using (new MembershipSwitcher(membershipProvider)) { var exists = repo.Exists("Smith"); exists.Should().BeFalse(); } } }
public void RestorePasswordShouldReturnsNewPassword(FakeMembershipUser user, MembershipProvider membershipProvider, AccountRepository repo) { user.ProviderName.Returns("fake"); membershipProvider.ResetPassword(Arg.Any<string>(), Arg.Any<string>()).Returns("new password"); membershipProvider.Name.Returns("fake"); membershipProvider.GetUser(Arg.Any<string>(), Arg.Any<bool>()).Returns(user); using (new MembershipSwitcher(membershipProvider)) { repo.RestorePassword(@"extranet\John").Should().Be("new password"); } }
public void ExistsShouldReturnTrueIfUserExists(FakeMembershipUser user, MembershipProvider membershipProvider, AccountRepository repo) { membershipProvider.GetUser(@"somedomain\John", Arg.Any<bool>()).Returns(user); var context = new FakeSiteContext(new StringDictionary { { "domain", "somedomain" } }); using (new Switcher<Domain, Domain>(new Domain("somedomain"))) { using (new MembershipSwitcher(membershipProvider)) { var exists = repo.Exists("John"); exists.Should().BeTrue(); } } }
/// <summary> /// If enabled by configuration, tries to login the current membership user (reading cookie / identity) as nearforums user /// </summary> /// <returns>The user id of the authenticated user, if not -1</returns> public static int TryFinishMembershipLogin(HttpContextBase context, SessionWrapper session, MembershipProvider provider, IUsersService service) { if (provider == null || String.IsNullOrEmpty(context.User.Identity.Name)) { return -1; } var membershipUser = provider.GetUser(context.User.Identity.Name, true); return TryFinishMembershipLogin(session, membershipUser, service); }
public void Load(ref Profile person, MembershipProvider provider) { //MemberProfile profile = new MemberProfile(); //profile.Initialize(person.UserName, true); MembershipUser user = !String.IsNullOrEmpty(person.UserName) ? provider.GetUser(person.UserName, false) : provider.GetUser(person.PersonGUID, false); if (user != null) { person.PersonGUID = (Guid)user.ProviderUserKey; person.UserName = user.UserName; person.Comment = user.Comment; person.CreationDate = user.CreationDate; person.RecoveryEmail = user.Email; person.IsApproved = user.IsApproved; person.IsLockedOut = user.IsLockedOut; person.LastActivityDate = user.LastActivityDate; person.LastLockoutDate = user.LastLockoutDate; person.LastLoginDate = user.LastLoginDate; person.LastPasswordChangedDate = user.LastPasswordChangedDate; } }
public void RegisterShouldCreateUserWithEmailAndPassword(FakeMembershipUser user, MembershipProvider membershipProvider, RegistrationInfo registrationInfo, string userProfile, AccountRepository repository) { user.ProviderName.Returns("fake"); user.UserName.Returns("name"); MembershipCreateStatus status; membershipProvider.CreateUser(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>(), Arg.Any<object>(), out status).Returns(user); membershipProvider.GetUser(Arg.Any<string>(), Arg.Any<bool>()).Returns(user); using (new Switcher<Domain, Domain>(new Domain("somedomain"))) { using (new MembershipSwitcher(membershipProvider)) { repository.RegisterUser(registrationInfo.Email,registrationInfo.Password, userProfile); membershipProvider.Received(1).CreateUser($@"somedomain\{registrationInfo.Email}", registrationInfo.Password, Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>(), Arg.Any<object>(), out status); } } }
public void RegisterShouldCreateLoginUser(FakeMembershipUser user, MembershipProvider membershipProvider, AuthenticationProvider authenticationProvider, RegistrationInfo registrationInfo, AccountRepository repository) { user.ProviderName.Returns("fake"); user.UserName.Returns("name"); MembershipCreateStatus status; membershipProvider.CreateUser(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>(), Arg.Any<object>(), out status).Returns(user); membershipProvider.GetUser(Arg.Any<string>(), Arg.Any<bool>()).Returns(user); using (new Switcher<Domain, Domain>(new Domain("somedomain"))) { using (new MembershipSwitcher(membershipProvider)) { using (new AuthenticationSwitcher(authenticationProvider)) { repository.RegisterUser(registrationInfo); authenticationProvider.Received(1).Login(Arg.Is<User>(u => u.Name == $@"somedomain\{registrationInfo.Email}")); } } } }