473,320 Members | 1,846 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,320 software developers and data experts.

Programmatically getting NTFS folder permissions

Hey , I need to make a function in C# that gets the permissions on a
folder and its sub folders. I wanted to list the users and the
permissions they have been granted on folders. I dont know if it is
conviniently possible. I am guessing that I'd probably have to use
directorysecurity.

Some help would be appreciated.

Jul 10 '07 #1
4 4041
Hi,

<ka*******@hotmail.comwrote in message
news:11**********************@n60g2000hse.googlegr oups.com...
Hey , I need to make a function in C# that gets the permissions on a
folder and its sub folders. I wanted to list the users and the
permissions they have been granted on folders. I dont know if it is
conviniently possible. I am guessing that I'd probably have to use
directorysecurity.

Did you try DirectorySecurity?

The other way would be WMI I guess.
Jul 10 '07 #2
I tried using directorysecurity but i get undesired results. Maybe I'm
not using it right.

On Jul 10, 11:11 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

<kanepa...@hotmail.comwrote in message

news:11**********************@n60g2000hse.googlegr oups.com...
Hey , I need to make a function in C# that gets the permissions on a
folder and its sub folders. I wanted to list the users and the
permissions they have been granted on folders. I dont know if it is
conviniently possible. I am guessing that I'd probably have to use
directorysecurity.

Did you try DirectorySecurity?

The other way would be WMI I guess.

Jul 10 '07 #3
<ka*******@hotmail.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
>I tried using directorysecurity but i get undesired results. Maybe I'm
not using it right.
Mind to post your code and what you are expecting, getting the effective
access permissions is not a trivial task and may require administrative
privileges to get it right.

Willy.

Jul 10 '07 #4
This might work .. but I am having some problems with it

DirectoryInfo dInfo = new DirectoryInfo("C:/Temporary");
DirectorySecurity dSecurity = dInfo.GetAccessControl();

Console.WriteLine(dSecurity.GetAccessRules(true,tr ue, Type
targetType******).ToString())

I dont know what the 3rd parameter marked ***** will be

I'm not even sure if this will work .. just one of the things I am
trying

On Jul 10, 12:20 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<kanepa...@hotmail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
I tried using directorysecurity but i get undesired results. Maybe I'm
not using it right.

Mind to post your code and what you are expecting, getting the effective
access permissions is not a trivial task and may require administrative
privileges to get it right.

Willy.

Jul 10 '07 #5

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

Similar topics

0
by: HitSkiper | last post by:
I am getting the error "The security ID structure is invalid." When running this code. Sub SetPermissions(ByRef vPath As String, ByVal UserName As String) Dim objADsSec As ADsSecurity Dim...
2
by: Ram | last post by:
Hey, I'v managed to find a way of adding NTFS permissions to a certain folder, But the problem is, the folder has a couple of inherited permissions which I want to delete. How can I remove the...
1
by: Mohamed Zaki | last post by:
Dear All, I'm facing a strange problem, I've an ASP.NET web application that contains an admin folder, in this folder the access should be restricted to specific users, as i'm using windows...
1
by: Codex Twin | last post by:
Hello folks Is it possible to add/remove Read Permissions (and any other NTFS permissions) to a folder programmatically via an ASP.NET page? Thanks.
4
by: Ram | last post by:
Hey, I'v managed to find a way of adding NTFS permissions to a certain folder, But the problem is, the folder has a couple of inherited permissions which I want to delete. How can I remove the...
3
by: Adrian | last post by:
I have a client application outside of a domain developed in VB.NET. If I want to see a shared folder from that domain into a browser I am just typing something like: \\10.1.1.1\FolderSharedName...
2
by: steggun | last post by:
Hello, I'm writing a C# windows form application and need some guidance on a couple of issues. First, my application needs to change the permissions on a folder. The application creates a...
3
by: palepimp | last post by:
Hello all, I have searched far and wide for a solution to my issue. In short, here is the problem: 1. 3 PC's enter data into an Access 2003 database (PC's are running Vista w/ Office 2007...
0
by: kanepart2 | last post by:
Hey , I need to make a function in C# that gets the permissions on a folder and its sub folders. I wanted to list the users and the permissions they have been granted on folders. I dont know if it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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....

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.