using System;using System.Collections;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.DirectoryServices;namespace senior{ public class Class1 { public struct UserInfo { public string username; public string AccountName; public string firstname; public string lastname; public string address; public string email; public string displayname; public string password; public string givenName; } UserInfo newUserInfo; public Class1(string Rfirstname, string Rlastname, string Raddress, string Remail, string Rdisplayname, string Rusername, string RaccountName) { newUserInfo.firstname = Rfirstname; newUserInfo.lastname = Rlastname; newUserInfo.address = Raddress; newUserInfo.email = Remail; newUserInfo.displayname = Rdisplayname; newUserInfo.username = Rusername; newUserInfo.AccountName = RaccountName; DirectoryEntry adUserFolder = new DirectoryEntry("LDAP://10.1.0.1/CN=Users;DC=seniorproject,DC=COM","[email protected]","********"); if (adUserFolder.SchemaEntry.Name == "container") { DirectoryEntry newUser = adUserFolder.Children.Add("CN=" + newUserInfo.username, "User"); if (DirectoryEntry.Exists(newUser.Path)) { Console.Write("The user:" + newUser.Username + "exists, they will be deleted"); adUserFolder.Children.Remove(new DirectoryEntry(newUser.Path)); } newUser.Properties["AccountName"].Value = newUserInfo.AccountName; newUser.Properties["givenName"].Value = newUserInfo.firstname; newUser.Properties["sn"].Value = newUserInfo.lastname; newUser.Properties["displayName"].Value = newUserInfo.displayname; newUser.Properties["Address"].Value = newUserInfo.address; newUser.Properties["email"].Value = newUserInfo.email; //newUser.Properties["Password"].Value = "Y7l11909"; newUser.CommitChanges(); newUser.Invoke("setPassword:", "P@ssword:"); newUser.Properties["userAccountControl"].Value = 0x0200; newUser.CommitChanges(); } } } }