Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8911279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:54:10+00:00 2026-06-15T03:54:10+00:00

I want to manage users and Roles in the cliente side, but i cannot

  • 0

I want to manage users and Roles in the cliente side, but i cannot find the way to accomplish this. Links or code will be very appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:54:11+00:00Added an answer on June 15, 2026 at 3:54 am

    Sorry for this abandoned question, i have solved this issue many days ago now, and i fill i should post the answer here because i couldnt find a complete answer in the web and this can help some soul in distress over there. Except for a link that i cannot remember right now but,my apologise to the blog owner for not remember even his name, however, here is the full history:

    First create a class to wrap MembershipUser and another one to wrap MembsershipRole:

        public class MembershipServiceUser
                {
                    public string Comment { get; set; }
                    [Editable(false)]
                    public DateTime CreationDate { get; set; }
                    [Key]
                    [Editable(false, AllowInitialValue = true)]
                    public string Email { get; set; }
                    public bool IsApproved { get; set; }
                    [Editable(false)]
                    public bool IsLockedOut { get; set; }
                    [Editable(false)]
                    public bool IsOnline { get; set; }
                    public DateTime LastActivityDate { get; set; }
                    [Editable(false)]
                    public DateTime LastLockoutDate { get; set; }
                    public DateTime LastLoginDate { get; set; }
                    [Editable(false)]
                    public DateTime LastPasswordChangedDate { get; set; }
                    [Editable(false)]
                    public string PasswordQuestion { get; set; }
                    [Key]
                    [Editable(false, AllowInitialValue = true)]
                    public string UserName { get; set; }
    
                    public MembershipServiceUser() { }
                    public MembershipServiceUser(MembershipUser user)
                    {
                        this.FromMembershipUser(user);
                    }
    
                    public void FromMembershipUser(MembershipUser user)
                    {
                        this.Comment = user.Comment;
                        this.CreationDate = user.CreationDate;
                        this.Email = user.Email;
                        this.IsApproved = user.IsApproved;
                        this.IsLockedOut = user.IsLockedOut;
                        this.IsOnline = user.IsOnline;
                        this.LastActivityDate = user.LastActivityDate;
                        this.LastLockoutDate = user.LastLockoutDate;
                        this.LastLoginDate = user.LastLoginDate;
                        this.LastPasswordChangedDate = user.LastPasswordChangedDate;
                        this.PasswordQuestion = user.PasswordQuestion;
                        this.UserName = user.UserName;
                    }
    
                    public MembershipUser ToMembershipUser()
                    {
                        MembershipUser user = Membership.GetUser(this.UserName);
    
                        if (user.Comment != this.Comment) user.Comment = this.Comment;
                        if (user.IsApproved != this.IsApproved) user.IsApproved = this.IsApproved;
                        if (user.LastActivityDate != this.LastActivityDate) user.LastActivityDate = this.LastActivityDate;
                        if (user.LastLoginDate != this.LastLoginDate) user.LastLoginDate = this.LastLoginDate;
    
                        return user;
                    }
        }
    
    //Roles
        public class MembershipServiceRole {
    
                public MembershipServiceRole() { }
    
                public MembershipServiceRole(string rolename) {
                    RoleName = rolename;
                }
    
                [Key]
                [Editable(true, AllowInitialValue = true)]
                public string RoleName { get; set; }
        }
    

    Second, create a class derived from DomainService to manipulate users and roles wrappers:

    [EnableClientAccess(RequiresSecureEndpoint = false /* This should be set to true before the application is deployed */)]
        public class MembershipService : DomainService
        {
            protected override void OnError(DomainServiceErrorInfo errorInfo)
            {
                TimeoutHelper.HandleAuthenticationTimeout(errorInfo, this.ServiceContext.User);
            }
    
            [RequiresRole("Administrator")]
            public IEnumerable<MembershipServiceUser> GetUsers()
            {
                return Membership.GetAllUsers().Cast<MembershipUser>().Select(u => new MembershipServiceUser(u));
            }
    
            [RequiresRole("Administrator")]
            public IEnumerable<MembershipServiceUser> GetUsersByEmail(string email)
            {
                return Membership.FindUsersByEmail(email).Cast<MembershipUser>().Select(u => new MembershipServiceUser(u));
            }
    
            [RequiresRole("Administrator")]
            public MembershipServiceUser GetUsersByName(string userName)
            {
                MembershipServiceUser retVal = null;            
                retVal =  Membership.FindUsersByName(userName)
                    .Cast<MembershipUser>()
                    .Select(u => new MembershipServiceUser(u))
                    .FirstOrDefault();
                return retVal;            
            }
    
            [Invoke(HasSideEffects = true)]
            public void CreateUser(MembershipServiceUser user, string password)
            {
                if (string.IsNullOrEmpty(user.Email)) {
                    user.Email = "cambiar@dominio.com";
                }
                Membership.CreateUser(user.UserName, password, user.Email);
            }
    
            [RequiresRole("Administrator")]
            public void DeleteUser(MembershipServiceUser user)
            {
                Membership.DeleteUser(user.UserName);
            }
    
            [RequiresRole("Administrator")]
            public void UpdateUser(MembershipServiceUser user)
            {
                Membership.UpdateUser(user.ToMembershipUser());
            }
    
            [RequiresRole("Administrator")]
            [Update(UsingCustomMethod = true)]
            public void ChangePassword(MembershipServiceUser user, string newPassword)
            {
                MembershipUser u = user.ToMembershipUser();
                u.ChangePassword(u.ResetPassword(), newPassword);
            }
    
            [RequiresRole("Administrator")]
            public void ResetPassword(MembershipServiceUser user)
            {
                user.ToMembershipUser().ResetPassword();
            }
    
            [RequiresRole("Administrator")]
            public void UnlockUser(MembershipServiceUser user)
            {
                user.ToMembershipUser().UnlockUser();
            }
    
            #region Roles
    
            [RequiresRole("Administrator")]
            public IEnumerable<MembershipServiceRole> GetRoles() {
                return Roles.GetAllRoles().Cast<string>().Select(r => new MembershipServiceRole(r));
            }
    
            [RequiresRole("Administrator")]
            public IEnumerable<MembershipServiceRole> GetRolesForUser(string userName) {
                return Roles.GetRolesForUser(userName).Cast<string>().Select(r => new MembershipServiceRole(r));
            }
    
            [RequiresRole("Administrator")]
            public void CreateRole(MembershipServiceRole role) {
                Roles.CreateRole(role.RoleName);
            }
    
            [RequiresRole("Administrator")]
            public void DeleteRole(MembershipServiceRole role) {
                Roles.DeleteRole(role.RoleName);            
            }
    
            [RequiresRole("Administrator")][Invoke]
            public void AddUserToRole(string userName, string roleName) {
                if (!Roles.IsUserInRole(userName,roleName))
                    Roles.AddUserToRole(userName, roleName);
            }
    
            [RequiresRole("Administrator")]
            [Invoke]
            public void RemoveUserFromRole(string userName, string roleName) {
                if (Roles.IsUserInRole(userName, roleName))
                    Roles.RemoveUserFromRole(userName, roleName);
            }
    
            #endregion //Roles
        }
    

    Third: Use the service the same way you do for your domains clases
    Cheers!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I now want to manage (create/delete/edit) Users and Roles for my MVC 3
I am using Acl9 to manage the roles and I want to hide the
I am using Devise and CanCan to manage users and user-rights. What I want
I am using Rhino.Security repository to manage my users/roles. The process of creation, deletion
Ok, I have my web application with this web.config for the manage of users
is there a way i can let the admin users of my site manage
I want to manage user and roles in a dedicated application. For example a
I want to make Security authorization management model that can manage all roles and
I want to manage permissions and access to a SQL Server database server on
For my iPhone app, I want to manage values either in NSMutableDictionary or NSMutableAarray

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.