As always, we start from where we ended last time, that is aspnet_regsql.exe.
System.Web.Security.SqlMembershipProvider: Provides you with the capability to use the
We have seen how aspnet_regsql.exe looks about. Now time to work around it and probably get into the real task.
There are several server controls which can talk to the Data source. But It needs providers to get works going.
So the things happen like this: server controls interact with the providers to retrieve informations about the users from the Data sources.
ASP.NET 3.5 provides two membership providers out of the box.
membership system to connect to Microsoft’s SQL Server 2000/2005 as well as with Microsoft
SQL Server Express Edition.
System.Web.Security.ActiveDirectoryMembershipProvider: Provides you with the capability
to use the membership system to connect to Microsoft’s Active Directory.
The default provider is the SqlMembershipProvider instance.
//here is the config settings in web.config
//end of the code
Now here in web.config, you can control your provider’s characters, like
minRequiredNonalphanumericCharacters=”1″ could be minRequiredNonalphanumericCharacters=”0″
So that you while registering you need not provide any Ulpha Numeric Character. But always it’s advisable to do that for resisting reverse engineering.
Programmatically today is good. I added user and membership tables using aspnet_regsql.exe in a database. After creating it I connected it through Provider class in web.config.
Next, I created roles programmatically and assign roles to users.
This is great. I wanted to do it for last two three days and failed. But the method is not very difficult at all.
You use a command line code like this:
aspnet_regsql.exe -d -E -A all
pressing enter the required classes(tables) will have added to the database. Now using the proper connection string you can get connected to the database.
The next steps are pieces of cakes as you drag web controls from Login toolbox. The default classes automatically attached and next thing you write down a class which inheriting from SqlProvider overrides the methods to create Roles and assign users to that roles.
Asp.Net ships with plenty of classes that you can use with your classes and create objects accordingly.
This is the greatness of Object Oriented Programming.
I find it Philosophical getting reflections of the real world. Don’t you?