Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

changing passwords

by RayRay459 (Pilgrim)
on Aug 10, 2001 at 21:16 UTC ( [id://103956]=perlquestion: print w/replies, xml ) Need Help??

RayRay459 has asked for the wisdom of the Perl Monks concerning the following question:

while running this script, i get this error : "Couldn't set the attributes: at C:\scripts\perl\changepass.pl line 19." can anyone help. i am trying to change local admin password on remote machines. Or does anyone know of a better way to do this? thnx. Ray
# Ray Espinoza # ChangePass.pl # This script will attempt to change the local admin password on a mac +hine. ###################################################################### +############# #!D:\perl\bin -w use Win32::AdminMisc; $Server = "\\\\muskrat"; $UserName = "Administrator"; $UserFullName = "Administrator"; $Password = "testing"; $PasswordAge = 0; $Privilege = "USER_PRIV_USER"; $HomeDir = "C:/winnt"; $Comment = 0; $Flags = 0; $ScriptPath = "C:/scripts/perl/changepass.pl"; Win32::AdminMisc::UserSetAttributes( $Server, $UserName, $UserFullName +, $Password, $PasswordAge, $Privilege, $HomeDir, $Comment, $Flags, $S +criptPath ) || die "Couldn't set the attributes: $!";

Replies are listed 'Best First'.
Re: changing passwords
by LD2 (Curate) on Aug 11, 2001 at 00:02 UTC
    You may want to look at the Win32::AdminMisc FAQ... Just an update, UserSetAttributes( $Server, $UserName, $UserFullName, $Password, $PasswordAge, $Privilege, $HomeDir, $Comment, $Flags, $ScriptPath ) is no longer used. According to the FAQ, the function is now obsolete. You probably want to update your code to use:
    UserSetMiscAttributes( $Domain, $User, $Attribute, $Value[, $Attribute +, $Value]... ) This will set set particular account details for the user $User in dom +ain $Domain. If $Domain is null then the default domain will be assum +ed. $Attribute must be one of the valid account attributes and $Value + must be a valid attribute value. Example: Win32::AdminMisc::UserSetMiscAttributes('', 'cartman', USER_HOME_DIR => "c:\\users\\c +artman", USER_FULL_NAME => "Eric Cartma +n"); Returns: 0 if unsuccessful 1 if successful
Re: changing passwords
by OzzyOsbourne (Chaplain) on Aug 10, 2001 at 22:29 UTC

    you could avoid all of this and use `net user $UserName $Password`, but that doesn't tell you why this doesn't work...

    -OzzyOsbourne

Re: changing passwords
by joefission (Monk) on Aug 10, 2001 at 22:55 UTC
    My apologies for my last attempt to help. I didn't have a win32 machine to really test, I just saw the escaped character issue.

    Anyway, according to Dave, you shouldn't use the UserSetAttributes function. I would recommend the SetPassword function instead for your purposes. Make sure you have adminsistrative rights on the remote machine that you are trying to modify, too. Wouldn't hurt to grab the latest version of AdminMisc from Dave as well.

    Good Luck!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://103956]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found