asp.net membership select provider - asp.net

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.

Related

How to I connect to ASPNETDB.MDF via webconfig?

I have a database in my App_Data that was created automatically by the system when I incorporated Membership and Role Manager and Profile into my web application.
The problem is there is no connectionstring for ASPNETDB, it wasn't created by the system. I assume it stored elsewhere, I've a feeling machine.config.
I have detacted this database from app_data and reconnected and store it in my SQL SERVER 2008.
How to I connect to it via Webconfig.sys to get my Application services working?
Regards,
Tea
I copied what was in machine.config under <provider>, <roleManager> and <Profile>. Added a connection string. Worked!
<system.web>
<membership defaultProvider="Pragatee_MLM_MamberProvider"> <providers> <add connectionStringName="ConnectionPragatee" enablePasswordRetrieval="false"
enablePasswordReset="true" applicationName="PragateeMLM" requiresUniqueEmail="true" passwordFormat="Hashed" name="Pragatee_MLM_MamberProvider" type="System.Web.Security.SqlMembershipProvider" /></providers></membership><roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="Pragatee_MLM_RoleProvider"><providers><add applicationName="PragateeMLM" connectionStringName="ConnectionPragatee" name="Pragatee_MLM_RoleProvider" type="System.Web.Security.SqlRoleProvider"/></providers></roleManager></system.web>

Changing asp.net membership configuration

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

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>

Using one Asp.net Membership database with multiple applications Single Sign On

I have two asp.net applications on one IIS server and I would like to use the same back end asp_security database and membership provider. I've read that all I have to do is reference the same application name in both web configs as I'm doing now, but I must be doing something wrong
In each applications web.config I have this section.
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="membership"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
/>
</providers>
</membership>
When I log in from application A and browse to application B application B doesn't seem to know anything about me or my credentials from application A. Anyone have any ideas what I'm doing incorrectly?
Just for closure sake I will answer how I did achieved the goal of what my original question meant to ask for.
I had two asp.net applications on one IIS server. It was my goal to make it so when user logged onto app1 their user credentials would be available in app2. Configuring the asp.net membership provider is only one step of what I was looking for. Even if both apps were using the same back end database and provider I still wouldn't be authenticated when I hit app2. What I was looking for was a Single Sign On solution.
Once you have both apps pointing at your asp_membership database by placing the following in the system.web section of your web config
<authentication mode="Forms" />
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="membership"
applicationName="/"
/>
</providers>
</membership>
<roleManager enabled="true" />
make sure both have the same applicationname property set.
I was using IIS 6 so I configured it to autogenerate a machine key for both applications. Because both of these applications live on the same machine the key would be identical, this is the critical part to making the SSO work. After setting up IIS the following was added to my web.config
<machineKey decryptionKey="AutoGenerate" validation="SHA1" validationKey="AutoGenerate" />
That was all there was to it. Once that was done I could log into app1 and then browse to app2 and keep my security credentials.
Thanks for the push in the right direction.
If my understanding serves me correctly, the users authentication credentails are stored within the HTTP context of each application. So switching between the two applications will not automatically authenticate the user, since a new context will be created when you switch to app B.
What I believe may the correct approach would be to use the DefaultCredentials (or UseDefaultCredentials property to True) of the current user prior to switching to app B.
When you say switch what do you mean eg. open a different browser window and access app B or request a page from appB from appA?

Resources