I have a site, into which users log in using forms authentication, in which I want to restrict access to files in a particular folder to certain users.
So, for instance, folder dir/foo will be accessible to user1 but not user2 or user3 and folder dir/bar will be accessible to user2 but not user1 or user3.
The folders mentioned above are not created at the point at which I deploy the site. They are created throughout the lifecycle of the website and I can know through code (by the names of the files) who should have access to which files.
My setup is such that I have some users who have roles of Member. A Member represents a company. Each Member has users with roles of Seller, Buyer and Viewer. Now, each user whether he is a Member, Seller, Buyer or Viewer should be able to see documents that belong to his company. So, if Seller1 has a document a.txt then Seller1 should be able to see it, Member1 should be able to see it (Member1 is the company to which Seller1 belongs), Buyer1 should be able to see it (belongs to Member1), Viewer1 should be able to see it (belongs to Member1), but Buyer2 should not be able to see it (if he belongs to Member2). Documents are placed in folders that are named after the name of the user to whom the document belongs. For example, documents belonging to Seller1 are in a folder called Seller1. Also, there is a user called Admin who can see all documents.
How can I do this?