Holly Brethren
This is a bit interesting, The script below (sorry about the extra spaces) will create a Tk based form that will have an entry box at the top where a drive letter (remote or local) can be entered, and by pressing the return key, a graphical display of the tree directory structure will be displayed on the left.
On the right I would like to display a list of all global groups that are allowed to access this particular drive only (not every global group available in the domain). This information on the form should change when another drive letter is selected (by typing in the drive letter and hitting the return key). My problems with this script are as follows:
1- When the script runs as it is, I do get a display of global groups in the right pane by using this call (at line 70)
@global_groups = @{&GetGroups(GROUP_TYPE_GLOBAL)};
map {$tk{group_list}->insert('end',
-itemtype=> 'imagetext',
-text=> "$_",
-image=> $im{grp})}
@global_groups;
And this sub
sub GetGroups
{
my $type = @_;
my @groups;
return \ @groups if (Win32::AdminMisc::GetGroups('',$type, \ @grou
+ps));
}
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:
@global_groups = @{&GetGroups( $dr{server}, GROUP_TYPE_GLOBAL)};
And modify the sub like this:
sub GetGroups
{
my ($srv, $type) = @_;
my @groups;
return \ @groups if (Win32::AdminMisc::GetGroups(‘’,$type, \ @grou
+ps));
}
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.
The call is currently in the main body of the script so the display of the global groups will not change (I do understand this bit), but not exactly sure on how to get the global groups correspond to the drive letter entered and how to insert the global groups (corresponding to the newly entered drive letter) instead of the current global groups display (i.e instead of inserting in the end of the list, it should delete the current global groups display and replaces it with the newly obtained global groups).
Your Enlightments are highly appreciated.
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));
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.