Changing asp.net membership configuration - asp.net

I have created an ASP.NET site on Visual Studio 2010. Membership tables are coming automatically. On the "register.aspx" page, there are only three fields which are user name, email address and password. But in the register step, I want member to give me more information about himself such as name, surname, city, grad school and so on... I have added extra textboxes to the page and corresponding fields to table "aspnet_Membership".
After a little bit browsing the codes, I have found the providers section in "web.config" file. And I tried to add some parameters for my specific fields. But it did not work.
What if I need to add more data fields to membership table? For example I need to know the city the member lives. What can I do for this circumstance?
The membership node of web.config is the following:
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/"
/>
</providers>
</membership>

You could extend the built in MembershipUser and add custom fields.
Then you need to create a table to store the information and at last you need to create a custom membership provider.
More information at msdn: How to: Implement a Custom Membership User

Related

Cant see my membership provider in aspnet tools

i am just creating a aspnet MVC 4 basic application with custom membership provider.
I follow these steps:
1) Create the membership tables in the Sql Server 2008 using aspnetregsql.exe
So i have the custom membership tables like:
aspnet_Users
aspnet_Membership
aspnet_Roles
...
2) Added a connection string refering to this database.
3) Added a provider in my web.config file inside the membership section:
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="primecontrol" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10" applicationName="/" />
So, when I run the ASP.NET configuration Tools and go to test my provider connection, it says that i dont create any providers.
But if i create a new user for example, it creates another tables in my database without the 'aspnet' prefix.
Whats going on?
i am just creating a aspnet MVC 4 basic application with custom
membership provider.
In the web.config, I do not see declaring custom membership provider.
It should be like -
<membership defaultProvider="CustomProvider">
<providers>
<clear/>
<add name="CustomProvider"
type="YourNamespace.YourMembershipProvider, YourNamespace"
... />
</providers>
</membership>
If you using ASP.Net MVC 4, you want to use new ASP.NET Universal Providers which is basically a newer version of Legacy Membership Provider that you are using.
ASP.NET Universal Providers uses Entity Framework Code First which is a lot cleaner compare to store procedures.
If you want to latest Membership, you might want to try ASP.NET Identity. Note: Identity is not backward compatible with Legacy Membership Provider.

Aspnet web site administration tool, Users table or aspnet_users table

Why do my users and roles end up in Users and Roles tables and not aspnet_users and aspnet_roles?
When I use the Aspnet web site administration tool (visualstudio->menu->project->aspnet configuration to add a user it ends up in the Users table; and new roles in the Roles table.
Everything I have read on the subject says aspnet_users and aspnnet_roles.
I am using aspnetmvc4 (beta), sqlserver2008r2, visualstudio2010. I have created the aspnet_xxx-tables in the database through aspnet_regsql.exe. I sniff sqlserver and get queries against Users and Roles. It even creates an Applications table.
As per request, the membership part of web.config:
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<clear />
<add connectionStringName="DefaultConnection" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/"
name="DefaultMembershipProvider"
type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</membership>
Old school ASP.NET 2.0+ providers (System.Web.XXX.SqlXXXProvider)
--> Uses the aspnet_Users and aspnet_Roles tables, via stored procs.
The new Universal Providers (System.Web.Providers.XXX)
--> Uses the Users and Roles tables, via (EF-generated?) SQL.
More info here (from Mr Scott H):
http://www.hanselman.com/blog/IntroducingSystemWebProvidersASPNETUniversalProvidersForSessionMembershipRolesAndUserProfileOnSQLCompactAndSQLAzure.aspx

Create a brand new custom membership provider and authenticate from that

I have to develop a brand new custom membership provider(MyCustomProvider) in which i have to implement all the methods like validate user, CreateUser and all other and use this membership provider as authentication mechanism for my sharepoint site. I have implemented it completely. Now i am left with using it for authentication. I want to know how to proceed further.
After implementing your Provider you just set it up in the web.config:
<configuration>
<system.web>
<membership defaultProvider="MyCustomProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="MyCustomProvider" type="My.Namespace.MyCustomProvider" connectionStringName="myConnStr"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="MyApp" />
</providers>
</membership>
</system.web>
</configuration>
Then you can use Forms Authentication, Login Controls and all the other cool features.
Also check out this MSDN example for custom Membership Providers
I suggest you to read - Examining ASP.NET's Membership, Roles, and Profile

custom Membership provider

I am new in ASP I am doing a web Site with a custom Membership provider, because I don't need a BBDD to save my user only XMLFile.
I am folling this example
http://madskristensen.net/post/XML-membership-provider-for-ASPNET-20.aspx
but now I don't Know, how to create my logon method to comunicate with my custom MembershipProvider.
There are any examples o documentations to learn about this.!!!!
Thanks a lot!!!
If you create a new ASP.NET MVC 3 Web Application it will contain an AccountController an related Account views that should work with your custom membership provider.
The only change you should need to make is to change the "type" to your custom provider in the membership section of the web.config (see sample below):
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="MY.CUSTOM.MembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>

asp.net membership select provider

I've done this before but can't remember how for the life of me. I used aspnetreg_sql.exe to create the membership tables in my database. But now i cant seem to be able to point my web app to the correct database. In the provider settings in asp.net management interface i only see a radio button with the label "AspNetSqlProvider" but I can only test it (in which it always fails). I can't modify the connection. Can someone help me with this?
Cheers,
Billy
The membership provider needs to clear the existing result and add in the new result with the new connection; the default uses the local sql server.
<membership defaultProvider="p">
<providers>
<clear />
<add name="p" type="System.Web.Security.SqlMembershipProvider" connectionStringName="myConnectionString" ... />
</providers>
So the keys here is to clear the existing provider, setting the default provider to the name of your entry, and adding a new entry with the in-built membership provider that points to your DB.
Look for something like this in the web.config:
<membership defaultProvider="AspNetSqlProvider" userIsOnlineTimeWindow="15">
<providers>
<add name="zzz" type="System.Web.Security.SqlMembershipProvider" connectionStringName="appServicesConn" applicationName="zzz" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" minRequiredNonalphanumericCharacters="0" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" passwordAttemptWindow="5" passwordStrengthRegularExpression="" passwordFormat="Hashed" />
</providers>
That should point you to the connection string.
The connection information should be in the web.config file under the <connectionstrings> section.

Resources