Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
manojkharde
Posts: 3
Joined: Tue 20 Aug 2013 02:33

Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Post by manojkharde » Tue 20 Aug 2013 03:04

I want to buy the licensed version of your ADO.Net provider for dotConnect for PostgreSQL Professional Edition latest version I think is 6.7.301 (08-Aug-2013). But I have some few issues which I want to put forth before you.

1) In your tutorial titled "Using ExtendedMembership Provider in ASP.NET MVC 4 Application" you have given detailed explanation of how to use Membership using MVC. But I don't want to use MVC, I just want to create normal Webforms and use your provider for Membership and Role Management. How can I do it? If yes please give me the detailed information (How-to) about how can I do it?

2) Can I use the default controls for creating Membership, Roles etc provided in the Visual Studio using your above stated provider? Is the code automatically created or should I have to write the code manually for doing it?

3) After buying your licensed version of the above stated software is there any kind of machine lock? Can I use it on different machines for testing purposes? Please give the details.
I am waiting eagerly for your reply.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Post by Shalex » Tue 20 Aug 2013 14:32

manojkharde wrote:1) In your tutorial titled "Using ExtendedMembership Provider in ASP.NET MVC 4 Application" you have given detailed explanation of how to use Membership using MVC. But I don't want to use MVC, I just want to create normal Webforms and use your provider for Membership and Role Management. How can I do it? If yes please give me the detailed information (How-to) about how can I do it?
We have implemented the InitializeDatabaseConnection method in the Devart.Common.Web.WebSecurity class because there was no way to override the corresponding method of the WebMatrix.WebData.WebSecurity class.

Other methods of the WebMatrix.WebData.WebSecurity class are supported in our implementation and can be used with Devart's SimpleMembership provider.

To work with PgSqlExtendedMembershipProvider you should use the WebMatrix.WebData.WebSecurity static class. To work with PgSqlExtendedRoleProvider, System.Web.Security.Roles is used.

A simple walkthrough:

1. Add the references to the following assemblies to your WebForms Application:
a) C:\Program Files\Devart\dotConnect\PostgreSQL\Devart.Data.dll v 5.0.760.0
b) C:\Program Files\Devart\dotConnect\PostgreSQL\Devart.Data.PostgreSql v 6.7.301.0
c) C:\Program Files\Devart\dotConnect\PostgreSQL\NET4\Devart.Data.PostgreSql.Web.dll v 6.7.301.4
d) WebMatrix.Data.dll v 2.0.0.0
e) WebMatrix.WebData.dll v 2.0.0.0

2. Open your web.config and put these entries:

Code: Select all

<configuration>
...
  <connectionStrings>
    <add name="PgSqlConnectionString" providerName="Devart.Data.PostgreSql" connectionString="server=your_server;port=your_port;database=your_database;uid=your_uid;pwd=your_pwd;"/>
  </connectionStrings>
...
  <system.web>
    <membership defaultProvider="PgSqlExtendedMembershipProvider">
      <providers>
        <remove name="PgSqlExtendedMembershipProvider"/>
        <add name="PgSqlExtendedMembershipProvider" type="Devart.Data.PostgreSql.Web.Providers.PgSqlExtendedMembershipProvider, Devart.Data.PostgreSql.Web, Version=6.7.301.4, Culture=neutral, PublicKeyToken=09af7300eec23701" description="dotConnect for PostgreSQL extended membership provider"/>
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="PgSqlExtendedRoleProvider">
      <providers>
        <remove name="PgSqlExtendedRoleProvider"/>
        <add name="PgSqlExtendedRoleProvider" type="Devart.Data.PostgreSql.Web.Providers.PgSqlExtendedRoleProvider, Devart.Data.PostgreSql.Web, Version=6.7.301.4, Culture=neutral, PublicKeyToken=09af7300eec23701" description="dotConnect for PostgreSQL extended role provider"/>
      </providers>
    </roleManager>
  </system.web>
</configuration>
3. Now you can add new user and role using the following code in your WebForm1.aspx.cs (the InitializeDatabaseConnection method will create a schema for the SimpleMembership provider):

Code: Select all

public partial class WebForm1 : System.Web.UI.Page {
    // Devart.Data.PostgreSql.PgSqlMonitor monitor;
    protected void Page_Load(object sender, EventArgs e) {
        // monitor = new Devart.Data.PostgreSql.PgSqlMonitor() { IsActive = true };
        Devart.Common.Web.WebSecurity.InitializeDatabaseConnection("PgSqlConnectionString", "userprofile", "userid", "username", true);
        WebMatrix.WebData.WebSecurity.CreateUserAndAccount("myuser", "mypassword");
        System.Web.Security.Roles.CreateRole("myrole");
    }
}
We recommend you to use the dbMonitor tool for tracing the database activity:
http://www.devart.com/dotconnect/postgr ... nitor.html
http://www.devart.com/dbmonitor/dbmon3.exe
manojkharde wrote:2) Can I use the default controls for creating Membership, Roles etc provided in the Visual Studio using your above stated provider? Is the code automatically created or should I have to write the code manually for doing it?
Please specify the names of the controls and their versions. Do they support SimpleMembership functionality?
manojkharde wrote:3) After buying your licensed version of the above stated software is there any kind of machine lock? Can I use it on different machines for testing purposes? Please give the details.
A licensed developer is entitled to install and use our product on one or more computers (any number of computers), provided that it is used by the licensed developer alone, for the sole purposes of developing, testing, and deploying applications.

