I have two tables one with jobs one with managers, when a job ID is passed to the view ‘Detail’ the details of that job are accessible.
Job_id Job_Title Manager_id
23 Chimney Sweep 65
24 Rat Catcher 84
Managers Email
65 arthur@work.com
66 fred@work.com
I want to restrict access to the view based on the manager_email – so for example if we’re on http://jobsite/jobs/Detail/23 then only arthur can access the view.. will be using AD to pick out the user’s email..
Any pointers would be much appreciated!
You could write a custom model binder:
and then have your controller:
The custom model binder could also be registered in
Application_Start:which would simplify your controller action:
Another advantage of this approach is that you could inject dependencies into the constructor of your custom model binder. It might require those dependencies when tries to communicate with the AD and the database.