473,327 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

FileSecurity and HasAccess in .NET 2

I know in .NET 2.0 I can use the new GetAccessControl and SetAccessControl
methods to retrieve and amend access ruls on files and folders.

However, is there a way to retrieve wether the current user has access to a
file or folder, or what type of access the have before opening.

I could wrap code in a try..catch block to verify if they have access and
use the catch for unauthorized access, but this seems a pretty expensive
approach to me if i want to do this check on many files.

Ideally something like:

Public Function UserHasAccess(domainUser as string, filePath as string)
as Boolean

or

Public Function UserAccess(domainUser as string, filePath as string) as
AccessControlType

This would be acheived with having to try and open the file or folder, and
would also deal with individual user as well as group access.

Does such a thing exist? If not any ideas on how to build would be greatly
appreciated.

David
Apr 27 '06 #1
0 927

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Nick | last post by:
Hello, I'm trying to add a DirectorySecurity ACL entry to an existing directory (based on some code I found in the msdn). However, this code only works on local machines because I can't...
2
by: mail | last post by:
Hi guys, So far I've spent about a week hacking away at this code, and I just can't get it to add an ACE to a the DACL for a network share using WMI. Just to set the scene, I'm trying to add...
0
by: Travis Sharpe | last post by:
The .NET 2.0 framework has provided some new classes to assist in manipulating NTFS File Permissions. Compared to the previous methods of directly editing/ordering DACL's, this is much easier. ...
0
by: Ed Sutton | last post by:
Is there a FileSecurity method that can determine if the current WindowsIdentity has write access to a file? I can get the current windows identity and use FileSecurity to return the ...
0
by: Marcus | last post by:
I need to grant all users full read/write access to some files. The files are created by a Windows administrator. The following code sample grants all users full read/write access to the file...
1
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example,...
21
nathj
by: nathj | last post by:
Hi, I am currently working on a new site that offers various files for download. The file information is stored in a MySQL database and the page is produced in PHP depending on how the user got...
5
by: Rainer Queck | last post by:
Hello NG, How can I modify the user rigths on a xml file? Can this be done by code as well? I could only find the possibillity to modify user rights on folders, not on files and this onyl...
2
by: sklett | last post by:
I have an application that loads several files from a database (as byte) then writes them to the "docs and settings\all users\application data\my company\my app" folder. The problem I'm running...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.