首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请问怎么在Win2003系统中通过程序或者脚本添加用户组和用户

2012-03-16 
请教如何在Win2003系统中通过程序或者脚本添加用户组和用户?我想知道在C#或者VB.NET中如何通过程序来添加

请教如何在Win2003系统中通过程序或者脚本添加用户组和用户?
我想知道在C#或者VB.NET中如何通过程序来添加用户组和用户。
我大楷晓得用System.DirectoryServices类来处理。不过现在我没有什么头绪,以前也没有涉及过。希望那位能提供一个稍微详细一点的解决方案。
多谢!

[解决办法]
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/
[解决办法]
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
[解决办法]
如果不限于DirectoryServices,则方法有很多了。
WMI、DOS命令、API……
[解决办法]
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();

}

}


}
}
[解决办法]
大家帮忙解决一下这个问题吧,谢谢了..............
http://community.csdn.net/Expert/topic/5581/5581312.xml?temp=.6539881
[解决办法]
要使用System.DirectoryServices似乎要系统支持的。
似乎要在域里才可以
[解决办法]
net user /add
[解决办法]
http://www.xrss.cn/Info/13717.Html
http://tonyqus.cnblogs.com/archive/2004/12/26/82120.aspx

热点排行