From: Matthew Daly
So I've been endeavoring to disconnect (almost) all the users from a
sharepoint on a remote machine. In this quest, I'm indebted to Timothy
Jackson for pointing me toward ADSI. But I'm still not _quite_ able to get
to where I want.
The problem is that I don't want to indisciminately end all the sessions
attached to this machine, just the ones that are associated with one
specific share. The script that I have come up with (included below)
checks all of the share's files that are open and disconnects only the
sessions of those file's "owners". But even this is blunt (to say nothing
of being s--l--o--w) because those sessions could be connected to other
shares that I don't want to touch. (Also, although I don't know how
important it is, it doesn't find users who are connected to the share but
don't have any open resources.)
It seems like there must be a better way. One of the properties of the
share is the CurrentUserCount -- is there a way to identify which sessions
comprise that count? Also, is there a class finer than sessions so that I
can disconnect someone from a single share without affecting the rest of
the session or the rest of the share?
Thanks,
-Matthew
[EMAIL PROTECTED]
-------------
# this is the guts of a subroutine that, given a connected FileService
# object and the text of a sharepoint, will end the sessions of all
# users who have open resources on that share.
my $FileService = shift;
my $Sharepoint = shift;
my %BadUsers = ();
my $Resources = $FileService->{Resources};
foreach my $Resource (in($Resources))
{
my $RUser = $Resource->{User};
my $RPath = $Resource->{Path};
if ($RPath=~/$Sharepoint/) {$BadUsers{$RUser}=1;}
}
my $Sessions = $FileService->{Sessions};
foreach my $Session (in($Sessions))
{
my $User = $Session->{User};
if ($BadUsers{$User})
{
print "Disconnecting $User\n";
$Sessions->Remove($Session->{Name});
}
}
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin