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 6801399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:05:44+00:00 2026-05-26T19:05:44+00:00

I have an ASP.NET web site that will use Active Directory to store Users.

  • 0

I have an ASP.NET web site that will use Active Directory to store Users.
There is a requirement to allow users to use their emails as username.
Active directory will not allow characters like “@” in the usernames.
I created a class to extend the ActiveDirectoryMembershipProvider; It converts usernames from (user@domain.com to user_x0040_domain.com ) before calling the base class functions.
example:

  public override bool ValidateUser(string username, string password)
        {
            string encodedUsername = this.Encode(username);
            return base.ValidateUser(encodedUsername, password);
        }

The Problem is that in the MembershipUser does not allow changing the username.
How can I handle overriding the methods that return MembershipUser?
Like MembershipUser GetUser(string username, bool userIsOnline)

  • 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-05-26T19:05:45+00:00Added an answer on May 26, 2026 at 7:05 pm

    I suppose you could do this overriding the MembershipUser returned by the Active Directory provider, something like this:

    public class MyActiveDirectoryMembershipProvider : ActiveDirectoryMembershipProvider
    {
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            ActiveDirectoryMembershipUser user = (ActiveDirectoryMembershipUser)base.GetUser(providerUserKey, userIsOnline);
            if (user == null)
                return null;
    
            return new MyActiveDirectoryMembershipUser(user);
        }
    
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection newColl = new MembershipUserCollection();
            foreach (ActiveDirectoryMembershipUser user in base.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords))
            {
                newColl.Add(new MyActiveDirectoryMembershipUser(user));
            }
            return newColl;
        }
    
        // TODO: check other methods to override
    }
    
    public class MyActiveDirectoryMembershipUser : ActiveDirectoryMembershipUser
    {
        private string _userName;
    
        public override string UserName
        {
            get
            {
                return _userName;
            }
        }
    
        public MyActiveDirectoryMembershipUser(ActiveDirectoryMembershipUser user)
        {
            // TODO: do your decoding stuff here
            _userName = MyDecode(user.Email);
        }
    }
    

    NOTE: you will need to ensure all methods that return a user are overriden. It also has a some performance impact on collection methods, because you’ll need to duplicate the collection (as I have shown in the sample).

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

Sidebar

Related Questions

I have an ASP.NET web site technology that I use for scores of clients.
I have website that uses ASP.net Membership Provider. This web site will be served
Assume we have an ASP.NET MVC3 Web site that makes use of Entity Framework
I have a asp.net web site that was developed on the .Net Framework v2
I have a web site that runs both classic ASP and ASP.NET Webforms. The
I have a web site in asp.net that uses a master page. In this
I have an asp.net web site which will send several ExecuteNonQuery() statements (stored proc)
I have a Asp.net web site built on C# with Forms Authentication. We use
I have a product admin web site that has been generated using ASP.NET Dynamic
I have an large ASP.Net web application that will have a large number of

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.