Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi there,

I have been asked to develop a function that, given a user name and a file name, to return whether the user has access to the file...

I have read a lot on the internet on explicit permissions, but was trying to get to the level of the specific user.

ie. bool HasAccess(string UserName, string FileName) {}

Any assistance would be fantastic.

Thanks in advance,

Roger Wright 13-Jul-10 23:54pm    
Reason for my vote of 5
Excellent question, and one that I'd like to see answered.

1 solution

Good question!

I did a bit of searching and found some goodies here[^], but the responses there are limited. The techniques posted will get you the groups that have access, but further work will be needed to find whether a user is a member of a particular group.

Best practices in the Microsoft world include granting access to groups, not users, then to assign users to groups depending on their access needs. The security model is structured to accomodate that practice, so you'll probably have to drill down through the model to find the solution. I think the above solution will get you through the first layer, but it's obviously not enough.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900