Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/local/bin/perl -w #-*-perl-*- # use strict; use vars qw ( %UserInfo %CallerUserInfo $OPasswd ); use Win32; use Win32::NetAdmin; use Term::ReadKey; use Win32API::Net; use File::Spec; my ($VERSION) = '$Revision: 1.0 $' =~ /([.\d]+)/; my $warnings = 0; # 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 [ userid ] [-h] EOF } die "$0: @_"; }; die "Usage" if ( exists $ARGV[0] && $ARGV[0] eq "-h" ); my $Level = "1003"; my $UserName = $ARGV[0] || getlogin; my $Server = ""; my $Error = -1; my $CallerPriv = GetCallerPriv() || "0"; my $Executable = ( File::Spec->splitpath( $0 ) )[2]; CheckUser(); print "Changing password for $UserName\n"; ( $OPasswd, $UserInfo{password} ) = PasswordPrompt(); if ( $CallerPriv < "2" ) { Win32API::Net::UserChangePassword ( $Server, $UserName, $OPasswd, $UserInfo{password} ) or die "\n$^E\n"; } if ( $CallerPriv == "2" ) { Win32API::Net::UserSetInfo ( $Server, $UserName, $Level, \%UserInfo, $Error ) or die "\n$^E\n"; } print "\n$Executable: all authentication tokens updated successfully\n +"; sub GetCallerPriv { my $Caller = getlogin; Win32API::Net::UserGetInfo ( $Server, $Caller, "11", \%CallerUserInfo ); return $CallerUserInfo{priv}; } sub PasswordPrompt { my ( $OldPassword, $NewPassword1 ); unless ( $CallerPriv == 2 ) { print "(current) login password: "; ReadMode 'noecho'; $OldPassword = ReadLine 0; chomp $OldPassword; print "\n"; } for ( my $Accumulator = 0; $Accumulator < 3; $Accumulator++ ) { print "New login password: "; ReadMode 'noecho'; my $NewPassword0 = ReadLine 0; chomp $NewPassword0; print "\nRetype new login password: "; ReadMode 'noecho'; $NewPassword1 = ReadLine 0; chomp $NewPassword1; last if $NewPassword0 eq $NewPassword1; print "\npasswords do not match\n"; if ( $Accumulator >= "3" ) { print "exiting ...\n"; die; } } return $OldPassword, $NewPassword1; } sub CheckUser { die "$Executable: unknown username \'$UserName\'\n" if ! Win32::NetAdmin::UsersExist ( $Server, $UserName ); } __END__ =pod =head1 NAME B<passwd> -- change login password. =head1 SYNOPSIS B<passwd> [ I<userid> ] [ -h ] =head1 DESCRIPTION B<passwd> changes the password or lists password attributes associated + with the user's login name (userid). When used to change a password, B<passwd> prompts everyone for their o +ld password, if any. It then prompts for the new password twice. If executed by a user with USER_PRIV_ADMIN() privilege flag (i.e. supe +r-user), the old password prompt does not appear. Passwords must be constructed to meet the operating system requirement +s =head2 OPTIONS B<passwd> accepts the options described below. =over 4 =item B<userid> The userid to perform a password reset. If null, the current user's p +assword will be reset. =item B<-h> Display syntax. =back =head1 ENVIRONMENT The working of B<passwd> is not influenced by any environment variable +s. =head1 BUGS B<passwd> does not work will in a Samba domain controller environment +(so far). =head1 STANDARDS It does not make sense to talk about standards in a B<passwd> manual p +age. =head1 REVISION HISTORY passwd Revision 1.0 2000/06/22 09:00:34 idnopheq Initial revision =head1 AUTHOR The Perl implementation of B<passwd> was written by Dexter Coffin, I<i +dnopheq@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

In reply to passwd for NT/2K by idnopheq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-23 18:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found