Login Controls - Could DB2 be used?

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?
LVL 2
fredmastroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

raterusCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
meomarCommented:
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
fredmastroAuthor Commented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

raterusCommented:
meomar, where have you been!?  MSDE is out, SQL Server Express 2005 is in.
0
meomarCommented:
with all it bugs I know!
0
fredmastroAuthor Commented:
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
meomarCommented:
Look it up over here:

http://www.connectionstrings.com/
0
raterusCommented:
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
fredmastroAuthor Commented:
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
raterusCommented:
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
fredmastroAuthor Commented:
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
raterusCommented:
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
fredmastroAuthor Commented:
Ahhhh  ok I see now, so I create the SQL statements myself, then.  OK great! Thanks! Much appreciated!
0
fredmastroAuthor Commented:
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
raterusCommented:
Good Stuff, glad you got it working.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.