Code Snippet: How to add a user to AD with Visual Studio

So, have you ever wanted to know how you would add a user to an Active Directory data store using .NET code?

This article shows the basics of .NET development with AD, using the “Directory Services” namespace.  Including:

– How to create an object to represent an AD Object (User folder in this case)
– How to create an object to representing an User (AD Object)
– Checking to see if a User exists before adding a duplicate
– Adding the user to the AD data store
– Setting the users password in code
– Enabling the new user as an “Active” user, with information on how to “deactivate” a user

Link to article with code snippet:

Do you want to learn more?  Come to my webcast on the subject on September 30th @ 11:00AM EST.  Login information below:


Active Directory programming w/Visual Studio 2005 “Whidbey” & “Directory Services”: Part 1

This talk will be a demonstration-oriented discussion of working with Active Directory and LDAP in general from a programmer’s perspective, using Visual Studio.  Although the content in this presentation is valid in Visual Studio .NET 2003, all demonstrations will be done using Visual Studio 2005 (aka., Whidbey), and will show some of the newest features of VS 2005.

In this session will cover:

    • The basic of the Active Directory object/data structure from a developers perspective
    • The basics of the “DirectoryServices” name space.
    • How to Add/Delete/Modify AD Entries (focusing on users)

Note: This talk is from the “Developers” perspective and WILL NOT be an extensive discussion of AD planning and/or Administration.


Click to Join Live Meeting

Robert Shelton has invited you to attend a Live Meeting.

  Subject: Programming AD with VS 2005 and DirectoryServices – Part 1
  Meeting URL:
  Meeting ID: 47XX9C
  Role: Attendee

This meeting will broadcast internet audio directly to your computer.  Please ensure that you have Windows Media Player 9 or higher installed.

FIRST TIME USERS: Install the Windows-based Meeting Console before your meeting:

This Live Meeting invitation is a personal invitation; it should not be forwarded.  For assistance, please visit Live Meeting Help and Support:

– Robert


Comments (0)