.net - Fine Tune A Membership Provider?

Apr 30, 2010

After all the answers to my last question about fine-tuning turned out to be more useful than I expected, I thought that I would ask another similar Question about the MembershipProviders as well.

Okay, so firstly, to clarify: I know what a Membership, Role, and Profile provider is, how to implement my own, and how to configure them, and most of the things about them. Implementing a role and profile provider is pretty straightforward, because they only require simple CRUD most of the time. (A single line of LINQ is enough for about half of the RoleProvider's methods.)

However, the Membership provider is a differend beast. Many of you may realize that it violates the SR (Single Responsibility) principle, because it has to do EVERYTHING related to user management. While this leaves a lot of room for customizations, it has its downsides as well. There is no information on the Internet about what their EXACT expected behaviour is, such as when should they throw exceptions or simply return null, and stuff like that.

I use this sample implementation for reference, but it also contains several contradictions.

For example, it uses its own ValidateUser method for checking for credentials in the ChangePassword method. But the ValidateUser also updates the user's LastLoginDate to the current date. So, does the framework expect that I set it in my own provider as well, or is it simply a mistake in the sample? The other is: the ChangePassword method throws an exception every time when validating the new password, but CreateUser doesn't ever throw an exception, it simply returns false. And last, but not least: it counts the invalid password attempts of the user and locks them if it passes a threshold. While this is good, but it requires manual action to unlock the users. Is it a problem if my provider automatically unlocks the user after a certain amount of time? (EDIT) I almost forgot: the CreateUser method in the sample inserts the ID from the method parameter. I actually think this is bad practice, because I use inters with auto incement as IDs, so inserting them from some method parameter is not an option. Should I just ignore the parameter, or require that its value is null and throw an exception if it isn't?

All in all, does ASP.NET have any assumptions about the behaviour of a MembershipProvider? Is there any documentation which describes when should I throw an exception or just return null?

I also tried to find a set of generic unit tests which would provide some guidance about the expected behaviour, but no luck, I found plenty of articles about "Unit testing is good", and "How to unit test a MembershipProvider", but not one where there would be any actual tests.

View 1 Replies


Similar Messages:

VS 2008 Implement Custom Role Provider And Membership Provider

Sep 27, 2010

I have watched the how to video on Creating a Custom Membership provider. So far it works great. My login control interacts well with it etc. Now i've created a Custom Role Provider. I've created a class that inherits the RoleProvider base class and i've added code to each Sub. My question is, what is the best way to implement the role provider, considering I get the Roles etc from the database?

View 11 Replies

Security :: Forms Authentication With AD Membership Provider And SQL Role Provider?

Jul 27, 2010

I am trying to build an application that

1. user can login by their AD account and password.

2. AD account can be assigned to different group.

I know there is a training video - [URL] to teach how to use the tool to provision the membership schema to SQL server for Forms authentication. but how can I use AD authentication with this?

View 1 Replies

Security :: Implement custom Role Provider And Membership Provider?

Dec 1, 2010

i have implemented custom role provider and membership provider .

login page : SignIn.aspx

on successful login it redirects to (index-Homepage.aspx)

now PROBLEM is when it successfully logged in ,and redirects to 'index-Homepage.aspx' it gives Anornymoustemplate ..while its verifying the role correctly in index-Homepage.aspx.cs

View 1 Replies

Security :: Difference Between Role Provider And Membership Provider?

Dec 1, 2010

1 - whats the difference between Role Provider and Membership provider ??

2- If we implement Custom Role Provider or Custom Membership provider then what does this means ? and which Provider do we use when we apply custom role provider or custom membership provider

View 4 Replies

Security :: Big Extension Of Membership Provider - Should Use A New Custom Provider

Mar 27, 2010

i'm building an application and i need to manage roles, users and more things so i tought to use the membership provider but i have some questions about it: can i full extend it and can i override the functions to use a database table to store infos about config or i need to build my own provider?

View 4 Replies

Net SQL Membership Provider Custom Provider Property

Dec 16, 2010

<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
<properties>
<add name="FirstName"/>
<add name="LastName"/>
</properties>
</profile>

I have the code snippet above in my webconfig file. I am attempting to set the FirstName property in codebehind on a register.aspx page. Like this:

Profile.FirstName = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("FirstName")).Text;

VS says Profile is in System.Web.Profile Namespace. I then use it like this "System.Web.Profile.FirstName", but says first name does not exist in System.Web.Profile.FirstName namespace.

How do I set the property and later retrieve it?

View 3 Replies

Security :: Aspnet Sql Membership / Running On XP IIS Just Fine?

Feb 23, 2010

