NetUserAdd()怎样在远程机器上创建用户?

亿云力科技 2006-07-14 11:47:51
该函数的第一个参数可以指定为一台远程主机:
servername
[in] Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.

我的问题是:知道远程主机的Administrator及其口令,怎样使用该用户和口令可以得到创建远程用户的权限?

谢谢
...全文
546 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
亿云力科技 2006-07-16
  • 打赏
  • 举报
回复
谢谢大家的回复!
亿云力科技 2006-07-16
  • 打赏
  • 举报
回复
楼上的,

本地进程的SID是无法在远程机器上创建用户的,会返回一个Access No Right的错误。

已经找到了一个方法,即先调用WNetAddConnection2()登录到远程机器,不知道还有没有更直接的办法,详细见:http://www.sysmgmt.com.cn/article.asp?id=31
whwjn 2006-07-15
  • 打赏
  • 举报
回复
MSDN里面有一个例子啊!
远程创建第一个参数为\\IP或者\\ServerName


#ifndef UNICODE
#define UNICODE
#endif

#include <stdio.h>
#include <windows.h>
#include <lm.h>

int wmain(int argc, wchar_t *argv[])
{
USER_INFO_1 ui;
DWORD dwLevel = 1;
DWORD dwError = 0;
NET_API_STATUS nStatus;

if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
exit(1);
}
//
// Set up the USER_INFO_1 structure.
// USER_PRIV_USER: name identifies a user,
// rather than an administrator or a guest.
// UF_SCRIPT: required for LAN Manager 2.0 and
// Windows NT/Windows 2000.
//
ui.usri1_name = argv[2];
ui.usri1_password = argv[2];
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;
//
// Call the NetUserAdd function, specifying level 1.
//
nStatus = NetUserAdd(argv[1],
dwLevel,
(LPBYTE)&ui,
&dwError);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User %s has been successfully added on %s\n",
argv[2], argv[1]);
//
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);

return 0;
}
lixiaosan 2006-07-14
  • 打赏
  • 举报
回复
http://www.codeproject.com/com/replication_directory.asp?print=true
DentistryDoctor 2006-07-14
  • 打赏
  • 举报
回复
Use WMI?
亿云力科技 2006-07-14
  • 打赏
  • 举报
回复
小三:

The AccountCreate function use the NetUserAdd win api function

但程序中只是使用NetUserAdd()创建了本地的用户:
nStatus = NetUserAdd(NULL,dwLevel,(LPBYTE)&ui,&dwError);

有没有不通过C/S结构,直接调用NetUserAdd()创建远程用户的例子?看起来应该用Impersonate,但是我没有发现任何一个Impersonate函数可以适用。

15,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