#!/usr/local/bin/perl -w
#-*-perl-*-
#
use strict;
use Win32API::Net;
use Win32::NetAdmin;
my ($VERSION) = '$Revision: 1.0 $' =~ /([.\d]+)/;
my $warnings = 0;
die "Must have perl 5.006\nSorry\n" if $] < 5.006;
# Print a usuage message on a unknown option.
$SIG {__WARN__} = sub {
if (substr ($_ [0], 0, 14) eq "Unknown option") {die "Usage"};
require File::Basename;
$0 = File::Basename::basename ($0);
$warnings = 1;
warn "$0: @_";
};
$SIG {__DIE__} = sub {
require File::Basename;
$0 = File::Basename::basename ($0);
if (substr ($_ [0], 0, 5) eq "Usage") {
die <<EOF;
$0 (NT Perl bin utils) $VERSION
$0 [ -r ] username
EOF
}
die "$0: @_";
};
# Get the options.
die "Usage" unless @ARGV;
die "Usage" if $ARGV[0] eq "-?";
# don't waste time if the user doesn't exist
my $Server = "";
if ( ! Existance() ) {
print "$0: $ARGV[0] does not exist\n";
exit;
}
print "$0: $ARGV[0] could not be removed:\n$^E\n" unless DelUser();
sub Existance {
return "1" if Win32::NetAdmin::UsersExist (
$Server,
$ARGV[0]
)
or return;
}
sub DelUser {
return "1" if Win32API::Net::UserDel (
$Server,
$ARGV[0]
)
or return;
}
=pod
=head1 NAME
B<userdel> -- Delete a user account.
=head1 SYNOPSIS
B<userdel> [ I<userid> ] [ -h ]
=head1 DESCRIPTION
B<userdel> modifies the system account files, deleting all entries
that refer to login. The named user must exist.
=head2 OPTIONS
The following options are supported:
=item -h
Display syntax.
=back
=head1 EXAMPLE
Below are exampls of B<userdel>:
=head1 ENVIRONMENT
The working of B<userdel> is not influenced by any environment variabl
+es.
=head1 BUGS
B<userdel> isn't as nice as I would like, but Win32 isn't Unix, now is
+ it? This I<really> doesn't like Samba domain controllers, which is
+why I added the 'unknown' entry in the output.
Samba causes problems, which is why an entry might return "unknown".
=head1 STANDARDS
It does not make sense to talk about standards in a B<userdel> manual
+page.
=head1 REVISION HISTORY
lastlogin
Revision 1.0 2000/06/22 12:13:22 idnopheq
Initial revision
=head1 AUTHOR
The Perl implementation of B<userdel> was written by Dexter Coffin, I<
+idnopheq@home.com>.
=head1 COPYRIGHT and LICENSE
This program is copyright by Dexter Coffin 2000.
This program is free and open software. You may use, copy, modify, dis
+tribute,
and sell this program (and any modified variants) in any way you wish,
provided you do not restrict others from doing the same.
=head1 SEE ALSO
=head1 NEXT TOPIC
=cut
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.