使用C#代码实现增加用户帐号

2016-01-29 12:36 15 1 收藏

使用C#代码实现增加用户帐号,使用C#代码实现增加用户帐号

【 tulaoshi.com - ASP.NET 】


using System;using System.DirectoryServices; //要增加此DLL文件
private void button3_Click(object sender, System.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(); } }

来源:https://www.tulaoshi.com/n/20160129/1486793.html

延伸阅读
很多人第一次接触到DirectX大都是通过游戏,至于安装、升级DirectX的原因无非是满足游戏运行的需要。Direct X其实是微软公司推出的一个为Windows平台的多媒体API函数库,它提供标准接口来与显卡和声卡、输入设备等进行交互。如果没有这组标准API函数库,那你就需要为每一种显卡、声卡的每个组合和每种类型的键盘、鼠标和游戏杆编写不同的代...
代码如下: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Diagnostics; using System.Threading; namespace WindowsApplication2 { /// summary /// Form1&...
using System;  using System.Data;  using System.Configuration;  using System.Collections;  using System.Web;  using System.Web.Security;  using System.Web.UI;  using System.Web.UI.WebControls;  using System.Web.UI.WebControls.W...
本文给出一个 C# Mines(布雷)的 代码 ,新手研究一下吧。 以下是引用片段: using System.Collections; using System.IO; using System; namespace com.Mines { class SearchingMines { public ArrayList list = new ArrayList(); pub...
在前两篇文章中我们讨论了XML文件的读取和写入,但都是基于流模型的解决方案,今天我们就来谈谈在C#中如何实现DOM,DOM确实有它的不足,但在编程工作中它还是不可或缺的技术。下面我们来简单了解一下DOM的相关知识。 DOM的全称是Document Object Model(文档对象模型),它是来自W3C的官方标准,它允许按照W3C标准W3C DOM Level1和W3C...

经验教程

961

收藏

59
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部