I don't know why, but for some reason I just can't get my head around this CSLA framework, so I have yet another really stupid question...
I have my identity and principal classes setup, but I need to tell the system to check the database for users. Where do I do this at? I can't even find where I am supposed to tell it what table to look at? We are using MySQL and no stored procs, so I need to find where to put in the select statements and such.
Thanks,
Completely Lost
In your custom identity clss you should have a shared method like this:
Friend Shared Function LoadIdentity(ByVal UserName As String, ByVal Password As String) As MyBusinessIdentity
Return CType(DataPortal.Fetch(New Criteria(UserName, Password)), MyBusinessIdentity)
End Function
<Serializable()> _
Private Class Criteria
Public Username As String
Public Password As String
Public Sub New(ByVal Username As String, ByVal Password As String)
Me.Username = Username.ToUpper
Me.Password = Password
End Sub
End Class
DataPortal.Fetch will run through the CSLA framework and end up calling a method named DataPortal_Fetch in your Identity class.
The Fetch method should have some code to retrieve the list of roles (and any other values you want to track.)
e.g.
Protected Overrides Sub DataPortal_Fetch(ByVal Criteria As Object)
mRoles.Clear()
Dim crit As Criteria = CType(Criteria, Criteria)
Dim dr As SafeDataReader
Try
'my DAL class knows the connection string for the SQL Server database.
'your ADO.Net code can just provide the connection string here if needed.
'Or you can read it from the config file.
' Then you execute a SQL statement which uses the table in your DB:
dr = New SafeDataReader(DAL.ExecuteReader(MySQLCLASS.GetRoles(crit.Username)))
dr.Read()
'add roles to mRoles here
Finally
dr.Close()
End Try
End Sub
Joe
Copyright (c) Marimer LLC