470,641 Members | 1,736 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

Programmatically check directory permissions

Does anyone know if there is a way to check the access
permissions of different users using C#? I need to know
if a user has full control or if they have read only
access or none to a certain directory. I have seen
different ways to set the permissions but none to read
them. Any help would be appreciated. Thanks in advance.
Nov 16 '05 #1
4 19895
Well, honestly, the easiest way is to try to examine the contents of the
directory. If that works, create a temp file in the directory and delete
it. If you can do all three, you have full control. If you cannot create
the file, but you can read the contents, you have read access. If you
cannot read the directory, you have no access.

Just make sure to catch the exceptions and handle them appropriately.

I suppose you could inspect the ACLs on the directory itself, but it would
be harder than doing the things above.

--- Nick

"Steven" <wh**************@hotmail.com> wrote in message
news:1b*****************************@phx.gbl...
Does anyone know if there is a way to check the access
permissions of different users using C#? I need to know
if a user has full control or if they have read only
access or none to a certain directory. I have seen
different ways to set the permissions but none to read
them. Any help would be appreciated. Thanks in advance.

Nov 16 '05 #2
Thanks for your help Nick. I have been checking the directory
permissions using the example that you provided. Do you know if there is
a way to programatically check the ACLS or if the .NET framework
provides any classes to check the ACLS?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Thanks for your help Nick. I have been checking the
directory
permissions using the example that you provided. Do you
know if there is
a way to programmatically check the ACLS or if the .NET
framework
provides any classes to check the ACLS?
-----Original Message-----
Well, honestly, the easiest way is to try to examine the contents of thedirectory. If that works, create a temp file in the directory and deleteit. If you can do all three, you have full control. If you cannot createthe file, but you can read the contents, you have read access. If youcannot read the directory, you have no access.

Just make sure to catch the exceptions and handle them appropriately.
I suppose you could inspect the ACLs on the directory itself, but it wouldbe harder than doing the things above.

--- Nick

"Steven" <wh**************@hotmail.com> wrote in message
news:1b*****************************@phx.gbl...
Does anyone know if there is a way to check the access
permissions of different users using C#? I need to know
if a user has full control or if they have read only
access or none to a certain directory. I have seen
different ways to set the permissions but none to read
them. Any help would be appreciated. Thanks in advance.

.

Nov 16 '05 #4
Yes, Renaud Paguay has done all the P/Invoke work in a GotDotNet user
sample:

http://www.gotdotnet.com/Community/U...f-e0705af065d9

HTH,

--
Scott
http://www.OdeToCode.com

On Sat, 12 Jun 2004 23:09:52 -0700,
<an*******@discussions.microsoft.com> wrote:
Thanks for your help Nick. I have been checking the
directory
permissions using the example that you provided. Do you
know if there is
a way to programmatically check the ACLS or if the .NET
framework
provides any classes to check the ACLS?
-----Original Message-----
Well, honestly, the easiest way is to try to examine the

contents of the
directory. If that works, create a temp file in the

directory and delete
it. If you can do all three, you have full control. If

you cannot create
the file, but you can read the contents, you have read

access. If you
cannot read the directory, you have no access.

Just make sure to catch the exceptions and handle them

appropriately.

I suppose you could inspect the ACLs on the directory

itself, but it would
be harder than doing the things above.

--- Nick

"Steven" <wh**************@hotmail.com> wrote in message
news:1b*****************************@phx.gbl.. .
Does anyone know if there is a way to check the access
permissions of different users using C#? I need to know
if a user has full control or if they have read only
access or none to a certain directory. I have seen
different ways to set the permissions but none to read
them. Any help would be appreciated. Thanks in advance.

.


Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Tracy Tripp | last post: by
3 posts views Thread by James Coleman | last post: by
6 posts views Thread by Fred W. | last post: by
3 posts views Thread by gareth | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.