Two Different Membership Providers On The Same Web-solution
Jan 17, 2011
I have built two websites, both of them use a custom membership provider I have written myself.
One of these sites is already a long time online and runs fine. Now I have installed the other site on the same webserver in the same Web as a different application. Also have I given a seperate ApplicationPool for each solution.
If now the client logs on to one site, he looses the session on the other and vice versa. It's not possible to be loged on on both sites together. All the rest works fine.
What is the connection between the two sites. Is it necessary to change something in my membership providers?
Our site has got two ASP.NET membership providers. The built in one, and a custom one (SqlMembershipProvider.
I am able to log into both no problems, but I don't necessary require the ability to have both logged in at the same time.
The issue I have is as follows:
User "person_a@site.com" logs into the built in provider. They then navigate to the section of the site where we require the custom provider.
On this page, I can check if they are authenticated, and get their username. I can then get a MembershipUser object form the custom providers GetUser method. (HttpContext.Current.User.Identity.Name)
It is possible (and very likely) that the username "person_a@site.com" could also exist in the users for the custom provider.
But, I don't want them to be logged in here, as they haven't authenticated against the custom provider.
So, is it possible to check which proivider HttpContext.Current.User was generated from.
I'm trying to use both the default Membership and Profile Providers and can not for the life of me get both to work at the same time. I'm using MS Visual Web Developer 2010 Express and when I create a new Project I get access to the Membership but not the Profile. When I create a new Website I get just the opposite i.e. access to Profile and not Membership. What do I need to do to get access to both?
Using the a Membership provider and the MVC framework, is it possible that routes are dynamically changed so that a already logged in user goes to his own page, rather than the default.
At the moment I go to the default. If the user is already logged in or not, there I do a redirect to their own page. This can't be the correct way! Can it?
In RegisterRoutes I have this
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } );
I know this question is asked (and answered) a lot already, but I believe my situation is unique.
We are using the ASP.NET SqlMembershipProvider. However, we also have some less-secure content we would like to secure by adding users directly to the web.config, like so...
Is it possible to use this method alongside a SQL Membership Provider? If so, how?
I know it's bad practice to do this. This is only a stepping stone as we move parts of our website into the asp.net application. We would like some of those password to be easily editable without going to the database.
I am writing a login routine that uses a .NET login control and I have a membership provider as well and set it all up in the config file. But I don't plan on using a connection string as I will be calling a web service in my ValidateUser function. Do I need the connection string in the config because it seems to throw an error if I don't have it.
In that case if you need it then wouldn't it be better to treat this membership provider class more as a normal class and just make calls to it directly like any class and not put any setting on my login control and remove the entry from my web.config
In my web application am using ASP.Net Membership for authentication ann role management.But now i have a situation where i need to authenticate multiple clients against different DB based upon the URL request being send. Below is my web.Config Details.
Am using form authentication for user authentication. In my login page am using Membership.ValidateUser(username,password),which is using default membership provider. Now my situation is i need to override the default DB and connect to multiple DB based on URL request send to my web server.
I'd like to know if its possible to use two membership providers within a single application. I need to have a membership provider "power users" and administrators on a site and a different one for clients and customers who will want to register on the site. I'd like to know if its possible to have two different membership providers to handle these two different sets of users. If it is, how do i go about it?
I'd like to know how membership providers works under the hood, if it uses cookies, session, the principal and identity thread objects, etc.. etc.. where can I find information?
(I have created runproviders.sql with my Visual Studio x64 Win64 Command Prompt (2010) )
Still now working...
Every time I run ASP.NET Configuration -> Provider -> Select a single provider for all site management data and TEST for
AspNetSqlProvider
I get the following error every time :
"Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider."
I can tell you for sure that my new created database is working because i used a web page with a CreateUserWizard1 control and I can create new users.Even I can see the new creted user with ASP.NET Configuration -> Security.
I am new to using the membership provider. I have been working in a small shop that has very focused programming and we are starting to venture out as our needs have grown. My question is the following:
Once I have created the asp schema and I set up users. How do I perform database access using those user accounts? I know how to perform access using a database account (schema), but do not understand how to use a user that only exists in a user table to access data tables.
Do I use an anonymous account and control access on the front end?
I have created two custome membership providers that I would like to add to my web.config. The first one would be the default that the asp.net application would use. The second would be called by a WCF service that I have in the same application.
The providers in the membership section of my web.config looks like the following:
To begin with I work on the large application, that has a WinForms client and server. Server in our case is the set of WCF services. There is one service that is responsible for authentication of users. The logic of authentication is custom and complex and authentication service uses different membership providers.
We want to protect the access to server services for non-authenticated users. The users must firstly authenticate and than use other services (users in this case are the other systems, services, WinForms client, etc.). On this basis, we decided to use the ASP.NET Url/File Authorization feature.
So, I set on the ASP.NET compatibility mode, allowed cookie in all binding configurations, added AspNetCompatibilityRequirements attribute to our services and added the followingconfigurations to config:
In the authenticate method of our authentication service I add the following code: public AuthenticationResult AuthenticateUser(string username, string password) { AuthenticationResult result = new AuthenticationResult(); result = Authenticate(username, password); if (result.IsAuthenticated) FormsAuthentication.SetAuthCookie(username, true); return result; }
Next, I wrote the following code:
var authClient = new AuthenticationServiceClient(); var result = authClient.AuthenticateUser("user", "password"); var otherClient = new OtherServiceClient(); var temp = otherClient.DoSomething();
But after authentication I can't access to OtherServiceClient...
So, how can I share the call context between the WCF services calls? Could anybody provide some useful articles about this question?
After running the aspnet_regsql.exe tool, i notice a bunch of different tables pertaining to the ASPNET security (e.g. aspnet_Applications, aspnet_Membership, aspnet_Paths, aspnet_Personalations, aspnet_Profile, aspnet_Roles, aspnet_SchemaVersion, aspnet_Users, aspnet_UsersInRoles). Do the different providers (AspNetSqlMembershipProvider, AspNetSqlProfileProvider, AspNetSQLRoleProvider) relate or associated with certain aspnet_xyz tables? I imagine the AspNetSQLProfileProvider is responsible for the aspnet_Profile table correct? The AspNetSQLRoleProvider probably is tied to the aspnet_Users, aspnet_Roles, aspnet_UsersInRoles table? Any links documenting the relationship between teh providers and the aspnet_xyz tables?
I have a custom membership provider and a custom role provider in a .NET assembly dll called Qws.Web. The full namespace path to the classes are Qws.Web.Providers.QwsMembershipProvider and Qws.Web.Providers.QwsRoleProvider They both inherit MembershipProvider and RoleProvider respectively When I include the assembly using a project reference in VS2010 it all works fine. The minute I publish the website and project to the staging server (using IIS7) i get the following error: Unable to find the requested .Net Framework Data Provider. It may not be installed. You can see the site at [URL] I've tried all of the usual stuff and been trawling the internet for the last two days.
1. The Qws.Web.dll file IS in the bin folder 2. My Web.Config file is below:
[Code]....
3. The providers are not in the GAC and not in the machine.config file as I only want them available for this site.
Unfortunately, all the examples for Forms Authentication Code Behind w/ Custom Role and Membership Providers I find online are written with a VB.NET code behind and I need a C# code behind. I need a codebehind that will do the following:
authenticate user upon login button click if user active_flag=0 (false) OR password!=@password, display error: "Access Denied" if user admin_flag=1 & active flag=1 (true), redirect to admin_pageszipsearch.aspx if user admin_flag=0 (false) & active_flag=1 (true), redirect to pageszipsearch.aspx
This is the first time i would be using .net membership providers and i need to add some extra columns and chage a couple of existing datatypes of the exising columns.
my Q is:
1)can i do this without having to suffer down the road.
2)can i modify the existing sp's in sql08 or would i need to use additional sp's for the new columns that i add.
my user will use form authentication against Active Directory or database. Theres no Windows Integrated Authentication there!!
What i want is when the user submit the authentication form, it will try to validate the user against Active Directory and if it fail, try with the database.
How can i do that? What i had in mind was to build a custom membership provider that will encapsulate the logic but im not sure how to start.
If I just have ADProvider1 it works, when I add ADProvider2, even though for testing I only use ADProvider1 I get an error: "Unable to establish secure connection with the server" Am I adding the second provider to the membership section incorrectly?
I have a webservice project and a web project in the same solution.
The web project implements a membershipprovider.
I want to be able to authenticate user via the webservice project but when i call this method in the webproject: public static bool AuthUser(string userName, string password) { return Membership.ValidateUser(userName, password); }
I get this inner ex."Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed." Calling the method from the webproject works fine. I understand why I get the ex. but not how to solve it.. UPDATE Well I fixed the issue by deleting the C:UsersJRBAppDataLocalMicrosoftMicrosoft SQL Server DataSQLEXPRESS folder.. However now the method always returns false.. It almost seems like it doesn't use the proper connectionstring.
I'm trying to create a .NET solution and add class libraries to it. First - in VS2008 I go to File > New > Project > Other Project Types > Visual Studio Solutions > Blank Solution. Then - after VS2008 creates the blank solution I right click on the solution and select Add > New Project > Visual C# > Class Library. However, when I add the Class Library to the solution, the solution icon disappears from Solution Explorer (although the solution name is still in the VS2008 title bar). Why does the solution icon disappear from the Solution Explorer when I attempt to do this?