WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

wntChgPswd 562 Invalid User Name


Question:

I'm a new user to WinBatch, was writing a script to change passwords on the local admin acct, and am getting a 562 error. To clarify, the program will run through a GPO when the user logs in to a Win2K domain in Native mode, and make these changes to the local administrator account on the local PC, which will be Win2K or XP.

When the script tries to change the old password to the new password, I get the "WIL Extender Error: 562: Invalid user name". I can change the password manually (through Computer/Manage/Users) to the same password I'm using through the script, so I know it's not a password policy problem. I can also use the "*UNKNOWN*" variable, and it works just fine to the same username. Am I doing something wrong in the command line?

Per some prevous suggestions, here is the text from the wwwbatch.ini:

[WWWNT34I]
LastError=2221 (NetUserChangePassword)
Here is the script that I'm using.
AddExtender('wwwnt34i.dll')
MachineSID = wntLsaPolGet('','AccountDomain',2)
AdministratorSID = StrCat(MachineSID, "-500")
AdministratorName = wntAcctInfo('',AdministratorSID,2,0)
Message("Administrator name is currently:", AdministratorName)
changepasswd=AskYesNo("Change Password?", "Would you like to change the password for the local administrator account?")
If changepasswd==@No 
Message("Bye","Have a nice day!")
exit
endif
response=AskYesNo("Changing Old Admin Acct. Password", "Do you know the old password?")
If response == @Yes 
old=AskPassword("Change Password","Enter old password")
while @TRUE
new1=AskPassword("Change Password","Enter new password")
new2=AskPassword("Change Password","Enter new password again")
if new1==new2 then break
Message("Try Again","The new passwords you entered do not match")
endwhile
result=wntChgPswd("", AdministratorName, old, new1)
if result
Message("Password","Successfully changed")
else
Message("Password","Not changed")
endif
else
while @TRUE
change1=AskPassword("Change Password","Enter new password")
change2=AskPassword("Change Password","Enter new password again")
if change1==change2 then break
Message("Try Again","The new passwords you entered do not match")
endwhile
doit=wntChgPswd("", "%AdministratorName%", "*UNKNOWN*", change1)
if doit
Message("Password","Successfully changed")
else
Message("Password","Not changed")
Endif
Endif
exit 

Answer:

2221 seems to resolve to 'user not found'.

I'm going to make a wild guess that a different API function is used for changing passwords when the old passowrd is known and for Admins forcing password changes. And that thes functions resolve "partial user names" in a different manner.

It would be interesting to see the actual code used here. are you using the form 'johnd' for the username or 'somemachine\johnd' or 'somedomain\johnd'

User Reply:

When I enter the username, the format is just the username, not domain\user of machine\user.

Answer:

You should qualify the usernames with a domain prefix or a machine name prefix just to be 100% certain that there is nothing ambiguous w/respect to the usename and what security domain it belongs to. Additionally, if you are changing the password on a domain user account, it would be advisable to specify the name of the PDC server as the value of the server name parameter in the call to wntChgPswd().

Please test this in your environment and let me know if it eliminates the error that you are observing when your script runs.

Sample Code:

AddExtender("wwwnt34i.dll")
old=AskPassword("Change Password","Enter old password")
while @TRUE
    new1=AskPassword("Change Password","Enter new password")
    new2=AskPassword("Change Password","Enter new password again")
    if new1==new2 then break
    Message("Try Again","The new passwords you entered do not match")
endwhile

user = wntUserInfo(o)
computer  = ItemExtract(1, WinSysInfo(), @TAB)
rslt=wntChgPswd(computer, user, old, new1)
if rslt
    Message("Password","Successfully changed")
else
    Message("Password","Not changed")
endif

User Reply:

That did it! Thanks much. I added these line at the top of my script:
sysinfo = WinSysInfo( )
computer = ItemExtract(1, sysinfo, @TAB)

...added the next line after old an new passwords were entered:
result=wntChgPswd( strcat('\\',computer), AdministratorName, old, new1)

Article ID:   W16527
File Created: 2005:02:18:12:21:16
Last Updated: 2005:02:18:12:21:16