manojkharde
Posts: 3
Joined: Tue 20 Aug 2013 02:33

Re: Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Post by manojkharde » Tue 20 Aug 2013 17:59

Respected Sir,
I highly appreciate your prompt reply for my query regarding dotConnect for PostgreSQL version 6.7.301. I am buying the license for the Professional Edition of your above stated provider in this month.
In regard to my second question “Can I use the default controls for creating Membership, Roles etc provided in the Visual Studio using your above stated provider? Is the code automatically created or should I have to write the code manually for doing it?”
You replied “Please specify the names of the controls and their versions. Do they support SimpleMembership functionality?”
I think my question is not clear. Hence I am restating it again. “In the Microsoft Visual Studio 2010 there are default Login controls (like Login, ChangePassword, CreateUserWizard etc) in the Toolbox. If I drag suppose the Login control in the WebForm, can I create code using your above stated provider for creating users, managing their roles, membership etc or are these functionalities automatically created by your dotConnect provider for PostgreSQL? If yes, please provide a detailed information (How-to) about it.”
Again thanking you for your prompt reply. I am eagerly waiting for your reply.
Regards,
Manoj Kharde.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Post by Shalex » Fri 23 Aug 2013 16:13

These controls are desinged for MembershipProvider.

Since the structure of the tables in ExtendedMembershipProvider differs from the tables in MembershipProvider, the controls which do not depend on the MembershipProvider's tables (e.g.: Login, ChangePassword, LoginName, LoginStatus, LoginView) will work. The other controls (such as CreateUserWizard, PasswordRecovery) won't work by default. But this can be fixed by overriding provider's methods.

An example of a wrapper for the CreateUserWizard support:

Code: Select all

namespace TestLoginForm {

  public class PgSqlMembershipProviderAdapter : PgSqlExtendedMembershipProvider {

    public PgSqlMembershipProviderAdapter()
      : base() {
      
    }

    public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status) {

      try {
        CreateUserAndAccount(username, password, false, null);
        status = MembershipCreateStatus.Success;
        return GetUser(username, false);
      }
      catch(MembershipCreateUserException ex) {
        status = ex.StatusCode;
      }

      return null;
    }

  }
}
The corresponding entries in web.config for this case:

Code: Select all

<configuration>
...
  <system.web>
...
    <membership defaultProvider="PgSqlMembershipProviderAdapter">
      <providers>
        <clear/>
        <add name="PgSqlMembershipProviderAdapter" type="TestLoginForm.PgSqlMembershipProviderAdapter"  description="my adapter"/>
      </providers>
    </membership>
...
  </system.web>
...
</configuration>

manojkharde
Posts: 3
Joined: Tue 20 Aug 2013 02:33

Re: Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Post by manojkharde » Sun 08 Sep 2013 06:58

Respected Sir,
I have bought the licensed version of dotConnect for PostgreSQL Professional 6.7.301 last week. My developer license number is CRPgN-02140.

My system details are as stated below:
Operating System: Microsoft 8 Enterprise.
Database Server: postgresql-9.2, server:localhost, port:5432, username: postgre, password:sai.
IDE: Microsoft Visual Studio 2010 Ultimate Edition with Service Pack 1.

Firstly, I am trying to execute the application that you had sent to me in the previous email named TestLoginForm. But when I try to run it, it shows me the following errors (please see the error details in the attachment).

Sir, I am developing a “Collage Attendance Management Software” where I require the implementation of Role Management, Membership Management, Authentication, Password Recovery, User Registration etc that too using Postgresql as the backend database server. I am not able to implement it myself using your dotConnect software or by following the procedures in the help file “Using Extended Membership Provider in ASP.NET MVC 4 Application”, nor the “TestLoginForm” you had send is executing. I do not want to use MVC.

“My earnest request is that you please send me a small asp.net application which implements all this i.e.. Role Management, Membership, User Authentication, Password Recovery, Change Password, User Registration etc so that I could directly use it in my software without any change”. Please help me to solve this vexing problem (Authentication & Authorization) I shall be highly obliged to you. I am eagerly waiting for your reply.

Thanking you.

Regards,
Manoj R. Kharde.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Help regarding SimpleMembership, Role using dotConnect for PostgreSQL

Post by Pinturiccio » Tue 10 Sep 2013 10:28

manojkharde wrote:Firstly, I am trying to execute the application that you had sent to me in the previous email named TestLoginForm. But when I try to run it, it shows me the following errors (please see the error details in the attachment).
Please check the name of class in the Global.asax.cs file. Probably you have modified the name of the Global class. The code must be the following:

namespace TestLoginForm {
public class Global : System.Web.HttpApplication {
manojkharde wrote:“My earnest request is that you please send me a small asp.net application which implements all this i.e.. Role Management, Membership, User Authentication, Password Recovery, Change Password, User Registration etc so that I could directly use it in my software without any change”.
In the PgSqlMembershipProviderAdapter.cs file of the “TestLoginForm” application the CreateUser method overriding is demonstrated. Other methods can be overridden in the same way.
manojkharde wrote:I do not want to use MVC.
Probably the PgSqlMembershipProvider and PgSqlRoleProvider providers will be suitable for you. You don't need to override any methods in order to use PgSqlMembershipProvider and PgSqlRoleProvider providers. You need only to make a few changes in the web.config file. For more information, please refer to http://www.devart.com/dotconnect/postgr ... iders.html.

Post Reply