Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
 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 = _membershipService.RoleCreate(request);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 3
0
 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(_membershipService.RoleExists(request).RoleExists);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 4
0
 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 = _membershipService.RoleGetUsers(request);
             return(response.Usernames);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 5
0
 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 = _membershipService.RolesForUser(request);
             return(response.RoleNames);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 6
0
 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(_membershipService.RoleDelete(request).ResultStatus);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 7
0
 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);
         }
     }
 }
Ejemplo n.º 8
0
 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 = _membershipService.RolesAddUsers(request);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 9
0
 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);
         }
     }
 }
Ejemplo n.º 10
0
 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);
         }
     }
 }
Ejemplo n.º 11
0
 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 = _membershipService.RoleContainsUser(request);
             return(response.ResultStatus);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
Ejemplo n.º 12
0
 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);
         }
     }
 }
Ejemplo n.º 13
0
        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);
                }
            }
        }
Ejemplo n.º 14
0
        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);
                }
            }
        }