Solved

Enumerate NTFS Folder Permissions

Posted on 2004-10-11
15
1,341 Views
Last Modified: 2008-01-09
I have been looking everywhere and have not been able to come up with a reasonable solution for this problem.  What I am trying to do is write a program/script that will enumerate through folders and return all of the NTFS permissions for each folder.  Any ideas???
0
Comment
Question by:jfkrueger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
15 Comments
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12282645
Have you tried cacls?  Not Visual Basic based, but rather old DOS Batch file type thing.
0
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 125 total points
ID: 12282668
Single DOS command (utilizing two other commands) when run in the CMD.EXE command interpreter will give you the results:

for /f "tokens=1" %a in ('dir /ad /b') do @cacls %a

(If you put that in a batch file, change it so that all %a references are instead %%a (double percent)).

For more info on cacls, execute cacls /? at a command prompt.
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12282672
Oh, and if you want from all directories and sub directories from the directory of execution, just add a /s to the dir part of the command -

for /f "tokens=1" %a in ('dir /ad /b /s') do @cacls %a
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 48

Assisted Solution

by:Mikal613
Mikal613 earned 125 total points
ID: 12282837
http://www.killervb.com/FileSystemLib.aspx

Included are the BackupStreamReader and BackupStreamWriter classes for reading and writing NTFS streams, including permissions, auditing and ownership objects
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12288095
leew,

That seems like a good idea and I may be able to use it, but I would need to be able specify a directory instead of running it from the current directory.  How would I go about doing this?  

Mikal613 - Thanks for the link, I haven't had time to test it out yet but will do so today and let you know how it worked.

Thanks again!
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12288252
Just modify the dir command between the quotes.  For example,
for /f "tokens=1" %a in ('dir /ad /b /s c:\documents and settings') do @cacls %a
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12288288
Actually, as I think about it, spaces and tabs are considered delimiters unless otherwise specified.  So it'd be best to use this instead:
for /f "tokens=1 delims=" %a in ('dir /ad /b /s' "c:\documents and settings") do @cacls "%a"

The "... delims=" effectively says no delimiters.  Also, enclose directory paths in quotes so they are read as a single directory and not multiple directories if they have spaces.
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12292188
leew,

I cannot get this to work with a directory specified, but that is OK....I can work around it.  However, I noticed that this works fine on my XP machine but when run on a Windows 2000 PC.  Is it possible that the cacls.exe command works differently on these OS's?

Thanks again...
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12294350
It's possible - I don't have a 2K system handy - will tomorrow - I'll check into this.

What happens when you specify a directory?  I tested it and seemed to work fine for me, so I'd like to help resolve it...
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12299531
leew,

Using your suggestion to specify a directory: for /f "tokens=1 delims=" %a in ('dir /ad /b /s' "c:\documents and settings") do @cacls "%a"

I get the following message: "The system cannot find the file 'dir /ad /b /s' "C:\documents and settings".

Thanks again for all of your help.

0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12299584
didja test mine?
0
 
LVL 2

Author Comment

by:jfkrueger
ID: 12299625
Mikal613 - I did go to the site and look around, but there is no documentation there and I would have no idea how to use it to get what I want...any suggestions?

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question