locked
Creating a new AD User Account RRS feed

  • Question

  • User986590904 posted

    Hello,

    I've been tasked to make a new web app that will create a new user account in the AD as well as the user folder.

    Are there any pearls of wisdom out there for me on how to preform this? Any references to complete this would be great.

     

    Thanks!
     

    Thursday, January 4, 2007 5:25 PM

All replies

  • User1359654022 posted

    Looking in the System.DirectoryServices Namespace.

    Here is an example of how to create a user

    http://www.codeproject.com/dotnet/addnewuser.asp 

    Friday, January 5, 2007 10:25 AM
  • User986590904 posted

    I think I'm confused. I've looked all over for the DirectoryServices namespace and can't find it. The article doesn't say how to reference the namespace either.

    Can you give me a bit more instruction on this?

     

    Thanks!
     

    Friday, January 5, 2007 3:14 PM
  • User1359654022 posted
    You will need to add a reference to your project to System.DirectoryServices

    The following link is the MSDN help files for the directory services.

    http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx

    I change the example a bit by removing the trace and throwing the exception so you can see what error you are getting.

    using System.DirectoryServices;

            static private void AddUser(string strDoamin, string strLogin, string strPwd)
            {
                DirectoryEntry obDirEntry = null;
                try
                {
                    obDirEntry = new DirectoryEntry("WinNT://" + strDoamin);
                    DirectoryEntries entries = obDirEntry.Children;
                    DirectoryEntry obUser = entries.Add(strLogin, "User");
                    obUser.Properties["FullName"].Add("Amigo");
                    object obRet = obUser.Invoke("SetPassword", strPwd);
                    obUser.CommitChanges();
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            static void Main(string[] args)
            {
                AddUser("<domin Name>", "<user name>", "<password>");
            }
    Saturday, January 6, 2007 8:07 AM
  • User986590904 posted

    I am running the free Visual Web Developer and using VB as my source code.

    In the code behind I'm trying to import the namespace but it's not listed in the options. Do I need to use the full Visual Studio for that or can I still use the free VWD?

     

    Thanks again!

    Monday, January 8, 2007 9:40 AM
  • User1359654022 posted

    did you add a reference to the System.DirectoryServices.dll to your project.

     

    From the project menu select Add Reference item and in the list shown select System.DirectoryServices.dll

    then you should be able to import the name space.


    Monday, January 8, 2007 10:02 AM
  • User986590904 posted

    Okay, that rules!

    Not only did I just learn something new but it worked as well! :)

    Thanks a bunch, I'll learn the rest from here.

     

    Dale
     

    Monday, January 8, 2007 11:39 AM