?
Solved

Login Controls - Could DB2 be used?

Posted on 2006-04-18
15
Medium Priority
?
386 Views
Last Modified: 2012-08-14
All these ASP.NET categories here at EE, I don't know which one to use, anyway...

I have a problem, I want to develop in .NET 2.0 but I have no access to any type of MS-SQL based server. I'm forced to use a DB2 database.

So I'm wondering, how could use the Login Controls in .NET 2.0 and have it talk back to the already existing DB2 database for Username and Password.  

How can I force it to check an already existing columns and associate them to the username/password in a table in a DB2 database?  So I can use all the features of the Login Controls?
0
Comment
Question by:fredmastro
  • 6
  • 6
  • 3
15 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 16480710
Certainly, you need to extend the MembershipProvider class and override the default methods, specifically the ones for authentication.

This is of course easier to say than do, but it can be done (I'm doing it)
http://www.odetocode.com/Articles/427.aspx
0
 
LVL 3

Expert Comment

by:meomar
ID: 16480750
You are not stuck with DB2, you can use MSDE database which comes free :
http://www.microsoft.com/downloads/details.aspx?FamilyID=413744D1-A0BC-479F-BAFA-E4B278EB9147&displaylang=en

(MSDE 2000)

0
 
LVL 2

Author Comment

by:fredmastro
ID: 16480811
Raterus idea is what I would like to look into and see how to do it, going to check your link out after this post.

meomar, the reason I'm stuck with DB2 is because we already have an authentication system using classic ASP and all our users are already stored in a DB2 database with all the indexes and foreign keys.  My goal is to conform the login controls to fit the already existing schema.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 33

Expert Comment

by:raterus
ID: 16480887
meomar, where have you been!?  MSDE is out, SQL Server Express 2005 is in.
0
 
LVL 3

Expert Comment

by:meomar
ID: 16480959
with all it bugs I know!
0
 
LVL 2

Author Comment

by:fredmastro
ID: 16481814
I can't figure this out...  
http://www.odetocode.com/Articles/427.aspx

I try creating my own Provider or using the one that was built in, AspNetSqlMembershipProvider, and then I try using my own connection string, like it seems to show on that article, but all I get is errors on any type of connection string except for a ms sql formated one.  

Errors like, Exception Details: System.ArgumentException: Keyword not supported: 'driver'.
or Exception Details: System.ArgumentException: Keyword not supported: 'Provider'. if I try using any type of DB2 Connection string like

connectionString="driver={IBM DB2 ODBC DRIVER};Database=D1A;hostname=xxxx;port=5951;protocol=TCPIP; uid=xxxx; pwd=xxx"

maybe I should be choosing a different "type" provider, but since it's fill in the blank, I have no idea.
0
 
LVL 3

Expert Comment

by:meomar
ID: 16481889
Look it up over here:

http://www.connectionstrings.com/
0
 
LVL 33

Expert Comment

by:raterus
ID: 16481908
No no, you're going to far, if you want to use DB2, you MUST inherit from just "MembershipProvider", not ever "SqlMembershipProvider" (that's the SQL Server option)
0
 
LVL 2

Author Comment

by:fredmastro
ID: 16483037
meomar I was actually already using that site, trying different ones, but thanks :)

Raterus, so you saying ignore the SqlMembershipProvider and create my own? I was reading that first site you sent me, still playing around with it, I'll attempt again tomorrow.
0
 
LVL 33

Expert Comment

by:raterus
ID: 16487535
Yes, the SqlMembershipProvider is a working implemention that connects to a specific set of tables that can be autogenerated.  The same thing you are going to have to do when you extend the MembershipProvider is what is _already_ done in the SqlMembershipProvider, got it?
0
 
LVL 2

Author Comment

by:fredmastro
ID: 16488168
Thanks, I think I can figure it out from here...
Unless you can tell me real quick how I can specify the specific set of tables.

I tried...

Dim MSP As MembershipProvider

but MSP doesn't give me anything I think I can use


I'll play with providers in web.config

