views:

97

answers:

1

How can I delete a security group from Active directory in .NET?

+2  A: 

In .NET 3.5 you can make use of the new namespace System.DirectoryServices.AccountManagement and try the following:

var SecurityContext= new PrincipalContext(ContextType.Domain);
var TheGroup = GroupPrincipal.FindByIdentity(SecurityContext, "GROUP_NAME");
TheGroup.Delete();

Obviously the user under which the code is running needs to have delete permissions.

Flo