Help

I have posted this problem to Admin list and on Roths perms news no one has
been able to help yet.

Ron

The error code that I get is,

126 The specified module could not be found. ERROR_MOD_NOT_FOUND
When the program tries to remove the second ACE.

Does this help anyone, help me?

Help

I am getting a little desperate, if anyone can help please.

Using NT 4 SP 5

Below is the code. What I am trying to do is remove selected group
permissions
on a particular path. The path and the groups (local groups) are on a
member server.

I have Dave Roth's new book and checked through all the examples he
never uses $perm->Get
and he does not give an example of removing a series of ACE's. In the
examples he uses
$perm->Remove(-1) to remove all the permissions. When I try this it
removes them all OK but
I can not put any back. I would prefer not to use this method anyway.

The program will find and remove the first ACE that matches the group
name. If there is more
than just the one ACE then it will fail. Even though I set then close
then undef the perm
and finally recreate the perm it will not remove the other ACE's of the
same name.

However if I close the program down and then rerun it, it will delete
the next ACE.

So the bottom line is I have to run the program as many times as I have
ACE's, not very
practical. Does anyone know why??


use strict;
use Win32::Perms;
use Win32;
use Win32::Lanman;

my ( $_perm, $_index, $_server, $_path, @_lines, @_list,
  $_group, $_script, $_elements, $_line, $_found, $i, $j );

if( not scalar @ARGV )
{
 my ( $_script ) = ( $0 =~ /([^\\]*?)$/);

 print << "EOT";

 Syntax

  Perl $_script <Directory> <Server> <Group Name>

 Example:

  perl $_script c:\\ansto Tagua project_admins

EOT

 exit();
}

$_path = "c:\\" unless ( $_path = $ARGV[0] );

$_server = Win32::NodeName() unless ( $_server = $ARGV[1] );

$_line =
"___________________________________________________________________________
__________";

$_group = 'ansto_dm';

$_found = 1;

while( $_found )
{
 $_index = $_found = 0;

 $_perm = new Win32::Perms( "dir:".$_path ) || exit "Can not obtain
permissions on $_path\n";

 $_perm->Dump( \@_list );

 $_elements = @_list;

 printOutput( "Server Name: \"$_server\" Path: \"$_path\" Delete Group:
\"$_group\"\n" );

 printOutput( "\nNumber of Elements $_elements\n");

 printList( @_list );

 $_found = removeGroupPermissions( $_perm, $_group, @_list );

 $_perm->Set();

 $_perm->Close();

 undef $_perm;
}

writeFile( "RemoveGroups", "v:\\ansto\\Output" );

#---------------------------------------------------------------------------
--------------------

sub showName
{
 my( $sid ) = @_;

 my( $binSid, $accountName, $domain, $SDT );

 $binSid = Win32::Lanman::StringToSid( $sid );
 Win32::LookupAccountSID( $_server, $binSid, $accountName, $domain, $SDT
);

 return $accountName;
}

sub printList
{
 my( @list ) = @_;

 my( $account, $accountName, $index, $line );

 $index = 0;

 foreach $account ( @list )
   {
  ( $accountName ) = showName( $account->{SID} );

  printOutput( "Index: $index, Account: $accountName Details are: \n" );


  printAccountDetails( $account );

  printOutput( "\n$_line\n" );

  $index++;
 }
}

sub printAccountDetails
{
 my( $account ) = @_;

 printOutput( "\nAccount->{ObjectName}  : \"$account->{ObjectName}\"" );

 printOutput( "Account->{ObjectType}  : \"$account->{ObjectType}\""  );
 printOutput( "Account->{Access}      : \"$account->{Access}\""  );
 printOutput( "Account->{Account}     : \"$account->{Account}\"" );
 printOutput( "Account->{Domain}      : \"$account->{Domain}\"" );
 printOutput( "Account->{Mask}        : \"$account->{Mask}\"" );
 printOutput( "Account->{Type}        : \"$account->{Type}\"" );
 printOutput( "Account->{Flag}        : \"$account->{Flag}\"" );
 printOutput( "Account->{SID}         : \"$account->{SID}\"\n" );
}

sub printOutput
{
 my( $line ) = @_;

 print "$line\n";

 # Remove white space from the end on the line
 #$line =~ s/\s+$//;
 push( @_lines, $line );
}

sub writeFile
{
 my( $file, $dir ) = @_;

 my( $filename, $line );

 $filename = "$dir\\$file".".dbug";

 open( F_OUT, ">$filename" ) || warn "Can not open $filename: $!";

 print "In writeFile $filename\n\n";

 foreach $line ( @_lines )
 {
  $line = "$line\n";
  print F_OUT $line;
 }
 close( F_OUT );
}

sub removeGroupPermissions
{
 my( $perm, $group, @list ) = @_;

 my( $account, $accountName, $index, $found );

 $index = $found = 0;

 foreach $account ( @list )
 {
  unless( $accountName = $account->{ Account } )
  {
   $accountName = showName( $account->{SID} );
  }

  if( $accountName eq $group )
  {
   if( $perm->Remove( $index ))
   {
    printOutput( "Just removed perm index $index: $accountName Path
$_path " );

   } else {

    printOutput( "Unable to remove perm index $index: $accountName Path
$_path " );
    print "Error: ".Win32::Lanman::GetLastError()."\n";
    $found = 1;
   }
  }
  $index++;
 }
 return $found;
}

This problem has really thrown a spaner in the works. Hoping someone can
help

Ron


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to