<membership>
  <providers>
    <add
      name="DB2MembershipProvider"
      type="MembershipProvider"
      connectionStringName="LocalSqlServer"
      enablePasswordRetrieval="false"
      enablePasswordReset="true"
      requiresQuestionAndAnswer="true"
      applicationName="/"
      requiresUniqueEmail="false"
      passwordFormat="Hashed"
      maxInvalidPasswordAttempts="5"
      minRequiredPasswordLength="7"
      minRequiredNonalphanumericCharacters="1"
      passwordAttemptWindow="10"
      passwordStrengthRegularExpression=""
    />
  </providers>
</membership>
0
 
LVL 33

Expert Comment

by:raterus
ID: 16488234
To extend the MembershipProvider, you have to add your code to a class like this, and link to it like your last example in web.config.,

--

Public Class DB2MembershipProvider : Inherits MembershipProvider

      Public Overrides Property ApplicationName() As String
            Get

            End Get
            Set(ByVal value As String)

            End Set
      End Property

      Public Overrides Function ChangePassword(ByVal username As String, ByVal oldPassword As String, ByVal newPassword As String) As Boolean

      End Function

      Public Overrides Function ChangePasswordQuestionAndAnswer(ByVal username As String, ByVal password As String, ByVal newPasswordQuestion As String, ByVal newPasswordAnswer As String) As Boolean

      End Function

      Public Overrides Function CreateUser(ByVal username As String, ByVal password As String, ByVal email As String, ByVal passwordQuestion As String, ByVal passwordAnswer As String, ByVal isApproved As Boolean, ByVal providerUserKey As Object, ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser

      End Function

      Public Overrides Function DeleteUser(ByVal username As String, ByVal deleteAllRelatedData As Boolean) As Boolean

      End Function

      Public Overrides ReadOnly Property EnablePasswordReset() As Boolean
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property EnablePasswordRetrieval() As Boolean
            Get

            End Get
      End Property

      Public Overrides Function FindUsersByEmail(ByVal emailToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection

      End Function

      Public Overrides Function FindUsersByName(ByVal usernameToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection

      End Function

      Public Overrides Function GetAllUsers(ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection

      End Function

      Public Overrides Function GetNumberOfUsersOnline() As Integer

      End Function

      Public Overrides Function GetPassword(ByVal username As String, ByVal answer As String) As String

      End Function

      Public Overloads Overrides Function GetUser(ByVal providerUserKey As Object, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser

      End Function

      Public Overloads Overrides Function GetUser(ByVal username As String, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser

      End Function

      Public Overrides Function GetUserNameByEmail(ByVal email As String) As String

      End Function

      Public Overrides ReadOnly Property MaxInvalidPasswordAttempts() As Integer
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property MinRequiredNonAlphanumericCharacters() As Integer
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property MinRequiredPasswordLength() As Integer
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property PasswordAttemptWindow() As Integer
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property PasswordFormat() As System.Web.Security.MembershipPasswordFormat
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property PasswordStrengthRegularExpression() As String
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property RequiresQuestionAndAnswer() As Boolean
            Get

            End Get
      End Property

      Public Overrides ReadOnly Property RequiresUniqueEmail() As Boolean
            Get

            End Get
      End Property

      Public Overrides Function ResetPassword(ByVal username As String, ByVal answer As String) As String

      End Function

      Public Overrides Function UnlockUser(ByVal userName As String) As Boolean

      End Function

      Public Overrides Sub UpdateUser(ByVal user As System.Web.Security.MembershipUser)

      End Sub

      Public Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean

      End Function
End Class
0
 
LVL 2

Author Comment

by:fredmastro
ID: 16489229
Ahhhh  ok I see now, so I create the SQL statements myself, then.  OK great! Thanks! Much appreciated!
0
 
LVL 2

Author Comment

by:fredmastro
ID: 16489643
Woohoo it works!!

Web Config has Membership Provider:

        <membership defaultProvider="DB2MembershipProvider">
            <providers>
      <add connectionStringName="LocalSqlServer"
      name="DB2MembershipProvider"
                type="DB2MembershipProvider"
                applicationName="/"
       />
      </providers>
        </membership>

Then have my connection string above that...

and then added code to the Validate portion of the class info you sent me,
now it works! thanks!
0
 
LVL 33

Expert Comment

by:raterus
ID: 16490474
Good Stuff, glad you got it working.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question