RE: Checking Folder Access Permissions



Hi Jeff,

Thanks for your post!

Based on my understanding, your File Manager application wanted to manage
and check certain user's NTFS access to a folder in .Net.

In Windows security world, all the objects are protected with DACL in
Security Descriptor. The DACL contains a list of ACEs, which describes
which account can/can't access this object. So is the Folder object.

The Windows DACL security feature is not supported in .Net1.1, but is
partial added in .Net2.0. To dump out the DACL of a folder, you may use
Directory.GetAccessControl method to get the DirectorySecurity class, and
then loop through the result set from DirectorySecurity.GetAccessRules to
dump each ACE content. The figure3 in the article below provides some
sample regarding dumping DACL of a file, which is easy to modified into
folder:
"Manage Access to Windows Objects with ACLs and the .NET Framework"
http://msdn.microsoft.com/msdnmag/issues/04/11/AccessControlinNET/

To programmatically access check if a user has certain access right to a
folder, Windows provides AccessCheck API for this purpose. However, based
on my research, I found .Net2.0 did not provide support for this API, so
you have to p/invoke this win32 API to achieve what you want. Actually, in
..Net world, the simplest way of access checking is performing the folder
accessing directly and catch the access deny exception to indicate the
failure, or the accessing is granted. AccessCheck API is a somewhat complex
API, if you want to p/invoke to it, please refer to the article below for
more information:
"The Windows Access Control Model Part 3"
http://www.codeproject.com/csharp/accessctrl3.asp

Finally, the article below provides a rude way of doing access checking in
..Net. That is he simulate the work of AccessCheck API in .Net by checking
each ACE for grant/deny information, if you do not like the complexibility
of p/invoke AccessCheck and throw exception with direct access, this is
another choice for you:
"Testing file access rights in .NET 2.0"
http://www.codeproject.com/useritems/UserFileAccessRights.asp

Hope this helps.

If you need further help or other concern, please feel free to tell me,
thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • RE: Console App in one EXE file
    ... Thanks for using Microsoft Newsgroup Service. ... Create a folder structure on the development computer that matches the ... manifest-based binding support (Windows XP Home Edition, ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.general)
  • Re: SP2 Crash/Re-Install on new HD. How do I access the files in my old profile?
    ... You need to "Take Ownership" of the folder. ... Support" and search for take ownership that should give you the info you ... > Last week I attempted to Install Windows XP on my home computer. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Console App in one EXE file
    ... The private assemblies idea is certainly a step forward from Microsoft's documentation of "xcopy deployment", because it does not need any installation on the target machine. ... Do you mean that you are trying to deploy a simple console app without needing any additional action of installation or any other impaction to target machine other than copying application folder. ... On a target computer with manifest-based binding support (Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Vista) no further preparation is necessary. ...
    (microsoft.public.vsnet.general)
  • Re: windows vista contacts - import
    ... Under "what kind of folder do you want?" ... Windows Mail (and Vista) has been out since Jan 2007. ... to spend the day trying to figure out the support website, ...
    (microsoft.public.windows.vista.mail)
  • Re: recover compacted folders
    ... Because of this tendency of attachments to infect, ... , then wasted space is generated in that file, and the folder must be ... Windows 2000 and Windows XP. ... Windows XP Service Pack 2 Resources for IT Professionals ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)