/*
在没有密码或者已知密码的情况下修改密码.
用途是可以用脚本或者编程以快速的方式改变密码.
本文简单修改自MSDN.
*/
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <windows.h>
#include <lm.h>
#pragma comment(lib, "Netapi32.lib")
int wmain(int argc, wchar_t *argv[])
{
if (argc != 4) {
fwprintf(stderr, L"Usage: %s \\\\UserName OldPassword NewPassword\n", argv[0]);
exit(1);
}
NET_API_STATUS nStatus = NetUserChangePassword(0, argv[1], argv[2], argv[3]);//在没有密码的情况下第三个参数可以为空即:L"".
if (nStatus == NERR_Success) {
fwprintf(stderr, L"User password has been changed successfully\n");
} else {
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
}
return 0;
}
没有评论:
发表评论