My System Have 2 Computer:
Frist Computer act as A domain Controller that has a Active Directory,RADIU S Server,DHCP and DNS
Second Computer act as A Web Server(join domain with a first computer already) and use Microsoft Visual Studio Team System 2008
I create a website on a second computer to add user in active directory. I have 3 file:
1.Default.aspx - Let user fill their privacy information
2.ViewRegisterd ata.aspx - Let user confirm their information before it's added to active directory. In this file,there is a Viewregisterdat a.aspx.cs which collect user information and send to Class1.cs when users click confirm button.
3.Class1.cs - Do the process in adding user in active directory

I have a problem with a third files.
When I run the website and go to a second page that is a ViewRegisterdat a.aspx and then press a confirm button,it shows an error.
This is my code in a third file:
Frist Computer act as A domain Controller that has a Active Directory,RADIU S Server,DHCP and DNS
Second Computer act as A Web Server(join domain with a first computer already) and use Microsoft Visual Studio Team System 2008
I create a website on a second computer to add user in active directory. I have 3 file:
1.Default.aspx - Let user fill their privacy information
2.ViewRegisterd ata.aspx - Let user confirm their information before it's added to active directory. In this file,there is a Viewregisterdat a.aspx.cs which collect user information and send to Class1.cs when users click confirm button.
3.Class1.cs - Do the process in adding user in active directory

I have a problem with a third files.
When I run the website and go to a second page that is a ViewRegisterdat a.aspx and then press a confirm button,it shows an error.
This is my code in a third file:
Code:
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","Administrator@seniorproject.com","********");
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();
}
}
}
}