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及其口令,怎样使用该用户和口令可以得到创建远程用户的权限?

谢谢
...全文
620 6 打赏 收藏 转发到动态 举报
写回复
用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函数可以适用。
【重要提示】本资源设置为0积分下载,若非0积分请勿轻易下载 亲爱的CSDN用户: 首先感谢你点进这个资源页面。我需要提前说明一个重要情况: 本资源原本已设置为“0积分下载”,即作者希望完全免费共享。但CSDN平台有时会根据文件的下载热度、文件大小、用户权限等因素,自动将部分资源的积分调整为非0数值(如1积分、2积分、5积分等)。这是平台系统的自动行为,而非作者本人的设定。 因此,如果你当前看到该资源的下载所需积分不是0(例如显示为1、2、3……),请谨慎决定是否下载。 如果你按照非0积分支付并下载后发现资源内容不符合预期、链接失效,或者实际上该资源本应是免费的,作者无法为此承担积分损失或退还操作。强烈建议:仅在页面显示为0积分时进行下载。 另外,本资源描述中并未直接提供具体的下载地址或外部链接,因为它本身是一个通过CSDN官方上传通道提交的文件/内容包。如果你看到描述中没有外部网盘地址,这是正常的——资源文件应通过CSDN内置的“下载”按钮获取。若因平台积分显示异常导致你支付了积分,请优先联系CSDN客服咨询积分退还政策,作者没有权限修改平台自动设定的积分值。 感谢你的理解与支持。技术分享本应开放,但受限于平台规则,特此提醒如上。祝学习进步!

15,465

社区成员

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

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