Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Create a Active Directory User on a different branch in tree


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.  company.com

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
1 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.

1. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/creating_users.asp
2. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/managing_user_passwords.asp
3. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/enabling_and_disabling_the_user_account.asp

darkstaggAuthor Commented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now