Click to open or copy the files for the ChngPass sample.
This sample changes the password for an arbitrary user on an arbitrary target machine. When targetting a domain controller for account update operations, target the primary domain controller for the domain. The account settings are replicated by the primary domain controller to each backup domain controller as appropriate. The NetGetDCName Lan Manager API call can be used to get the primary domain controller computer name from a domain name.
Admin or account operator privilege is required on the target machine unless argv[4] is present and represents the correct current password.
NetUserSetInfo at info-level 1003 is appropriate for administrative override of an existing password.
NetUserChangePassword allows for an arbitrary user to override an existing password, provided that the current password is confirmed.
This sample uses the following keywords:
displayerrortext; formatmessagea; fprintf; freelibrary; getstdhandle; loadlibraryex; localfree; makelangid; netapibufferfree; netgetdcname; netuserchangepassword; netusersetinfo; text; wmain; writefile