parent
b894102a28
commit
e191c1bcde
1 changed files with 66 additions and 20 deletions
@ -1,67 +1,113 @@ |
|||||||
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
||||||
use strict; |
use strict; |
||||||
use esmith::AccountsDB; |
use esmith::AccountsDB; |
||||||
|
use esmith::ConfigDB; |
||||||
|
|
||||||
my $a = esmith::AccountsDB->open_ro() || die "Couldn't open the accounts database"; |
my $a = esmith::AccountsDB->open_ro() || die "Couldn't open the accounts database"; |
||||||
|
my $c = esmith::ConfigDB->open_ro() || die "Couldn't open the configuration database"; |
||||||
|
|
||||||
sub uniq { |
sub uniq { |
||||||
my %seen; |
my %seen; |
||||||
grep !$seen{$_}++, @_; |
grep !$seen{$_}++, @_; |
||||||
} |
} |
||||||
|
|
||||||
print "\n\n\n" . '================================' . "\n\n\n"; |
print "\n" . '^ Dossiers partagés ^ Accès en écriture ^ Accès en lecture seule ^' . "\n"; |
||||||
print "\n" . '^ Dossier partagés ^ Accès en ecriture ^ Accès en lecture seule ^' . "\n"; |
|
||||||
|
|
||||||
|
# Pour chaques Share Folder : |
||||||
foreach my $share ($a->get_all_by_prop(type => 'share')) { |
foreach my $share ($a->get_all_by_prop(type => 'share')) { |
||||||
print "\n\n" . '---------' . "\n\n"; |
|
||||||
my $name = $share->key; |
my $name = $share->key; |
||||||
my $wu = $share->prop('WriteUsers'); |
my $wu = $share->prop('WriteUsers'); |
||||||
my $wg = $share->prop('WriteGroups'); |
my $wg = $share->prop('WriteGroups'); |
||||||
my $ru = $share->prop('ReadUsers'); |
my $ru = $share->prop('ReadUsers'); |
||||||
my $rg = $share->prop('ReadGroups'); |
my $rg = $share->prop('ReadGroups'); |
||||||
|
my @list_rw; |
||||||
|
my @list_ro; |
||||||
|
|
||||||
|
# Pour chaque groupe ayant un accès RW : |
||||||
foreach my $wgroup (split(/,/, $wg)) { |
foreach my $wgroup (split(/,/, $wg)) { |
||||||
my $rec_wg = $a->get($wgroup); |
my $rec_wg = $a->get($wgroup); |
||||||
my $wg_members = $rec_wg->prop('Members'); |
my $wg_members = $rec_wg->prop('Members'); |
||||||
my @acces_members_rw = split(/,/, $wg_members . "," . $wu); |
my @acces_members_rw = split(/,/, $wg_members); |
||||||
my @acces_members_rw_filtered = uniq(@acces_members_rw); |
# Coloration en gris des comptes verrouillés : |
||||||
my @list_rw; |
foreach my $user_rw (@acces_members_rw) { |
||||||
foreach my $user_rw (@acces_members_rw_filtered) { |
|
||||||
my $urw = $a->get($user_rw); |
my $urw = $a->get($user_rw); |
||||||
my $lock_rw = $urw->prop('PasswordSet'); |
my $lock_rw = $urw->prop('PasswordSet'); |
||||||
if ($lock_rw eq 'no') { |
if ($lock_rw eq 'no') { |
||||||
|
# Injection des utilisateurs verrouillés des groupes RW dans la liste : |
||||||
push @list_rw, "<color #c3c3c3>" . $user_rw . "</color>"; |
push @list_rw, "<color #c3c3c3>" . $user_rw . "</color>"; |
||||||
} |
} |
||||||
else { |
else { |
||||||
|
# Injection des utilisateurs actifs des groupes RW dans la liste : |
||||||
push @list_rw, $user_rw; |
push @list_rw, $user_rw; |
||||||
} |
} |
||||||
} |
} |
||||||
print "\nShare Folder : " . $name . "\n"; |
|
||||||
print "\nListe RW :\n"; |
|
||||||
print @list_rw; |
|
||||||
} |
} |
||||||
|
|
||||||
|
# Pour chaque utilisateur ayant un accès RW : |
||||||
|
foreach (split(/,/, $wu)) { |
||||||
|
my @acces_members_rw = split(/,/, $wu); |
||||||
|
# Coloration en gris des comptes verrouillés : |
||||||
|
foreach my $user_rw (@acces_members_rw) { |
||||||
|
my $urw = $a->get($user_rw); |
||||||
|
my $lock_rw = $urw->prop('PasswordSet'); |
||||||
|
if ($lock_rw eq 'no') { |
||||||
|
# Injection des utilisateurs verrouillés des groupes RW dans la liste : |
||||||
|
push @list_rw, "<color #c3c3c3>" . $user_rw . "</color>"; |
||||||
|
} |
||||||
|
else { |
||||||
|
# Injection des utilisateurs actifs des groupes RW dans la liste : |
||||||
|
push @list_rw, $user_rw; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
# Pour chaque groupe ayant un accès RO : |
||||||
foreach my $rgroup (split(/,/, $rg)) { |
foreach my $rgroup (split(/,/, $rg)) { |
||||||
my $rec_rg = $a->get($rgroup); |
my $rec_rg = $a->get($rgroup); |
||||||
my $rg_members = $rec_rg->prop('Members'); |
my $rg_members = $rec_rg->prop('Members'); |
||||||
my @acces_members_ro = split(/,/, $rg_members . "," . $ru); |
my @acces_members_ro = split(/,/, $rg_members); |
||||||
my @acces_members_ro_filtered = uniq(@acces_members_ro); |
# Coloration en gris des comptes verrouillés : |
||||||
my @list_ro; |
foreach my $user_ro (@acces_members_ro) { |
||||||
foreach my $user_ro (@acces_members_ro_filtered) { |
|
||||||
my $uro = $a->get($user_ro); |
my $uro = $a->get($user_ro); |
||||||
my $lock_ro = $uro->prop('PasswordSet'); |
my $lock_ro = $uro->prop('PasswordSet'); |
||||||
if ($lock_ro eq 'no') { |
if ($lock_ro eq 'no') { |
||||||
|
# Injection des utilisateurs verrouillés des groupes RO dans la liste : |
||||||
push @list_ro, "<color #c3c3c3>" . $user_ro . "</color>"; |
push @list_ro, "<color #c3c3c3>" . $user_ro . "</color>"; |
||||||
} |
} |
||||||
else { |
else { |
||||||
|
# Injection des utilisateurs actifs des groupes RO dans la liste : |
||||||
push @list_ro, $user_ro; |
push @list_ro, $user_ro; |
||||||
} |
} |
||||||
} |
} |
||||||
print "\nShare Folder : " . $name . "\n"; |
|
||||||
print "\nListe RO :\n"; |
|
||||||
print @list_ro; |
|
||||||
} |
} |
||||||
} |
|
||||||
|
|
||||||
# print "^ " . $name . " | Accès en ecriture | Accès en lecture seule |" . "\n\n"; |
# Pour chaque utilisateur ayant un accès RO : |
||||||
|
foreach (split(/,/, $ru)) { |
||||||
|
my @acces_members_ro = split(/,/, $ru); |
||||||
|
# Coloration en gris des comptes verrouillés : |
||||||
|
foreach my $user_ro (@acces_members_ro) { |
||||||
|
my $uro = $a->get($user_ro); |
||||||
|
my $lock_ro = $uro->prop('PasswordSet'); |
||||||
|
if ($lock_ro eq 'no') { |
||||||
|
# Injection des utilisateurs verrouillés des groupes RO dans la liste : |
||||||
|
push @list_ro, "<color #c3c3c3>" . $user_ro . "</color>"; |
||||||
|
} |
||||||
|
else { |
||||||
|
# Injection des utilisateurs actifs des groupes RO dans la liste : |
||||||
|
push @list_ro, $user_ro; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
my @list_rw_uniq = uniq(@list_rw); |
||||||
|
my @list_ro_uniq = uniq(@list_ro); |
||||||
|
|
||||||
|
print "^ " . $name . " | RW | RO |" . "\n"; |
||||||
|
|
||||||
print "\n\n\n" . '================================' . "\n\n\n"; |
foreach (@list_rw_uniq) { print "$_ "; } |
||||||
|
|
||||||
|
foreach (@list_ro_uniq) { print "$_ "; } |
||||||
|
|
||||||
|
|
||||||
|
print "\n\n\n"; |
||||||
|
} |
||||||
|
Loading…
Reference in new issue