Adding Groups (and users to groups) to Active Directory with .NET

Play Adding Groups (and users to groups) to Active Directory with .NET
Sign in to queue


Federal Developer Evangelist, Robert Shelton, takes you through a 8 minute walkthrough/demonstration of how to create a group in active directory with .NET and to add users to that group.  This demonstration is using the DirectoryServices namespace of the .NET framework.

You can find the code at my blog: 

My other Programming AD Screen Casts:
- Searching AD with .NET:
- Adding users to Active Directory with .NET
List of Group attributes for Active Directory:
List of values for the groupType Attribuet:




Download this episode

The Discussion

  • User profile image
    While it's nice of you to help people by posting this webcast, I really think that it's completely worthless that there is no source code that can be downloaded. It's really hard to remember everything from the webcast, and it's even harder to copy/paste from windows media player!!! Perplexed

  • User profile image
    Robert Shelton
    Good feedback, flabbergasted...I will check to see if I still have the sample code and if so, I will post the code in the presentation section (left navigation) of  Going forward, I will make this a part of my process, to make it easier for everyone.

    Again, thanks for stating the obvious.  Sometimes the obvious, isn't so obvious! Wink
  • User profile image
    Robert Shelton
    I checked and I don't have that demo saved anywhere, but I did have the original "full" demonstration application that I took the smaller demos for the screencast from.  For those who are interested, it will be on on the left hand navigation under presentations, under Robert Shelton. 

    Again, in the future, I will save the demo code and posted it with a link within the Screencast description form.

  • User profile image
    That was cool thanks!. Code would be nice.
  • User profile image
    I thought the screen show was great it is what I was looking for.

    I'm having trouble finding the source code for the project.  Could you post a link to the source code?

  • User profile image
    I'm also having an issue with the DirectoryEntry.Exists command it keeps telling me that

    "Logon failure: unknown user name or bad password."

    I would have thought that adUserFolder object would contain the connection information since I specified at the beginning.

    Any ideas?

  • User profile image
    Exactly what I'm looking for thanks!

    Has anyone resolved the Logon failure: unkown user name or bad password?  I'm having the same issue, only when I used the Exists function.

    Here is an screen shot of my issue.

    I know it isn't permission problem, because if I comment out the line that causes the error:

    // if (DirectoryEntry.Exists(newUser.Path)) return;

    Then it works fine, but if the user doesn't exist in AD.

    In other words, I can commit with no problems.

    Just for the sake of permissions, I even logged in as administrator, still the same problem.

  • User profile image
    We just discovered why I was getting the error.

    I was trying to use the DirectoryEntry.Exist() function on a non trusted computer to the test AD Domain Controller.

    Since you pass the username and password when adding the user to the User group, the account is enough for the DirectoryEntry object to validate with AD.

    So remember that when testing on a system to make sure that system is part of the domain.
  • User profile image
    I wish I had found this page 3 days ago.  The code sample that I was working off of was this:">

    That says:

    The following Visual Basic .NET example demonstrates how to add a single member to a group.

    Visual Basic
    ' Bind to the group.
    Dim group As New DirectoryEntry(groupDN)
    ' Add the user to the group.
    ' Commit the changes to the group.

    Can anyone tell me what this sample is supposed to do? Is it incorrect? I tried to post Community Content that it didn't work and I successfully used group.invoke("Add",userDN) instead. But my browser just goes into some kind of loop.

Add Your 2 Cents