当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 使用C#代码实现增加用户帐号

ASP.NET
Web服务器控件:LinkButton控件
Web服务器控件:ListBox控件
Web服务器控件:ListItem控件
Web服务器控件:Literal控件
Web服务器控件:Panel控件
Web服务器控件:PlaceHolder控件
Web服务器控件:RadioButton控件
Web服务器控件:RadioButtonList控件
Web服务器控件:BulletedList控件
Web服务器控件:Style控件
Web服务器控件:Table控件
Web服务器控件:TableCell控件
Web服务器控件:TableRow控件
Web服务器控件:TextBox控件
Web服务器控件:XML控件
Validation服务器控件:CompareValidator控件
Validation服务器控件:CustomValidator控件
Validation服务器控件:RangeValidator控件
Validation服务器控件:RegularExpressionValidator控件
Validation服务器控件:RequiredFieldValidator控件

ASP.NET 中的 使用C#代码实现增加用户帐号


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 155 ::
收藏到网摘: n/a


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(); } }