gpt4 book ai didi

c++ - 调用 AddUser 时持续出现 87 错误

转载 作者:行者123 更新时间:2023-11-28 05:54:16 26 4
gpt4 key购买 nike

<分区>

我正在尝试使用 NetAddUser 添加本地用户,但总是无缘无故地收到此错误代码 - 87。据我所知,一段代码已根据 MSDN 完成。这里可能出了什么问题?

#include "stdafx.h"
#include <windows.h>
#include <Lm.h>

#pragma comment(lib, "netapi32.lib")

int _tmain(int argc, _TCHAR* argv[])
{
wchar_t wchLogin[256] = { 0 };
wchar_t wchPassword[256] = { 0 };
DWORD dwError = 0;
USER_INFO_1 user_info;
//ZeroMemory(&user_info, sizeof(USER_INFO_1));
NET_API_STATUS err;

wcscpy_s(wchLogin, L"test_user");
wcscpy_s(wchPassword, L"123");


user_info.usri1_name = wchLogin;
user_info.usri1_password = wchPassword;
user_info.usri1_priv = USER_PRIV_ADMIN;
//user_info.usri1_script_path = L"";

//user_info.usri1_flags = UF_SCRIPT;
//user_info.usri1_home_dir = NULL;
//user_info.usri1_comment = NULL;
//user_info.usri1_flags = UF_SCRIPT | UF_WORKSTATION_TRUST_ACCOUNT;


err = NetUserAdd(NULL, 1, (LPBYTE)&user_info, &dwError);
if ( err != NERR_Success )
{
printf("Error adding user: %d\n", err);
}


getchar();
return 0;
}

谢谢!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com