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: https://blogs.msdn.com/federaldev/articles/472935.aspx

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
Abstract:

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.

https://www.livemeeting.com/cc/microsoft/join?id=47XX9C&role=attend

Subject: Programming AD with VS 2005 and DirectoryServices - Part 1
Meeting URL: https://www.livemeeting.com/cc/microsoft/join
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:
https://r.office.microsoft.com/r/rlidLiveMeeting?p1=7&p2=en_US&p3=LMInfo&p4=DownloadWindowsConsole

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

https://r.office.microsoft.com/r/rlidLiveMeeting?p1=7&p2=en_US&p3=LMInfo&p4=support

- Robert