Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (12)
    As of 2014-07-10 09:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (203 votes), past polls