I have an asp.net site running on XP IIS just fine, with login using aspnetdb. However, I wrote a page that has a datasource that connects to the same db, with a gridview that displays users. I've done this before on 2003 server iis 6 no problem. Here I get,

Cannot open user default database. Login failed.Login failed for user (domainusername)This is the identity I set in IIS 6.0 under authentication methods for anonymous access. I had to do this because the site connects to a remote accessdb as well. I cant use a local account or aspnet account.I dont understand how I can use the same site to login and out, but not to access this page.This is my asp.net conection string

data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;user instance=true

The web config has this:

<
add
name="ASPNETDBConnectionString"
connectionString="Data
Source=.SQLEXPRESS;AttachDbFilename=C:InetpubwwwrootApp_DataASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=true"
providerName="System.Data.SqlClient"
/>

Thats what the data source uses.Go figure when I remove and add again integrated security true, I can see the page. WHY I DONT KNOW!!!! But I also call membership.deleteuser() with a delete button, NOW THIS FAILS!Cannot open user default database. Login failed.Login failed for user '(computername)ASPNET'.

View 4 Replies

Security :: Membership.getuser() Returns Null In Ff And Chrome But Works Fine In IE

Mar 29, 2010

I have strange problem with the membership provider on my mvc application.

I have a webforms page inside admin folder which calls the following code in the models directory.

public int SaveUploadedFile(HttpPostedFileBase fileBase)

View 2 Replies

Security :: Custom Membership Provider Error "Could Not Load Type Custom.AspNet.Membership.PostPropertyProvider"

Jan 5, 2011

This is my first membership provider; I converted the sample provider [URL] to SQL. I created a vb class provider and put it into the App_Code folder. After it was created I tried to modify my webconfig but the error pops up. I don't know what else to try, I don't know if I have missed something

webconfig:

[code]....

View 1 Replies

C# - Use Membership Provider To Set Role?

Mar 4, 2011

I am building my first asp.net app from scratch. I have two different membership providers. One is a basic sql provider while the other is active directory. The user "role" is determined by how the user logs in. I want to use the Role Manager functionality of asp.net but I don't want to build the whole role provider part when I really don't have "roles" in my application, I have two membership types.

Is there a way to set the role of the user through the membership provider at login or in some way mark a logged in user as having been authenticated by sql or AD?

This is my first asp.net app, am I even thinking about this the right way?

View 2 Replies

Custom Membership Provider For Asp.net Using C#?

Jun 11, 2010

How i can realise my own Membership Provider for my social network example project where i want to use more extended registration with new fields?

View 3 Replies

Security :: SQL Membership Provider Using .NET 3.5 C#?

Dec 13, 2010

I am using SQL Membership Provider to create user accounts for my web site and for some reason, the CreateDate and LastLoginDate fields are NOT saving the current time of my machine when I add a new user to the website. It is showing the previous day's date and the time is displayed as PM when it's AM and vise-versa in the CreateDate and LastLoginDate fields in aspnet_Membership table. I am developing and running the website via localhost on my laptop using IIS 7 (Windows 7). Does this have anything to do with my laptop's clock settings or is there something I need to configure in the web.config file or in IIS.

View 4 Replies

C# - Why Membership Provider Is Not Generic

Apr 10, 2010

The default implementation is not very appropriate normally and I haven't seen so far a good implementation of a custom membership provider, probably because this is not possible.

View 1 Replies

C# - Membership Provider Class?

Jan 26, 2010

I want to know how I can implement membership provider class to have ability to remember users who signed in. I have Membership provider class and I need functionality of "Remember Me" checkbox but I don't know how I can implement some methods

View 3 Replies

C# - How To Use Membership Provider Class

Jan 15, 2011

i want to use asp.net membership provider for my own database i have own table here is what have i done i extended the membership provider class with my own write all overided methords. is it right way to use membership provider class for custom use?? i also extend the rolemanagement class too.

View 2 Replies

MVC And Custom Membership Provider?

Mar 22, 2011

i am planing an application that needs to handle different client logins. A user should be able to login under each clients url.The project will have a start page and multiple (database generated) client URLs.www.domain.com/ClientA www.domain.com/ClientB www.domain.com/ClientC
I failed using MVC Routes to build up such a scenario with dynamically clients so i used an MVC area for the client space:www.domain.com/clients/ClientA www.domain.com/clients/ClientB www.domain.com/clients/ClientC Is there any client support for membership providers? All i found is made for a single client environment. I would love to take advantage of the mvc buildin attributes for authentication..

View 2 Replies

Use MemberShip Provider With EF Code First?

Jan 23, 2011

