In my application I am using the aspnetdb membership for authorizing users. I created a new table UserProfiles that will hold their profile information. The UserID is linked to aspnet_users UserID with a foreign key. One of the columns in the table represents CompanyID (int). I want to be able to restrict logged in users to only see records from their company based on the CompanyID. There can be more than one user with the same CompanyID to the UserID would not work.
I can restrict their access by UsedID to only see records they created by using code behind:
Partial Class Membership_FindMyComments
Inherits System.Web.UI.Page
Protected Sub CommentsDataSource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles CommentsDataSource.Selecting
' Get a reference to the currently logged on user
Dim currentUser As MembershipUser = Membership.GetUser ...
Go to the complete details ...