blackadder has asked for the wisdom of the Perl Monks concerning the following question:
And this sub@global_groups = @{&GetGroups(GROUP_TYPE_GLOBAL)}; map {$tk{group_list}->insert('end', -itemtype=> 'imagetext', -text=> "$_", -image=> $im{grp})} @global_groups;
But I am not sure where the script does get these groups from? The reason for this is, when I change the call to include the server name like this:sub GetGroups { my $type = @_; my @groups; return \ @groups if (Win32::AdminMisc::GetGroups('',$type, \ @grou +ps)); }
And modify the sub like this:@global_groups = @{&GetGroups( $dr{server}, GROUP_TYPE_GLOBAL)};
I get a huge list of global groups (I suppose this is supplied by the PDC) even I do not use the server name in the sub. Can a saint confirm this for me please whether I am correct in my assumptions or there is something else happening that I do not know of. My other problem is: I am not sure where in the script I should insert the @global_groups call so that it will obtain the global groups that correspond to the drive that’s been entered in the entry box.sub GetGroups { my ($srv, $type) = @_; my @groups; return \ @groups if (Win32::AdminMisc::GetGroups(‘’,$type, \ @grou +ps)); }
equire 5.006; use strict; use warnings 'all'; use Tk 800.005; use Tk::TList; use Tk::Table; use Tk::Frame; use Tk::DirTree; use Tk::Adjuster; use Tk::Scrollbar; use Tk::DropSite; use Tk::DragDrop; use File::Find; use Win32::ODBC; use Win32::Perms; use Win32::NetAdmin; use Win32::AdminMisc; use Win32::NetResource; # use Win32; # use OLE; use vars qw /%tk %dr %im @local_groups @users @global_groups $dnd_toke +n1 $dnd_token2/; $dr{path} = 'c:/'; $dr{server} = ShowServer($dr{path}); $dr{perms} = "Permissions" . $dr{path}; $tk{mw} = MainWindow -> new(-background=> 'white'); $tk{mw}-> geometry('900x700'); $tk{top_frame} = $tk{mw}-> Frame; $tk{left_frame} = $tk{mw}-> Frame; $tk{adjuster} = $tk{mw}-> Adjuster(-widget=> $tk{left_frame}, -side=> +'left'); $tk{right_frame} = $tk{mw}-> Frame; $tk{bottom_frame} = $tk{mw}-> Frame; $tk{entry_box_label} = $tk{top_frame}-> Label(-text=> "Path: "); $tk{entry_box} = $tk{top_frame}-> Entry(-textvariable=> \ $dr{path}); $tk{dir_tree_label} = $tk{left_frame}-> Label(-textvariable=> \ $dr{se +rver}); $tk{dir_tree} = $tk{left_frame}-> Scrolled('DirTree', -height=> '0', - +width=> '0', -scrollbars=>'e',); $tk{group_label} = $tk{right_frame}-> Label(-text=> ":Groups List:"); $tk{group_list} = $tk{right_frame}-> Scrolled('TList', -height=> '1', +-width=> '1', -scrollbars=> 'osoe',); $im{one} = $tk{mw}-> Photo(-file=> 'c:/perl/one.gif'); $im{grp} = $tk{mw}-> Photo(-file=> 'c:/perl/grp.gif'); $tk{entry_box}-> bind('<Key-Return>', sub {OnNewPath();}); $tk{top_frame}-> pack(qw/-side top -fill x/); $tk{left_frame}-> pack(qw/-side left -fill y/); $tk{adjuster}-> pack(qw/-side left -fill y/); $tk{right_frame}-> pack(qw/-side right -fill both -expand 1/); $tk{entry_box_label}-> pack(qw/-side left -fill both/); $tk{entry_box}-> pack(qw/-side top -fill both -expand 1/); $tk{dir_tree_label}-> pack(qw/-side top -fill both/); $tk{dir_tree}-> pack(qw/-side left -fill both -expand 1/); $tk{group_label}-> pack(qw/-side top -fill both/); $tk{group_list}-> pack(qw/-side top -fill both -expand 1/); # My Problems start here# #@global_groups = @{&GetGroups(GROUP_TYPE_GLOBAL)}; @global_groups = @{&GetGroups( $dr{server},GROUP_TYPE_GLOBAL)}; map {$tk{group_list}->insert('end', -itemtype=> 'imagetext', -text=> " +$_", -image=> $im{grp})} @global_groups; #################### MainLoop; exit (0); sub ShowServer { my $drv = @_; my $srv; if (Win32::NetResource::GetUNCName( my $unc, $dr{path})) { $unc =~ s/^\\\\(\w)+//; $srv = $&; return $dr{server} = "[ Remote Server Name : " . uc($srv) . " +]"; } else { $srv = Win32::NodeName(); return $dr{server} = "[ Local Server Name : " . uc($srv) . " ] +"; } } sub OnNewPath { $tk{dir_tree}-> delete('all'); $tk{dir_tree}-> chdir ($dr{path}); ShowServer($dr{path}); } sub GetGroups { my $type = @_; my @groups; return \ @groups if (Win32::AdminMisc::GetGroups('', $type, \ @gro +ups)); }
|
|---|