You should be able to use Win32::Perms for shares also.

Here is a script where I remove permission that others may have set up on
shares.

#---------------------------------------------------------------------------
---
#   Author: Howard A. Bullock [[EMAIL PROTECTED]]
#  Created: 05-Nov-1999
# Modified: 09-Jan-2000
#
# Usage: perl NullDACL.pl 
# 
# This script write a Null DACL to hidden shares on NT. This is very useful
# when you inherit a system that has a large number of user shares in which
# permission were assigned to shares that you want to remove. The result of
# running this script against an NT computer is that Everyone will have FULL
# control at the share level. Philosophically, I belong to the school of
# thought where virtually all permissions should exist at the file system
and
# not at the share level.
# 
# As currently written,  this script target all non-administrative hidden
shares
# which are primarily the hidden user home shares in our environment. The
# script can easily be altered to process other shares.
#
# Known Issues: The SetDacl method fails when $Server is the local computer.
#               This program works correctly against remote computers.
#---------------------------------------------------------------------------
---

use Getopt::Std;
use Win32::Lanman;
use Win32::Perms;
use strict;

my (%opts, $Server);
if ( ! getopts('c:', \%opts)) {                  # Check commandline options
   print "\noptions [-c computer_name]\n";
   print "options [[-c] \"name1 name2 name3 ...\"]\n";
   exit;
}
my @server = split / /, $opts{c};                # Put computer names into
an array

foreach $Server (@server) {                      # Loop for each computer
   my $LogFile = "Perms-HiddenShares-$Server.log";
   my (@shares, @SortedShares, $share, $ShareName, @ShareNames, $NullDACL,
$i);

   open (LOG, ">\\\\$Server\\c\$\\$LogFile") || die "Can not open
\\\\$Server\\c\$\$LogFile";

   if(!Win32::Lanman::NetShareEnum("\\\\".$Server, \@shares)) {
      print LOG "Error enumerating shares: " . Win32::Lanman::GetLastError()
. "\n";;
      print "Error enumerating shares: " . Win32::Lanman::GetLastError() .
"\n";;
      exit 1;
   }
   $i = 0;
   $NullDACL = new Win32::Perms();                   # Create Null Dacl

   foreach $share (@shares) {                        # The Lanman function
above returns
      push (@ShareNames, ${$share}{'netname'});      # an array of hashes.
Create an array
   }                                                 # of just share names
and discard the 
   undef @shares;                                    # the array of hashes.

   foreach $ShareName (sort @ShareNames) {
      # Regular expressions are used for matching those shares to ignore.
      # Adjust this criteria for share selection. Yes these could be
combined but
      # were listed separately for readability and manageability.

      next if $ShareName !~ /\$$/;                   # Skip non-hidden
shares
      next if $ShareName =~ /^[A-Z]\$$/;             # Skip C$ etc drive
shares
      next if $ShareName =~ /(^IPC\$|^ADMIN\$|^REPL\$)/i;    # Skip Admin
shares

      $i++;
      if ($NullDACL->SetDacl("share:\\\\$Server\\$ShareName")) {  # Set Null
Dacl
         print "$i share:\\\\$Server\\$ShareName\n";
         print LOG "$i share:\\\\$Server\\$ShareName\n";
      } else {
         print "$i ERROR share:\\\\$Server\\$ShareName\n";
         print LOG "$i ERROR share:\\\\$Server\\$ShareName\n";
      }    
   }
   close LOG;
}

-----Original Message-----
From: Sibi John [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, August 13, 2002 11:42 AM
To: Perl (E-mail)
Subject: Permissions on shares.


Is there a way to find out using  perl, permissions on  network shares on
w2k ?? I need to know just the share permissions, the security permissions
on the folders itself have been found using Win32::Perms

~~~~~~~~~~~~~~~~~~~~
Sibi John.
Systems Adminstrator.
Deerfield Capital Management.
E:   [EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~
 

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to