Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

.Net 2.0 - Create AD Group/Role

Last post 05-16-2008, 12:14 AM by dunnry. 4 replies.
Sort Posts: Previous Next
  •  05-08-2008, 9:10 AM 3491

    .Net 2.0 - Create AD Group/Role

    Hi,

    Is it possible to create a Group/Role in AD using .Net DirectoryServices?

    If so could someone point me in the direction of a code sample.

    Thanks,

    Ben.

  •  05-08-2008, 10:04 AM 3493 in reply to 3491

    Re: .Net 2.0 - Create AD Group/Role

    u can use the code

    DirectoryEntry dirEntry = new DirectoryEntry(LDAPPath, userName,passWord);
    DirectoryEntry  grp= dirEntry.Children.Add("cn=testGrp" ,"group");

  •  05-08-2008, 10:28 AM 3495 in reply to 3493

    Re: .Net 2.0 - Create AD Group/Role

    You can also use the new System.DirectoryServices.AccountManagement namespace in .NET 3.5 to create groups with the GroupPrincipal class.  I would use that if I was a beginner and had that as an option.
  •  05-08-2008, 7:30 PM 3504 in reply to 3493

    Re: .Net 2.0 - Create AD Group/Role

    Make sure your LDAPPath is complete; eg.  "LDAP://OU=Security Groups,DC=domain,DC=com"
  •  05-16-2008, 12:14 AM 3574 in reply to 3504

    Re: .Net 2.0 - Create AD Group/Role

    I would also download the sample code here on the site and check it out.  It is covered in detail in Chapter 11.  Of course, as Joe mentions, SDS.AD makes it easy now as well.

    Ryan Dunn
    Extemporaneous Mumblings
    The .NET Developer's Guide to Directory Services Programming
View as RSS news feed in XML