Checking Directory permissions for a user group

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pramodkh
    New Member
    • Nov 2007
    • 23

    Checking Directory permissions for a user group

    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
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by pramodkh
    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

    Comment

    • pramodkh
      New Member
      • Nov 2007
      • 23

      #3
      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).

      Code:
      use strict;
      
      my @dirList;
      
      system("cmd /C \"dir  /B /S  D:\\MyDir\\ \" > dirList.out");
      open(FH,"< dirList.out") or die($!);
      while(my $fileName = <FH>){
          push(@dirList, $fileName);
      }
      close FH;
      foreach my $item ( @dirList){
          print "\nITEM = $item";
          chomp($item);
          if ( not -w $item) {
      	    die "directory $item is not writeable...Permission denied.\n";
      	}
      }
      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.
      Last edited by eWish; Jun 3 '08, 01:18 PM. Reason: Replace quote tags with the proper code tags

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        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

        Comment

        • pramodkh
          New Member
          • Nov 2007
          • 23

          #5
          Hi
          Here is the script using which I am able to get some user information.

          Code:
          use Win32::Perms;
          
          # Create a new Security Descriptor and auto import permissions
          $filedir = 'C:\temp';
          if( -e $filedir ) {
          	print "\n $filedir Exists...";
          }
          else {
          	print "\n $filedir Doesn't exists...";
          }
          $Dir = new Win32::Perms( $filedir ) || die "Unable to create Perms Object";
          # dump the contents to STDOUT
          $Dir->Dump;

          This will give me the following output.
          Code:
           C:\temp Exists...
          
          Descretionary ACL:
          Index Account                                  Mask       Type       Flag
          ----- ---------------------------------------- ---------- ---------- ----------
              0 CODE1\ing03125                           0x001200a9 Allow      0x00000003
              1 BUILTIN\Administrators                   0x001f01ff Allow      0x00000010
              2 BUILTIN\Administrators                   0x10000000 Allow      0x0000001b
              3 NT AUTHORITY\SYSTEM                      0x001f01ff Allow      0x00000010
              4 NT AUTHORITY\SYSTEM                      0x10000000 Allow      0x0000001b
              5 CREATOR OWNER                            0x10000000 Allow      0x0000001b
              6 BUILTIN\Users                            0x001200a9 Allow      0x00000010
              7 BUILTIN\Users                            0xa0000000 Allow      0x0000001b
              8 BUILTIN\Users                            0x00000004 Allow      0x00000012
              9 BUILTIN\Users                            0x00000002 Allow      0x00000012
          
          
          System (auditing) ACL:
          Index Account                                  Mask       Type       Flag
          ----- ---------------------------------------- ---------- ---------- ----------
          This is a NULL SACL. This means that no auditing is taking place.
          
          
          Owner: 
                Account                                 
                ----------------------------------------
                BUILTIN\Administrators
          
          
          Group: 
                Account                                 
                ----------------------------------------
                
          
          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/

          Comment

          • pramodkh
            New Member
            • Nov 2007
            • 23

            #6
            I am still waiting for suggestions/alternatives.

            Comment

            • numberwhun
              Recognized Expert Moderator Specialist
              • May 2007
              • 3467

              #7
              Originally posted by pramodkh
              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

              Comment

              • pramodkh
                New Member
                • Nov 2007
                • 23

                #8
                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.netadmintoo ls.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

                Comment

                Working...