I have models based on EF Code First and I want to use them with default MembershipProvider, but I don't know how to write model correctly, so it will don't erase all my data on recreating tables when there were made changes to model.

View 3 Replies

MVC And ASP Membership Template Provider?

Mar 19, 2010

In a standard ASP.NET MVC template application that is created by default in Visual Studio when starting a new ASP.NET MVC application there is already a built-in membership / authentication / authorization system.

Using web search one can find lots of info about how to work with a built-in ASP.NET membership system, but very often this material is a bit of an old and refer to ASP.NET only, not mentioning ASP.NET MVC framework.

Just for example:
http://msdn.microsoft.com/en-us/library/ms998347.aspx#paght000022%5Fmembershipapis
or http://www.4guysfromrolla.com/articles/091207-1.aspx

To what extent all that applies to ASP.NET built-in membership system applies also to ASP.NET MVC ready template membership system?

View 2 Replies

Membership Provider Deployment?

Jan 4, 2011

I am trying to deploy a asp.net mvc site. My hosting service provider provides me dsn database connection for my sql server 2008 database. I changed my web.config to use dsn connection using this modification in web.config.

<appSettings>
<add key="myDSN" value="evdsn"/>
</appSettings>

In my site I have used asp.net membership provider. I have all the tables of membership provider in my own database. when I deploy the site I get the following error:

My web.config file is as follows
<?xml version="1.0" encoding="UTF-8"?>
<!--

Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in

WindowsMicrosoft.NetFrameworkv2.xConfig
-->
<configuration> [code]....

View 3 Replies

How To Localize Membership Provider In WPF Application

May 10, 2010

We are using ASP.Net Membership provider for user management module in our WPF based application. It seems to be working fine. But now we want to localize our WPF application, and don't know how to do that with respect to the data stored as part of Membership Provider. Is Localization supported by Membership Provider ?

View 2 Replies

LastActivityDate Custom Membership Provider

Feb 12, 2010

When is the LastActivityDate supposed to be updated? When I click on any other pages in my web application as an authenticated user, the LastActivityDate does not get updated.

I would imagine it should be updated when a user clicks on any page, whether it be to do with membership (change password, GetUser(), etc) or not. But the examples that I have seen, seem only to update it on ValidateUser().

http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.lastactivitydate.aspx

Under Remarks, it says to do it under ValidateUser method.

When do you update the LastActivityDate? Just inside ValidateUser()?

Update: Clarified question.

View 1 Replies

C# - 4 Custom Membership Provider Tables

Apr 3, 2011

Now this might just be straightforward, but I can't seem to figure it out..

I have set up the Custom Membership provider, and gave it the proper connection stuff.
What I know is that it connects to the correct database, but I know for sure that it doesn't look at the correct table.

How would I set it up to use a specific table? As the table already has users in them.

The table name is: members_info.

the column names are: member___id(key), member_name, member__pwd, member_perm

member___id => Being the Key and the account name to login with
member_name => Being the users Name or Nickname
member__pwd => 10 chars long (for now)
member_perm => holds 1 of the following values: 0) User 1)Admin 2)Banned


now I know that the later one is to be setup by the Role Provider, and I'm sure once I know how to do the membership one that one is similar in some way.

So my question is, how do I point the Custom Membership Provider to the table: members_info and to use member___id for username, members__pwd for password (and possibly get member_name out to say: Welcome {member_name}! when they login).

===

Added info.
Members__uid is the key value as it increases on each new entry.

===

Since you can't tell it to use a specific table

How can I set it up so, that it works with the tool provided in visual studio? (Website > ASP.net Configuration).

As it now says 0 users, on the security tab. I want to be able to manage the users through here too.

View 1 Replies

MVC :: What Is The Database Used By The Default Membership.provider

Aug 3, 2010

When a user is registered in an MVC application using the default Register action of the Account controller, where is the user info stored? Can I specify that this user table be stored in the database of the MVC application?

I am reading about writing a custom membership provider. I want to have some linkage between application specific user info ( current orders, items the user has ordered ) and the login database. I want to hook the "register a new user" process so that a new customer is added to the customer master.

View 3 Replies

C# - Using Session Variable With .Net Membership Provider

Sep 2, 2010

I m using the Asp.net membership provider with my web application !I would like to know how to get the user ID and How and Where can I add code to the application to set same session variable On the User log on !

This is the scenario ,The user Logon,I catch his ID an the database,I execute some query to set same session variable with data in relation with this user : Like name and other stuff from other table in relation with the user table !According to user data(role and other stuff), I redirects it to his own view or page.

PS :The membership system are using his own database : ASPNETDB.mdf !
PSS: I m using C sharp !

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved