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 ([email protected] 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)
I suppose you could do this overriding the MembershipUser returned by the Active Directory provider, something like this:
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).