请教如何在Win2003系统中通过程序或者脚本添加用户组和用户?

Jinniu 2007-06-05 10:45:57
我想知道在C#或者VB.NET中如何通过程序来添加用户组和用户。
我大楷晓得用System.DirectoryServices类来处理。不过现在我没有什么头绪,以前也没有涉及过。希望那位能提供一个稍微详细一点的解决方案。
多谢!
...全文
379 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jinniu 2007-06-07
  • 打赏
  • 举报
回复
帮帮忙看一下呀!
Jinniu 2007-06-07
  • 打赏
  • 举报
回复
那位大哥还有高见?
wzq6511 2007-06-05
  • 打赏
  • 举报
回复
不懂,帮顶
chuxue1342 2007-06-05
  • 打赏
  • 举报
回复
都是高手啊!
wuyisky84 2007-06-05
  • 打赏
  • 举报
回复
看了一下楼上上的文章,可以解决问题
qyfjl 2007-06-05
  • 打赏
  • 举报
回复
http://www.xrss.cn/Info/13717.Html
http://tonyqus.cnblogs.com/archive/2004/12/26/82120.aspx
shrinerain 2007-06-05
  • 打赏
  • 举报
回复
net user /add
jinta2001 2007-06-05
  • 打赏
  • 举报
回复
要使用System.DirectoryServices似乎要系统支持的。
似乎要在域里才可以
chen85cong 2007-06-05
  • 打赏
  • 举报
回复
大家帮忙解决一下这个问题吧,谢谢了..............
http://community.csdn.net/Expert/topic/5581/5581312.xml?temp=.6539881
jinjazz 2007-06-05
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.DirectoryServices;
namespace WindowsApplication29
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)
{
try
{
DirectoryEntry AD = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");
DirectoryEntry NewUser = AD.Children.Add("TestUser1", "user");
NewUser.Invoke("SetPassword", new object[] { "#12345Abc" });
NewUser.Invoke("Put", new object[] { "Description", "Test User from .Net" });
NewUser.CommitChanges();
DirectoryEntry grp;

grp = AD.Children.Find("Guests", "group");
if (grp != null) { grp.Invoke("Add", new object[] { NewUser.Path.ToString() }); }
Console.WriteLine("Account Created Successfully");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();

}

}


}
}
jinta2001 2007-06-05
  • 打赏
  • 举报
回复
如果不限于DirectoryServices,则方法有很多了。
WMI、DOS命令、API……
zxkid 2007-06-05
  • 打赏
  • 举报
回复
How to add a user to the local system by using directory services and Visual C#
kb306273
http://support.microsoft.com/kb/306273/en-us
yan63 2007-06-05
  • 打赏
  • 举报
回复
How to add a user to the local system by using directory services and Visual C#

ref:http://support.microsoft.com/kb/306273/EN-US/

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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