Last post Apr 18, 2008 03:07 PM by lokus
Mar 19, 2008 11:21 AM|lokus|LINK
Does anyone know how I could add a few extra fields to the default aspnetdb and use them through the membership provider? For example, I want to use windows integrated authentication in my web app and have it be role based. I, as the admin, will go into
the system, and lookup users that I want to add into a specific role. I want their FirstName, LastName, NT ID(intranet windows nt account name), and email added into the aspnetdb. How would I add these additional fields so that when I add users into roles
that data will be present? Thanks.
Mar 19, 2008 01:21 PM|lspence|LINK
Have a look at the following link. Even though it is about customizing the CreateUserWizard Control it goes over the concept of extending the ASPNETDB with an additional table and fields.
Mar 21, 2008 05:03 AM|Vince Xu - MSFT|LINK
At firstly, pay attention that you can't modify the structure of tables in membership db.
And then there are two approachs can achieve your purpose.
1. Use Profile.(The best approach for you.)
You can define firstname, lastname and NTID as the attributes of users. These attributes called Profile in membership.
Profile in MemberShip is to store the information on users who can be login user or anonymous user. The information will be store in the database.
1). Configure in Web.Config. You can set <anonymousIdentification enabled="true"/> to permit all of the user use profile, and the information of it will be stored in database.
The make-up "allowAnonymous=True" can allow using profile for anonymous user.
<add name="FirstName" allowAnonymous="true"/>
<add name="LastName" allowAnonymous="true"/>
<add name="LastVisited" allowAnonymous="true"/>
<add name="Work" allowAnonymous="true"/>
<add name="Education" allowAnonymous="true"/>
As to login user, you have to use the membership controls, such as Login.
2). Via Profile.FirstName = "username", you can set the value to this profile.
As to retrieving data from profile, you can use this:
Labal1.Text = "First name: " + Profile.FirstName;
Label2.Text = "Work :" + Profile.Work;
Befor that, you have to implement user management by using membership.
You can get more information about profile by using the following link http://www.odetocode.com/Articles/440.aspx
2. You can create some table in membership db in order to extend membership database and set the primary key as UserID which is connected with table aspnet_Users.
But this approach is not secured. My suggestion is if the approch one can't satisfy you, you can use approach two.
Hope it helps.
Apr 17, 2008 05:56 AM|lokus|LINK
Thanks for the response. When I add the properties to the web.config, will asp.net create a new database table for me with the fields listed as the properties in the web.config or do I need to create a new table myself? So basically, where does it store
this data? Keep in mind, there will be no login box as this is Windows integrated authentication. Many times, there is no need to log into Intranet website apps. So what I will be doing is creating a form for the admin to add a user. They will provide their
windows login ID in a text box and hit search. I will then be using a webservice to obtain the other user information such as their FirstName, LastName, Email, Title, PhoneNumber, etc. Once the data is pulled back I would then like to "submit" the information
into the database and assign roles to that user.
Apr 17, 2008 09:38 PM|Vince Xu - MSFT|LINK
The information about Profile will be stored in the database ASPNETDB. You needn't create database. No matter with Windows or Form, it will be worked fine.
Apr 18, 2008 05:18 AM|lokus|LINK
How does it create the related fields in the database, via the SqlProfileProvider?
Apr 18, 2008 06:28 AM|Vince Xu - MSFT|LINK
I think so. And SqlMembershipProvider is for the concomitant membership.
Apr 18, 2008 03:07 PM|lokus|LINK
I just wanted to provide a resource to everyone who may have similar questions to mine. The video is similar to the one posted on ASP.NET but I like their approach. It is from the guys at dotnetrocks. Miguel Castro goes over creating a custom membership
provider in a video. It is definitely worth a look.