Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

userdel for NT/2K

by idnopheq (Chaplain)
on Apr 23, 2001 at 15:04 UTC ( #74685=sourcecode: print w/replies, xml ) Need Help??
Category: NT Admin
Author/Contact Info idnopheq
Description: userdel -- Delete a user account.

userdel modifies the system account files, deleting all entries that refer to login. The named user must exist.

#!/usr/local/bin/perl -w

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
    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";

print "$0: $ARGV[0] could not be removed:\n$^E\n" unless DelUser();

sub Existance {
  return "1" if Win32::NetAdmin::UsersExist ( 
    or return;

sub DelUser {
    return "1" if Win32API::Net::UserDel (
      or return;


=head1 NAME

B<userdel> -- Delete a user account.


B<userdel> [ I<userid> ] [ -h ]


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.


=head1 EXAMPLE

Below are exampls of B<userdel>:


The working of B<userdel> is not influenced by any environment variabl

=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".


It does not make sense to talk about standards in a B<userdel> manual 


    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<>.


This program is copyright by Dexter Coffin 2000.

This program is free and open software. You may use, copy, modify, dis
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


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://74685]
[Corion]: Yay. Traditional finance situation averted. Bonds can be quoted in amounts (1_000_000 EUR) or per unit (1 unit). And a traditional error is to trade 2_000_000 piece when you meant to trade 2_000_000 EUR.
[Corion]: (one of my scripts simply catches high amounts and I phone people making that trade, ideally before the payment is due)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-03-29 11:26 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (347 votes). Check out past polls.