From 5f8838a3517baa1c80a2d70fdfaafc9bff87d636 Mon Sep 17 00:00:00 2001 From: Heuzef Date: Fri, 15 Dec 2017 17:29:52 +0100 Subject: [PATCH] =?UTF-8?q?view=20the=20SF=20RO=20acc=C3=A8s=20for=20each?= =?UTF-8?q?=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report_acl.pl | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/report_acl.pl b/report_acl.pl index 9a65e19..c426ce5 100644 --- a/report_acl.pl +++ b/report_acl.pl @@ -116,9 +116,9 @@ foreach my $share ($a->get_all_by_prop(type => 'share')) { my @list_ro_uniq = uniq(@list_ro); print "^ " . $name . " (" . $desc . ") | "; - foreach (@list_rw_uniq) { print "$_, "; } + foreach (@list_rw_uniq) { print "$_" . "\\\\ "; } print " | "; - foreach (@list_ro_uniq) { print "$_, "; } + foreach (@list_ro_uniq) { print "$_" . "\\\\ "; } print " |" . "\n"; } @@ -143,7 +143,6 @@ foreach my $users (@users) { print $users->prop('FirstName') . " " . $users->prop('LastName'); print " | "; # Affichage des accès RW : - # Pour chaques Share Folder : foreach my $share ($a->get_all_by_prop(type => 'share')) { my $name = $share->key; @@ -178,12 +177,46 @@ foreach my $users (@users) { } } my @list_sf_rw = uniq(@list_sf_rw); - foreach (@list_sf_rw) { print "$_\\ "; } + foreach (@list_sf_rw) { print "$_" . "\\\\ "; } } - print " | "; # Affichage des accès RO : - print " RO "; + # Pour chaques Share Folder : + foreach my $share ($a->get_all_by_prop(type => 'share')) { + my $name = $share->key; + my $desc = $share->prop('Name'); + my $ru = $share->prop('ReadUsers'); + my $rg = $share->prop('ReadGroups'); + my @list_sf_ro; + + # Pour chaque groupe ayant un accès RO : + foreach my $rgroup (split(/,/, $rg)) { + my $rec_rg = $a->get($rgroup); + my $rg_members = $rec_rg->prop('Members'); + my @acces_members_ro = split(/,/, $rg_members); + foreach my $user_ro (@acces_members_ro) { + # Si l'utilisateur du groupe ayant un accès RO a ce Share Folder correspond à l'utilisateur : + if ($user_ro eq $users->key) { + # Injection du nom du Share Folder dans la liste : + push @list_sf_ro, $name . " (" . $desc . ")"; + } + } + } + + # Pour chaque utilisateur ayant un accès RO : + foreach (split(/,/, $ru)) { + my @acces_members_ro = split(/,/, $ru); + foreach my $user_ro (@acces_members_ro) { + # Si l'utilisateur ayant un accès RO a ce Share Folder correspond à l'utilisateur : + if ($user_ro eq $users->key) { + # Injection du nom du Share Folder dans la liste : + push @list_sf_ro, $name . " (" . $desc . ")"; + } + } + } + my @list_sf_ro = uniq(@list_sf_ro); + foreach (@list_sf_ro) { print "$_" . "\\\\ "; } + } print " |\n"; }