By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,712 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,712 IT Pros & Developers. It's quick & easy.

Checking Directory permissions for a user group

P: 23
Hi All

I have the following directory structure.
A -
a1
a2
a3
B -
b1
b2
b3 -
bb1.c
bb2.h
bb3.xml
C -

I have to check the Read/Write permissions for a particular user group for the directories and files shown in the above directory structure.
I am still exploring the different possibilities. so havent yet tried anything on this.
Please let me know if anyone knows how to achieve this.

Thanks
Pramod
Jun 2 '08 #1
Share this Question
Share on Google+
7 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Hi All

I have the following directory structure.
A -
a1
a2
a3
B -
b1
b2
b3 -
bb1.c
bb2.h
bb3.xml
C -

I have to check the Read/Write permissions for a particular user group for the directories and files shown in the above directory structure.
I am still exploring the different possibilities. so havent yet tried anything on this.
Please let me know if anyone knows how to achieve this.

Thanks
Pramod
Well, being a learning forum AND the fact that this sounds distinctly like it is school work, we cannot do the work for you. Instead, you are going to have to first do the work and if you are stuck getting it to work, then post your code back to this thread and we will help you get it working. But, please know that it is against site policy for you to request the answers from us without having done anything first.

Regards,

Jeff
Jun 2 '08 #2

P: 23
This is what i started with...As i m still exploring the possibilities, i wanted some information on this before i actually start working on this script. That is why i posted it in a hurry. otherwise i usually try out something first and then post(as Jeffin said).

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2.  
  3. my @dirList;
  4.  
  5. system("cmd /C \"dir  /B /S  D:\\MyDir\\ \" > dirList.out");
  6. open(FH,"< dirList.out") or die($!);
  7. while(my $fileName = <FH>){
  8.     push(@dirList, $fileName);
  9. }
  10. close FH;
  11. foreach my $item ( @dirList){
  12.     print "\nITEM = $item";
  13.     chomp($item);
  14.     if ( not -w $item) {
  15.         die "directory $item is not writeable...Permission denied.\n";
  16.     }
  17. }
  18.  
But this will check write permissions only for the user who is running this script. I want to check for a different user in different user group (that too in WINDOWS). Are there any commands in windows to check for user group permissions?
Please help me.
Jun 3 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
Don't waste too much effort on this question Jeff:

http://forums.devshed.com/perl-programming-6/checking-directory-permission-for-user-group-534325.html
Jun 3 '08 #4

P: 23
Hi
Here is the script using which I am able to get some user information.

Expand|Select|Wrap|Line Numbers
  1. use Win32::Perms;
  2.  
  3. # Create a new Security Descriptor and auto import permissions
  4. $filedir = 'C:\temp';
  5. if( -e $filedir ) {
  6.     print "\n $filedir Exists...";
  7. }
  8. else {
  9.     print "\n $filedir Doesn't exists...";
  10. }
  11. $Dir = new Win32::Perms( $filedir ) || die "Unable to create Perms Object";
  12. # dump the contents to STDOUT
  13. $Dir->Dump;

This will give me the following output.
Expand|Select|Wrap|Line Numbers
  1.  C:\temp Exists...
  2.  
  3. Descretionary ACL:
  4. Index Account                                  Mask       Type       Flag
  5. ----- ---------------------------------------- ---------- ---------- ----------
  6.     0 CODE1\ing03125                           0x001200a9 Allow      0x00000003
  7.     1 BUILTIN\Administrators                   0x001f01ff Allow      0x00000010
  8.     2 BUILTIN\Administrators                   0x10000000 Allow      0x0000001b
  9.     3 NT AUTHORITY\SYSTEM                      0x001f01ff Allow      0x00000010
  10.     4 NT AUTHORITY\SYSTEM                      0x10000000 Allow      0x0000001b
  11.     5 CREATOR OWNER                            0x10000000 Allow      0x0000001b
  12.     6 BUILTIN\Users                            0x001200a9 Allow      0x00000010
  13.     7 BUILTIN\Users                            0xa0000000 Allow      0x0000001b
  14.     8 BUILTIN\Users                            0x00000004 Allow      0x00000012
  15.     9 BUILTIN\Users                            0x00000002 Allow      0x00000012
  16.  
  17.  
  18. System (auditing) ACL:
  19. Index Account                                  Mask       Type       Flag
  20. ----- ---------------------------------------- ---------- ---------- ----------
  21. This is a NULL SACL. This means that no auditing is taking place.
  22.  
  23.  
  24. Owner: 
  25.       Account                                 
  26.       ----------------------------------------
  27.       BUILTIN\Administrators
  28.  
  29.  
  30. Group: 
  31.       Account                                 
  32.       ----------------------------------------
  33.  
  34.  
  35. Total: 10 ACE entries
But it is very difficult to understand the Mask code.
Please let me know is there any way by which i can get the human readeable information out of it?
I tried to decode the mask information using this link : http://www.roth.net/perl/perms/
Jun 10 '08 #5

P: 23
I am still waiting for suggestions/alternatives.
Jun 11 '08 #6

numberwhun
Expert Mod 2.5K+
P: 3,503
I am still waiting for suggestions/alternatives.
To tell you the truth, I have no idea. If I were you, I would start reading everything I could over at the Roth Consulting site where you got the module from (as its not part of CPAN). If you have any questions, maybe they can provide the answers for you.

Regards,

Jeff
Jun 11 '08 #7

P: 23
Thanks Jeff. I have sent a mail to Roth Cons. Lets see if i get any reply, i will post the answer in this forum.

But in general, its so easy to get user group info through GUI. I mean there must be some module in PERL which will talk to Windows API to get user info.
which module of CPAN do you suggest to get user group info? I couldn't get any. I tried all this:
http://www.netadmintools.com/art33.html
http://www.roth.net/perl/perms/
win32::Security etc.

Please let me know if anyone can help me to get this info. Its very urgent for me.

Thanks
Pramod
Jun 12 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.