public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { using (_log.NewTrace()) { //WcfClientUtils.VerifyParameter("username", username); //WcfClientUtils.VerifyParameter("password", password); //WcfClientUtils.VerifyParameter("email", email); //WcfClientUtils.VerifyParameter("passwordQuestion", passwordQuestion); //WcfClientUtils.VerifyParameter("passwordAnswer", passwordAnswer); try { IdentityCreateRequest request = new IdentityCreateRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.Answer = passwordAnswer; request.User = new MembershipUser("scrimpNetMembershipProvider", username, providerUserKey, email, passwordQuestion, "", isApproved, false, DateTime.UtcNow, Utils.Date.SqlMinDate, Utils.Date.SqlMinDate, DateTime.UtcNow, Utils.Date.SqlMinDate); request.Password = password; IdentityCreateReply response = _membershipService.IdentityCreate(request); status = response.CreateStatus; return(response.User); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool ValidateUser(string username, string password) { using (_log.NewTrace()) { //WcfClientUtils.VerifyParameter("username",username); //validate user should not throw an error,simply return false //WcfClientUtils.VerifyParameter("password", password); try { UserVerifyRequest request = new UserVerifyRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken;; request.ChallengePrompt = username; request.ChallengeAnswer = password; UserVerifyReply response = _membershipService.CredentialVerify(request); if (response.Context.IsAuthenticated == true) { _userSecurityToken = response.Context.IdentityToken; return(true); } _log.Warning("User '{0}' is not validated with status '{1}'. {2}", username, response.Status, response.Messages.ToString()); _userSecurityToken = null; return(false); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { WcfClientUtils.VerifyParameter("username", username); WcfClientUtils.VerifyParameter("password", password); WcfClientUtils.VerifyParameter("newPasswordQuestion", newPasswordQuestion); WcfClientUtils.VerifyParameter("newPasswordAnswer", newPasswordAnswer); using (_log.NewTrace()) { try { PasswordQAChangeRequest request = new PasswordQAChangeRequest(); request.NewAnswer = newPasswordAnswer; request.NewQuestion = newPasswordQuestion; request.Password = password; request.UserName = username; request.ServiceSessionToken = WcfClientUtils.SessionToken; PasswordQAChangeReply response = _membershipService.CredentialChangePasswordQA(request); return(response.Status == ActionStatus.OK && response.ResultStatus == true); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override int GetNumberOfUsersOnline() { using (_log.NewTrace()) { try { return(_membershipService.GetNumberOfUsersOnline()); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string[] GetAllRoles() { //using (_log.NewTrace()) { try { RolesGetAllRequest request = new RolesGetAllRequest(); request.ServiceSessionToken = _authenticationKey; return _appService.RolesGetAll(request).RoleNames; } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override void UpdateUser(MembershipUser user) { using (_log.NewTrace()) { try { var request = new UserUpdateRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.User = user; var response = _membershipService.IdentityUpdate(request); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override void CreateRole(string roleName) { WcfClientUtils.VerifyParameter("roleName", roleName); //using (_log.NewTrace()) { try { RoleCreateRequest request = new RoleCreateRequest(); request.RoleName = roleName; request.ServiceSessionToken = _authenticationKey; var response = _appService.RoleCreate(request); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool RoleExists(string roleName) { //using (_log.NewTrace()) { try { WcfClientUtils.VerifyParameter("roleName", roleName); RoleExistsRequest request = new RoleExistsRequest(); request.RoleName = roleName; request.ServiceSessionToken = _authenticationKey; return _appService.RoleExists(request).RoleExists; } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) { using (_log.NewTrace()) { UserGetByProviderKeyRequest request = new UserGetByProviderKeyRequest(); try { request.ServiceSessionToken = WcfClientUtils.SessionToken; request.ProviderKey = new Guid(providerUserKey.ToString()); request.IsOnLine = userIsOnline; var response = _membershipService.IdentityGetByKey(request); return(response.User); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string GetUserNameByEmail(string email) { using (_log.NewTrace()) { // WcfClientUtils.VerifyParameter("email", email); // providers do not validate email try { UsernameGetByEMailRequest request = new UsernameGetByEMailRequest(); request.EMailAddress = email; request.ServiceSessionToken = WcfClientUtils.SessionToken; var response = _membershipService.IdentityGetByEMail(request); return(response.Username); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool UnlockUser(string userName) { using (_log.NewTrace()) { // WcfClientUtils.VerifyParameter("userName", userName); try { var request = new UserUnlockRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.UserName = userName; var response = _membershipService.CredentialUnlock(request); return(response.ResultStatus); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string[] GetUsersInRole(string roleName) { //using (_log.NewTrace()) { try { WcfClientUtils.VerifyParameter("roleName", roleName); RoleGetUsersRequest request = new RoleGetUsersRequest(); request.ServiceSessionToken = _authenticationKey; request.RoleName = roleName; var response = _appService.RoleGetUsers(request); return response.Usernames; } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string[] GetRolesForUser(string username) { //using (_log.NewTrace()) { try { WcfClientUtils.VerifyParameter("username", username); RolesContainingUserRequest request = new RolesContainingUserRequest(); request.Username = username; request.ServiceSessionToken = _authenticationKey; RolesContainingUserReply response = _appService.RolesForUser(request); return response.RoleNames; } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { //using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("roleName", roleName); try { RoleDeleteRequest request = new RoleDeleteRequest(); request.RoleName = roleName; request.ThrowOnPopulated = throwOnPopulatedRole; request.ServiceSessionToken = _authenticationKey; return _appService.RoleDelete(request).ResultStatus; } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override void AddUsersToRoles(string[] usernames, string[] roleNames) { //using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("usernames", usernames); WcfClientUtils.VerifyParameter("roleNames", roleNames); try { UsersAddToRolesRequest request = new UsersAddToRolesRequest(); request.ServiceSessionToken = _authenticationKey; request.Rolenames = roleNames; request.Usernames = usernames; UsersAddToRolesReply response = _appService.RolesAddUsers(request); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("username", username); try { UserDeleteRequest request = new UserDeleteRequest(); request.DeletedRelatedData = deleteAllRelatedData; request.UserName = username; request.ServiceSessionToken = WcfClientUtils.SessionToken; UserDeleteReply response = _membershipService.IdentityDelete(request); return(response.ResultStatus == true && response.Status == ActionStatus.OK); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string[] FindUsersInRole(string roleName, string usernameToMatch) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("roleName", roleName); WcfClientUtils.VerifyParameter("usernameToMatch", usernameToMatch); try { RoleFindUsersRequest request = new RoleFindUsersRequest(); request.ServiceSessionToken = _authenticationKey; request.RoleName = roleName; request.UsernamePattern = usernameToMatch; return(_membershipService.FindUsersInRole(request).Usernames); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override MembershipUser GetUser(string username, bool userIsOnline) { using (_log.NewTrace()) { //WcfClientUtils.VerifyParameter("username", username); //provider should return null if username is null or empty try { UserGetByUserNameRequest request = new UserGetByUserNameRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.UserName = username; request.UserIsOnLine = userIsOnline; var response = _membershipService.IdentityGetByName(request); return(response.User); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override bool IsUserInRole(string username, string roleName) { //using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("username", username); WcfClientUtils.VerifyParameter("roleName", roleName); try { RoleContainsUserRequest request = new RoleContainsUserRequest(); request.ServiceSessionToken = _authenticationKey; request.Username = username; request.RoleName = roleName; var response = _appService.RoleContainsUser(request); return response.ResultStatus; } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string ResetPassword(string username, string answer) { using (_log.NewTrace()) { //WcfClientUtils.VerifyParameter("username", username); //WcfClientUtils.VerifyParameter("answer", answer); try { PasswordResetRequest request = new PasswordResetRequest(); request.PasswordAnswer = answer; request.ServiceSessionToken = WcfClientUtils.SessionToken; request.Username = username; var response = _membershipService.CredentialReset(request); return(response.NewPassword); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("usernames", usernames); WcfClientUtils.VerifyParameter("roleNames", roleNames); try { RolesRemoveUsersRequest request = new RolesRemoveUsersRequest(); request.ServiceSessionToken = _authenticationKey; request.Usernames = usernames; request.RoleNames = roleNames; _membershipService.RolesRemoveUsers(request); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override string GetPassword(string username, string answer) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("username", username); WcfClientUtils.VerifyParameter("answer", answer); try { PasswordGetRequest request = new PasswordGetRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.UserName = username; request.Answer = answer; PasswordGetReply response = _membershipService.IdentityGetPassword(request); return(response.Password); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { using (_log.NewTrace()) { try { UsersGetAllRequest request = new UsersGetAllRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.PageIndex = pageIndex; request.PageSize = pageSize; UsersGetAllReply response = _membershipService.IdentityGetAll(request); totalRecords = response.TotalRecords; return(response.UserList); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public bool UserActivate(string username, string password, string activationKey) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("username", username); WcfClientUtils.VerifyParameter("password", password); WcfClientUtils.VerifyParameter("activationkey", activationKey); try { CredentialActivateRequest request = new CredentialActivateRequest(); request.ServiceSessionToken = WcfClientUtils.SessionToken; request.IdentityPassword = password; request.IdentityName = username; request.ActivationKey = activationKey; return(_membershipService.CredentialActivate(request).IsActivated); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
/// <summary> /// /// </summary> /// <param name="emailToMatch"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRecords"></param> /// <returns></returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="emailToMatch"/> is null</exception> /// <exception cref="ArgumentException">Throw if <paramref name="pageIndex"/> or <paramref name="pageSize"/> is < 0</exception> public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) { //using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("emailToMatch", emailToMatch); try { UsersFindByEMailRequest request = new UsersFindByEMailRequest(); request.EMailPattern = emailToMatch; request.PageIndex = pageIndex; request.PageSize = pageSize; request.ServiceSessionToken = WcfClientUtils.SessionToken; UsersFindByEMailReply response = _membershipService.FindUsersByEmail(request); totalRecords = response.TotalRecords; return(response.UserList); } catch (FaultException <WcfFault> ex) { throw WcfUtils.Extract(ex); } } }
public override bool ChangePassword(string username, string oldPassword, string newPassword) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("username", username); WcfClientUtils.VerifyParameter("oldPassword", oldPassword); WcfClientUtils.VerifyParameter("newPassword", newPassword); try { PasswordChangeRequest request = new PasswordChangeRequest(); request.NewPassword = newPassword; request.OldPassword = oldPassword; request.UserName = username; PasswordChangeReply response = _membershipService.CredentialChangePassword(request); return(response.Status == ActionStatus.OK && response.ResultStatus == true); } catch (Exception ex) { throw WcfUtils.Extract(ex); } } }
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { using (_log.NewTrace()) { WcfClientUtils.VerifyParameter("usernameToMatch", usernameToMatch); try { UsersFindByNameRequest request = new UsersFindByNameRequest(); request.PageIndex = pageIndex; request.PageSize = pageSize; request.ServiceSessionToken = WcfClientUtils.SessionToken; request.UserNamePatter = usernameToMatch; UserFindByNameReply response = _membershipService.FindUsersByName(request); totalRecords = response.TotalRecords; return(response.UserList); } catch (FaultException <WcfFault> fault) { throw WcfUtils.Extract(fault); } } }