请教如何在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