Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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]
[stevieb]: choroba my GPS home device is done, at least prototype v1 is. I'm just making sure all of my code does what it says now
[stevieb]: I test/prototype code on my Pi, then I migrate it over to Arduino when it's ready (if that's a better platform for what I'm doing). The whole RPi stuff was for learning at first, then it snowballed. I'm just trying to get my in-house CI...
[stevieb]: ...done, which obviously requires a specific hardware setup.
[stevieb]: I don't write tests for the lower-level distributions (ie. ICs, sensors etc) within those distributions, I have all tests in a master distribution which encompasess all of the sub-modules

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-06-25 22:54 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (572 votes). Check out past polls.