R
Rafia Tapia
Hi,
I have added couple of fields in the membership table. I want to expose
those additional fields through membership user. I understand that I need to
provide my own implementation of membershipprovider and membershipuser
class. Since the sqlmembership provider provides most of the functionality I
need, I thought of using a sqlmembership provider internally within my
custom provider to provide lot of the implementation. So my code is
class MyMemberShipProvider : MembershipProvider
{
private SqlMembershipProvider _DefaultSqlProvider;
// I then implement the abstract methods of MembershipProvider by simply
calling sqlmembershipprovider function so for instance my implementation of
change password is
public override bool ChangePassword(string username, string oldPwd,
string newPwd)
{
return SqlProvider.ChangePassword(username, oldPwd, newPwd);
}
//I have also implemented the initialize method as
if (config == null)
throw new ArgumentNullException("config");
if (name == null || name.Length == 0)
name = "MyMembershipProvider";
if (String.IsNullOrEmpty(config["description"]))
{
config.Remove("description");
config.Add("description", "Custom Membership provider");
}
// Initialize the abstract base class.
base.Initialize(name, config);
SqlProvider = new SqlMembershipProvider();
SqlProvider.Initialize(name, config);
}
but now I get an error that the provider name cannot be null or empty. Can
anyone please tell me what I am doing wrong. Also is my approach the correct
way of exposing some couple of additional fields in the database membership
table
I have added couple of fields in the membership table. I want to expose
those additional fields through membership user. I understand that I need to
provide my own implementation of membershipprovider and membershipuser
class. Since the sqlmembership provider provides most of the functionality I
need, I thought of using a sqlmembership provider internally within my
custom provider to provide lot of the implementation. So my code is
class MyMemberShipProvider : MembershipProvider
{
private SqlMembershipProvider _DefaultSqlProvider;
// I then implement the abstract methods of MembershipProvider by simply
calling sqlmembershipprovider function so for instance my implementation of
change password is
public override bool ChangePassword(string username, string oldPwd,
string newPwd)
{
return SqlProvider.ChangePassword(username, oldPwd, newPwd);
}
//I have also implemented the initialize method as
if (config == null)
throw new ArgumentNullException("config");
if (name == null || name.Length == 0)
name = "MyMembershipProvider";
if (String.IsNullOrEmpty(config["description"]))
{
config.Remove("description");
config.Add("description", "Custom Membership provider");
}
// Initialize the abstract base class.
base.Initialize(name, config);
SqlProvider = new SqlMembershipProvider();
SqlProvider.Initialize(name, config);
}
but now I get an error that the provider name cannot be null or empty. Can
anyone please tell me what I am doing wrong. Also is my approach the correct
way of exposing some couple of additional fields in the database membership
table