0 Replies - 592 Views - Last Post: 02 March 2010 - 12:30 AM Rate Topic: -----

#1 darkdexter  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-June 09

!Urgent Cannot modify user account in Active Directory via ASP.net

Posted 02 March 2010 - 12:30 AM

My System Have 2 Computer:

Frist Computer act as A domain Controller that has a Active Directory,RADIUS 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.ViewRegisterdata.aspx - Let user confirm their information before it's added to active directory. In this file,there is a Viewregisterdata.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 ViewRegisterdata.aspx and then press a confirm button,it shows an error.
Posted Image
This is my code in a third file:

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://;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.Invoke("setPassword:", "[email protected]:");
                        newUser.Properties["userAccountControl"].Value = 0x0200;


This post has been edited by darkdexter: 02 March 2010 - 12:31 AM

Is This A Good Question/Topic? 0
  • +

Page 1 of 1