OK here is what I have: I for got to mention that I am using LINQ to SQL In one project I have my DBML files like this
NDBS.DBML
NDBS.Designer.vb
NDBS.vb
The latter looks like this
Namespace CSW.Models.NDMS
Partial Class NDMSDataContext
End Class
End Namespace
In my security folder I have
Imports CSW.Models.NDMS
Imports log4net
Imports System.Reflection
Imports System.Web
Namespace CSW.Security
Public MustInherit Class NDMSMemberProvider
Inherits System.Web.Security.MembershipProvider
Private _db As NDMSDataContext
Public MustOverride Function GetNDMSDataContext() As NDMSDataContext
Sub New()
_db = GetNDMSDataContext()
End Sub
Private Shared ReadOnly Log As ILog = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType)
Public Overrides Property ApplicationName() As String
Get
Return "CSW-Forms"
End Get
Set(ByVal value As String)
Throw New NotImplementedException()
End Set
End Property
Public Overrides Function ChangePassword(ByVal username As String, ByVal oldPassword As String, ByVal newPassword As String) As Boolean
Throw New NotImplementedException()
End Function
Public Overrides Function ChangePasswordQuestionAndAnswer(ByVal username As String, ByVal password As String, ByVal newPasswordQuestion As String, ByVal newPasswordAnswer As String) As Boolean
Throw New NotImplementedException()
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
Throw New NotImplementedException()
End Function
Public Overrides Function DeleteUser(ByVal username As String, ByVal deleteAllRelatedData As Boolean) As Boolean
Throw New NotImplementedException()
End Function
Public Overrides ReadOnly Property EnablePasswordReset() As Boolean
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property EnablePasswordRetrieval() As Boolean
Get
Throw New NotImplementedException()
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
Throw New NotImplementedException()
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
Throw New NotImplementedException()
End Function
Public Overrides Function GetAllUsers(ByVal pageIndex As Integer, ByVal pageSize As Integer, ByRef totalRecords As Integer) As System.Web.Security.MembershipUserCollection
Throw New NotImplementedException()
End Function
Public Overrides Function GetNumberOfUsersOnline() As Integer
End Function
Public Overrides Function GetPassword(ByVal username As String, ByVal answer As String) As String
Throw New NotImplementedException()
End Function
Public Overloads Overrides Function GetUser(ByVal providerUserKey As Object, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser
Throw New NotImplementedException()
End Function
Public Overloads Overrides Function GetUser(ByVal username As String, ByVal userIsOnline As Boolean) As System.Web.Security.MembershipUser
Throw New NotImplementedException()
End Function
Public Overrides Function GetUserNameByEmail(ByVal email As String) As String
Throw New NotImplementedException()
End Function
Public Overrides ReadOnly Property MaxInvalidPasswordAttempts() As Integer
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property MinRequiredNonAlphanumericCharacters() As Integer
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property MinRequiredPasswordLength() As Integer
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property PasswordAttemptWindow() As Integer
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property PasswordFormat() As System.Web.Security.MembershipPasswordFormat
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property PasswordStrengthRegularExpression() As String
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property RequiresQuestionAndAnswer() As Boolean
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides ReadOnly Property RequiresUniqueEmail() As Boolean
Get
Throw New NotImplementedException()
End Get
End Property
Public Overrides Function ResetPassword(ByVal username As String, ByVal answer As String) As String
Throw New NotImplementedException()
End Function
Public Overrides Function UnlockUser(ByVal userName As String) As Boolean
Throw New NotImplementedException()
End Function
Public Overrides Sub UpdateUser(ByVal user As System.Web.Security.MembershipUser)
Throw New NotImplementedException()
End Sub
Public Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean
'TODO: factor out the NDMS datacontext into the user service.
' DO we need a presntaion model?
Dim ReturnValue = (From u In _db.Users _
Where u.user_name = username _
And u.pword = password _
Select u).Any()
Dim IP As String = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
If ReturnValue = True Then
Log.InfoFormat("Successful Login - Username: {0}, Client IP: {1}", username, HttpContext.Current.Request.ServerVariables("REMOTE_ADDR"))
Else
Log.InfoFormat("Failed Login - Username: {0}, Client IP: {1}", username, HttpContext.Current.Request.ServerVariables("REMOTE_ADDR"))
End If
Return ReturnValue
End Function
End Class
End Namespace
I also have in my CSW.Web project:
Another Class
Imports CSW.Models
Namespace Security
Public Class NDMSMemberProvider
Inherits CSW.Security.NDMSMemberProvider
Public Overrides Function GetNDMSDataContext() As NDMSDataContext
Return New NDMSDataContext(My.Settings.NDMS_ConnectionString)
End Function
End Class
End Namespace
All this works perfectly on my local machine and has worked for a while.
Lately staging started erroring out after I started exploring functionality for user roles as the non implemented code snipets indicate. Can somebody see where I am messing up? If I don't get this fixed, I cannot put anything in production...