Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login control in ASP.NET with PostgreSQL

I have a ASP.NET project and PostgreSQL database. In my database, I have table named user and that table has attributes: password and nick.

I want use the Login component in my ASP.NET project, but I do not know how can I configure it for my own databse. In the project I use an empty ASP.NET web page. And for the connection I use ODBC or NpgSQL.

maybe i have to ues membership provaider... How can i use it with postgreSQL ????

Thanks a lot.

like image 628
Eddy_Screamer Avatar asked Oct 11 '22 23:10

Eddy_Screamer


2 Answers

I've been attempting the same thing: using ASP.NET membership, except with PostgreSQL instead of SQL Server. I found this project on the web, developed by one of the NpgSQL developers, with some instructions:

http://dev.nauck-it.de/projects/aspsqlprovider/wiki/Install

Summary of instructions (from the above link):

  1. Copy the NauckIT.PostgreSQLProvider.dll into the ~/Bin directory.
  2. Add the PostgreSQL connection string into your Web.config.
  3. Create the PostgreSQL database schema with the provided DatabaseSchema.sql script.
  4. After creating the tables, double check the global schema search path and make sure the schema in which you placed the tables is referenced in the current search path. If not, edit the global config file, add the schema to the search path, and restart the postgres server. Otherwise, the ASP.NET configuration will not be able to find the tables.

Sample code is available on the project's wiki page.

like image 54
Kendrick Avatar answered Oct 13 '22 14:10

Kendrick


I know this is an older question but someone else might find this helpful.

The easiest thing to do it to swap out the microsoft provider with a postgresql provider that basically does the same job. That way you can use all of the examples that the microsoft people and bloggers have created. You will also be able to use the login objects.

I like it better than the nauck provider. I think it is more up to date. It has been upgraded so that you don't even need to run the sql script to get it started, it will create the tables for you.

PGprovider at code.google.com

  1. You will take the pgProvider.dll, include it in your project.
  2. Create a security schema and user in your postgresql database
  3. Configure the web.config (the actual code you need to change is listed in the wiki)
  4. Then follow the microsoft membership provider examples. (the provider will create all the tables on first use if they don't exist). Microsoft provider help files
like image 32
Stradas Avatar answered Oct 13 '22 12:10

Stradas