Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:46:45+00:00 2026-05-26T18:46:45+00:00

Seeking example using ADSI API to programmatically create a Windows Group. AD is Windows

  • 0

Seeking example using ADSI API to programmatically create a Windows Group. AD is Windows Active Directory http://en.wikipedia.org/wiki/Active_Directory

‘SI’ maybe Service Interface?

Anyway, this area is just not well documented. . . I have seen some PowerShell scripts . . . but really do not want to have to ensure PowerShell is installed etc. A simple program that runs and makes sure MY_XYZ_GROUP is added to the Window’s set of Groups…..

Should be easy…. Appears not so easy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:46:46+00:00Added an answer on May 26, 2026 at 6:46 pm

    ADSI = Active Directory Service Interfaces – it’s an API to talk to Active Directory to create users, groups, computer accounts in Active Directory – the network based LDAP directory for Microsoft networks.

    So do you need to create local users on a local machine/server, or do you need to create groups in your Active Directory??

    If you’re programming in .NET 3.5 and up, you should check out the System.DirectoryServices.AccountManagement (S.DS.AM) namespace. Read all about it here:

    • Managing Directory Security Principals in the .NET Framework 3.5
    • MSDN docs on System.DirectoryServices.AccountManagement

    Basically, you can define a domain context and easily find users and/or groups in AD:

    // set up domain context
    PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
    
    // find a user
    UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
    
    if(user != null)
    {
       // do something here....     
    }
    
    // create a group 
    GroupPrincipal group = new GroupPrincipal(ctx, "Group01");
    // set other properties on the group here.....
    group.Save();  
    

    The new S.DS.AM makes it really easy to play around with users and groups in AD!

    Update: unforutnately, the new S.DS.AM doesn’t work with local groups 🙁 it’s only intended for Active Directory use.

    If you need to create a local Windows group, you need to use the older DirectoryEntry approach – something like:

    // bind to your machine's WinNT:// provider
    DirectoryEntry computer = new DirectoryEntry("WinNT://YourMachineNameHere");
    
    // create a new local group on your computer
    DirectoryEntry newGroup = computer.Children.Add("NewGroupName", "Group");
    
    // save that group to the local machine
    newGroup.CommitChanges();
    
    // refresh the property cache so you can set properties like "Description" or others
    newGroup.RefreshCache();
    newGroup.Properties["description"].Value = "Description for your group....";
    newGroup.CommitChanges();
    

    Richard Mueller has a great list of Excel sheets showing all the various properties available, both on the LDAP-based Active Directory objects, as well as the very limited WinNT properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am seeking an example of using Audio Queue Services. I would like to
Recently I've been seeing a lot of this: <a href='http://widget-site-example.com/example.html'> <img src='http://widget-site-example.com/ross.jpg' alt='Ross&#39;s Widget'
Seeking help to design a layout as shown here: http://docs.google.com/Doc?docid=0AQhgDtGvE2HgZGZ6cmtua185MTd0eGdyZmc&hl=en The major challenge I
If you use the satellite GMapType using this Google-provided example in v3 of the
I have to insert a string after a certain character using Ruby. For example,
I am seeking a sample implementation of Authorize.Net DPM using Webforms, but I can't
I'm seeing a strange behavior in my code, here's an analogous example using apples
I remember seeing an example of this recently, but for the life of me
Seeking your help to get off .epub(s) sea in iPhone world... I am trying
Just seeking confirmation here : apache Thrift protocol does not seem to support running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.