Create a Active Directory User on a different branch in tree

Posted on 2005-05-04
Last Modified: 2010-04-16

I am trying to write a basic AddUser application for active directory.  I have a method that binds the admin account to the directory at the top.

Now I want to add a user in a deeper branch such as
OU=Test Accounts,OU=Users,OU=OU=IS,DC=company,DC=com

can anyone provide an example of how I would do this.  I am not clear if I need to rebind to the directory at that level.  I have tried this (its not working) but I am hoping there is a better answer.

Thanks in advance
Question by:darkstagg
    LVL 20

    Accepted Solution


    To have a fresh new user created, enable and has a correct password, you need to do this steps in order
    1. Create the user and CommitChanges
    2. Call SetPassword and CommitChanges
    3. Set userAccountControl attribute to enable the use and call CommitChanges one last time.



    Author Comment

    That helped a lot thank you.  I now need to make the account exchange 2003 as well.  Any suggestions where I can find some example code for that.  

    Thanks again this was great.


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now