Help with Implementing custom MemebershipProvider
-
I needed to implement a custom MembershipProvider cuz we already have a database with user information in it; also I need to get a list of users. In my DAL I have a method that I can call which will populate the business entity and returh a List<>. However since I am using MembershipProvider I thought I should use the Memebership.GetAllUsers() method to do the same.
Do you think that the following implementation is acceptable or is it a programming NO NO...?
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
List<UsersEntity> users = DAL.GetUsers();
foreach(UserEntity user in users)
{
MembershipUser members = new MembershipUser(this.Name,
user.username,
user.providerUserKey,/*I dont have this in my database*/
user.email,
user.passwordQuestion,
user.comment,/*I dont have this in my database*/
user.isApproved,/*I dont have this in my database*/
user.isLockedOut,
user.creationDate,
user.lastLoginDate,
user.lastActivityDate,
user.lastPasswordChangedDate,
user.lastLockedOutDate/*I dont have this in my database*/);}
}
Can you tell me what I need to to do about the fields that I donot have in my database? Do I need to update the database? or should I just pass in a null or String.Empty or something like that? Please help.
-
I needed to implement a custom MembershipProvider cuz we already have a database with user information in it; also I need to get a list of users. In my DAL I have a method that I can call which will populate the business entity and returh a List<>. However since I am using MembershipProvider I thought I should use the Memebership.GetAllUsers() method to do the same.
Do you think that the following implementation is acceptable or is it a programming NO NO...?
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
List<UsersEntity> users = DAL.GetUsers();
foreach(UserEntity user in users)
{
MembershipUser members = new MembershipUser(this.Name,
user.username,
user.providerUserKey,/*I dont have this in my database*/
user.email,
user.passwordQuestion,
user.comment,/*I dont have this in my database*/
user.isApproved,/*I dont have this in my database*/
user.isLockedOut,
user.creationDate,
user.lastLoginDate,
user.lastActivityDate,
user.lastPasswordChangedDate,
user.lastLockedOutDate/*I dont have this in my database*/);}
}
Can you tell me what I need to to do about the fields that I donot have in my database? Do I need to update the database? or should I just pass in a null or String.Empty or something like that? Please help.
Hi, you can provide any value to the fields to the Fields that u dont have in your database or you can leave them blank by assigning null or string.empty or any default value. But be sure that you r not going to use these fields anywhere in your application. I hope this will help you.
Thanks and Regards, Chetan Ranpariya