The Asp.Net membership provider has some clear uses in a web app. I am thinking about trying to leverage some of the features in a windows application (more specifically WPF). Does anyone know if it is possible to use the core features in a windows app? I am mostly just looking for it to create my database tables, and maintain users, roles, and profiles. I obviously do not need to use the built-in web controls (e.g. Login).
Yes. Membership, roles and profiles are all features of Visual Studio 2008 Client Application Services (Services tab of a project properties)
http://msdn.microsoft.com/en-us/library/bb384297.aspx
http://channel9.msdn.com/posts/DanielMoth/Client-Application-Services-with-Visual-Studio-2008/
I have a winform app that talks to DotNetNuke (DNN). DNN uses the Asp.net membership provider, so the source will work for other apps that use that membership provider as well. It's a very simple app, so you should be able to read the source easily.
http://www.datakido.com/downloads/Token/ViewInfo/ItemId/3
You should be able to adapt the source to work with WPF.
Yes, you can.
All the configuration can be done within app.config instead web.config of asp.net.
Make sure that you are creating a 3.5 application (WPF 4 won't work yet) - Then you must import the reference System.Web. This will allow you to use "using System.Web.Security;" like you normally would in a web app... now you can access stuff such as Membership.CreateUser()
Your app.config file has to be configured for your provider along with a connection string.
Related
I'm trying to integrate with an already existing user base. They are using the membership providers, but my application is multiplayer for a mobile game. I guess my question is in two parts.
Can I use the membership provider classes in a non-asp.net application?
And if I can, how do I setup a Web.config file when not in a web application project?
You can definitely use WebSecurity in other places, it is just a class after all. And there is nothing magical about web.config, asp.net is basically taking those attributes inside web.config and feed them to appropriate classes. Something like WebSecurity.InitializeDatabaseConnection . So you can just hard code them in or make your own config file to store those info.
I'm new to ASP.NET MVC 4 framework, before I developed .NET web apps using ASP.NET Web Forms.
In my new project (I'm updating an existing Web Form project) I need to implement Form authentication and role based authorization to pages and functionalities.
Following some articles and StackOverflow answers I'm trying to use SimpleMembershipProvider but I'm finding several difficulties to configure it and in integration with my existing DB.
In particular cannot use my existing user accounts table...
I'm using SQL Server 2005 and now I'm upgrading from Linq-to-SQL to EntityFramework.
Can you suggest me the best way to implement authentication and role authorization in ASP.NET MVC4?
It depends how custom you need:
1) Try something, that exists already. As long as you're using EF, you may try https://efmembership.codeplex.com. Haven't tried it, but from first look, looks reasonable and configurable. There are also other MembershipProvider implementations on nuget gallery if previous one does not fit.
2) If really nothing fits into your scenario from existing in nuget gallery, implement membership provider by your self. Example may be here: http://blog.ianchivers.com/2012/03/entity-framework-custom-membership.html or there even video how to do it: http://www.asp.net/web-forms/videos/how-do-i/how-do-i-create-a-custom-membership-provider
On creating a new MVC project, Visual Studio take cares of SqlMembershipProvider if it is a non-empty project. Visual Studio creates a Database and all necessary Tables.
But, I have an existing MVC 3 project and I would like to add/integrate SqlMembershipProvider.
How can I add SqlMembershipProvider and create all needed Tables in my existing Database?
You need to run
Aspnet_regsql.exe ( this creates the necessary tables into your existing database)
Take a look here:
What's difference between windows and forms authentication in asp.net mvc 4?
YES, ignore the sections of code that refer to comparison for windows and forms authentication. However, it should serve as useful information on SQLMembershipProvider which uses the Membership and MembershipUser classes to provide these membership services to a ASP.NET application.
Aspnet_regsql.exe
http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider(v=vs.90).aspx
You can use the Microsoft ASP.NET Universal Providers nuget package
ASP.NET Universal Providers add provider support in ASP.NET 4 for all
editions of SQL Server 2005 and later and to SQL Azure. If you use
these providers to develop your application, the application will be
ready for cloud environments like Azure. Other than supporting
additional storage options, the providers work like the existing
SQL-based providers, so that you can easily switch an application to
use cloud storage via SQL Azure.
And for this great Hanselman's post
The configuration for these providers is the same as the existing
SqlMembershipProvider class, but the type parameter is set to the type
of the new providers, as shown in the following table:
SQL Provider Types -> Equivalent Type for Universal Providers
System.Web.Security.SqlMembershipProvider
-> System.Web.Providers.DefaultMembershipProvider System.Web.Profile.SqlProfileProvider
-> System.Web.Providers.DefaultProfileProvider System.Web.Security.SqlRoleProvider
-> System.Web.Providers.DefaultRoleProvider (Built in provider) System.Web.Providers.DefaultSessionStateProvider
So I have two projects in my solution, one is an ASP.Net C# Web App and the other is a Silverlight application. My question is, instead of configuring users and security for both sites with the ASP.net Web Site Administration tool, can I somehow use just one to configure users for both?
To do this you simply need a shared storage mechanism for users from both sources. This would normally be a database.
I'm not sure about in Visual Studio, but if you're deploying to IIS you can configure a forms login at a higher level and use that for each application.
Using single login is right way!
You can already use your aspnet membership in Silverlight. We use that way and this is the right thing.By this way you can share all your membership info,such as profile,groups.
http://blogs.msdn.com/b/kylemc/archive/2010/05/10/using-asp-net-membership-in-silverlight.aspx
http://www.silverlightshow.net/items/Leveraging-the-ASP.NET-Membership-in-Silverlight.aspx
We have an ASP.net application but some screens are deemed too slow to use by our users.
As a result, we are trying to provide a WinForms-based alternative to those data-input centric screens so we can use richer controls like Grids with immediate screen updates and feedback for the user.
Ideally, I would like the users to login to the WinForms application using the same credentials they use in the ASP.net application?
Is it possible?
I've found this post ( .Net authentication for both web and winforms ) but it isn't really answering the question from my point of view...
We are not using WebServices, or WCF at the moment and do not plan to use it unless it is really the only way to achieve this.
Thanks a lot.
Sure you can, just add the same settings in your app.config that you have in your web.config to wire up the Membership provider, and reference System.Web.Security. Then you can use Membership and Roles from your WinForms application.
See this article for a good example of how to do this:
http://www.theproblemsolver.nl/usingthemembershipproviderinwinforms.htm
Take a look at this article: Unify Windows Forms and ASP.NET Providers for Credentials Management.
For even more information check out the links from this answer: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/9e5192f4-4f44-4db6-aab8-8e79f2e667f8.