ASP.net Web Forms Application login using external DB - asp.net

I'am creating a dynamic web form aplication. It stores the users data in another database (external server)
I know that there is aspnet_regsql.exe but i have no idea how to implement it on external server.
(i also can't loose data from existing database)
How can i force default login system to check if my database have valid credentials in my Password and UserName columns ?
Thanks in advance.

Membership using aspnet_regsql.exe has been obsoleted.
There are new ones -
Universal Providers
Simple Membership
ASP.NET Identity
Universal Providers will be the closest if you want to use the legacy Membership.
It stores the users data in another database (external server) I know
that there is aspnet_regsql.exe but i have no idea how to implement it
on external server.
Yes, you can store the Membership's tables in another database. If so, you will need to have separate connection string for the Membership.
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<clear/>
<add name="DefaultMembershipProvider" connectionStringName="MyConnection" ... />
</providers>
</membership>
<roleManager enabled="true" cacheRolesInCookie="false"
defaultProvider="DefaultRoleProvider">
<providers>
<clear/>
<add name="DefaultRoleProvider" connectionStringName="MyConnection" ... />
</providers>
</roleManager>

Related

MVC4 Simple Membership Provider setup

I would like to use mvc4 Simple membership provider. So I set up a new MVC4 internet application. Click Debug and I see that db and tables were created for me.
Is this all I need to do?.
Some articles:
http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx
http://blog.longle.net/2012/09/25/seeding-users-and-roles-with-mvc4-simplemembershipprovider-simpleroleprovider-ef5-codefirst-and-custom-user-properties/
tell me to add
<membership defaultProvider >...
section. is this necessary?
Also:
I can't get ASP.Net configuration tool to work. It says "An error was encountered. Please return to the previous page and try again. "
??
If you created a new MVC 4 web application using the Internet template it should have wired up SimpleMembership for a basic log-on/log-off functionality. It should have already updated your web.config with the proper settings. It should have setup the membership and roles and they should looks something like this.
<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
<providers>
<clear/>
<add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
</providers>
</roleManager>
<membership defaultProvider="SimpleMembershipProvider">
<providers>
<clear/>
<add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
</providers>
</membership>
SimpleMembership does not use the ASP.NET Configuration Tool used with the traditional ASP.NET membership. You have to create your own web pages for managing roles and users.
The Internet template just creates the basic functionality for authentication and authorization in your application. But SimpleMembership is very extensible. For example it is fairly easy to customize what type of information you want to capture in the user profile or setup email confirmation of new users.

ASP.NET Membership - LDAP Authentication Against Apache DS

I am trying to set up a custom ASP.NET membership provider to authenticate using LDAP and Apache DS. This is what my web.config entry looks like:
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
connectionProtection="None"
connectionUsername="uid=myid, O=this domain"
connectionPassword="mypwd"
attributeMapUsername="sAMAccountName"
enableSearchMethods="True" />
I am not having much luck here, probably owing to the fact that I have no idea what I am doing. I am hoping someone can at least verify I am headed in the right direction?
You can't use the ActiveDirectoryMembershipProvider for LDAP, it requires a real ActiveDirectory server. Unless Apache DS emulates AD, you won't be able to use this.
You're going to have do a custom membership provider. THere's a working example here:
http://forums.asp.net/t/970391.aspx/1

ASP.NET Membership is creating double user entries upon creation

I'm using asp.net membership in my web application.
I use website->ASP.net Configuration to create users. Whenever I create an user it is adding two entries into this table aspnet_Users with two different application ids.
is there a reason why?
Because, i'm assigning this user a role. this is getting saved into the usersinroles table with a user id.
When i login from my application, the logged in userid is different from the usersinroles table.
How do i achieve this? Im trying to display/not display some links based on user roles. the users and roles are created using asp.net configuration utility
--I see 3 records created in teh application table. How is this possible? When are they craated. here are teh values in application table
ApplicationName LoweredApplicationName ApplicationId
/ / AA398676-C555-4999-A085-632DDF3576FE
/eproc /eproc 9F887F82-7AA1-41E8-97EA-E8EDEB4A7C09
eproc eproc 4B46421F-2FCE-449B-A14A-9188EEE0B8B6
Check your Web.Config file and search for 'applicationName'.
Make sure they are all set to the same value.
You will have at least 3:
<membership>
<providers>
<clear/>
ONE HERE
</providers>
</membership>
<profile>
<providers>
<clear/>
ONE HERE
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
ONE HERE
</providers>
</roleManager>

ASP.NET role based security with AzMan and AD roles

I'm trying to evaluate AzMan for one of my ASP.NET applications but I have a strange problem. My test application expects three roles:
User
Owner
Admin
I created XML Authorization store located in application's App_Data and added these role definitions. I configured my test ASP.NET application to use AuthorizationStoreRoleProvider and I added some test code wich uses Principal.IsInRole and PrincipalPermission. Everything worked well on my local computer with local accounts assigned to roles in AzMan.
Then I moved my test application to the server and a I assigned Active Directory users and Groups to AzMan's roles. Now PrincipalPermission and Principal.IsInRole don't work any more. Interesting is that if I assign builtin Everyone group into any role it works so there is some problem with AD users and groups assigned to roles. Can I use XML authorization store with AD groups and users? What else can cause such problems?
Check the security settings on your asp.net application.
It sounds like annonymous authentication is on, so your users are coming in as annonymous users, not themselves, therefore it works for the everyone group.
<roleManager enabled="true" cacheRolesInCookie="false" cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="AspNetWindowsTokenRoleProvider" createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear/>
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>

Is it possible to use a different database name with SqlMembershipProvider

Can I specify a different database than ASPNETDB using SqlMembershipProvider? I am developing a site on a shared host, and have to restrict my data schema to a single provided database.
I was roundly scolded last time I suggested rolling my own authentication code.
Alternatively, is there some other packaged authentication system I could drop in and configure to use an arbitrary database and tables from asp.net?
You can install the ASP.Net Membership Schema to any SQL database by using the aspnet_regsql command line tool.
You can also specify any connection string you'd like for your membership provider. Simply add something like this to your membership declaration in your web.config file:
<connectionStrings>
<add name="MyConnectionString" connectionString="Database=MyDatabase;Server=xxx;User=xxx;Pwd=xxx;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<membership defaultProvider="MyProvider">
<providers>
<add connectionStringName="MyConnectionString" applicationName="/Test"
description="MyProvider" name="MyProvider" type="SqlMembershipProvider" />
</providers>
</membership>
The previous answer is largely correct, but I had a problem until I fully qualified the "Type" value to be "System.Web.Security.SqlMembershipProvider".
<membership defaultProvider="MyProvider">
<providers>
<add connectionStringName="MyProvider"
applicationName="/Test"
description="MyProvider"
name="MyProvider"
type="System.Web.Security.SqlMembershipProvider" />
</providers>
</membership>

Resources