Hi guys,
I have found interesting code..
Unfortunatelly I dont know how to use it :/

public void Delete(string ouPath, string groupPath)
{
    if (DirectoryEntry.Exists("LDAP://" + groupPath))
    {
        try
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://" + ouPath);
            DirectoryEntry group = new DirectoryEntry("LDAP://" + groupPath);
            entry.Children.Remove(group);
            group.CommitChanges();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message.ToString());
        }
    }
    else
    { 
        Console.WriteLine(path + " doesn't exist"); 
    }
}

I don't know whats the difference bewteen ouPath and groupPath
At first I thought that
groupPath is

LDAP://CN=GRUPA TESTOWA,OU=Security,OU=Groups,OU=Krakow,OU=PL-PMPL,OU=PMI,OU=Users & Workstations,DC=LORDAC,DC=NET

and ouPath is:

LDAP://OU=Security,OU=Groups,OU=Krakow,OU=PL-PMPL,OU=PMI,OU=Users & Workstations,DC=LORDAC,DC=NET

But it doesnt work...
I need to delete group and I really dunno how to modify that code :/
Can you help me?
Thanks in advance!

Hi guys,
I have found interesting code..
Unfortunatelly I dont know how to use it :/

public void Delete(string ouPath, string groupPath)
{
    if (DirectoryEntry.Exists("LDAP://" + groupPath))
    {
        try
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://" + ouPath);
            DirectoryEntry group = new DirectoryEntry("LDAP://" + groupPath);
            entry.Children.Remove(group);
            group.CommitChanges();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message.ToString());
        }
    }
    else
    { 
        Console.WriteLine(path + " doesn't exist"); 
    }
}

I don't know whats the difference bewteen ouPath and groupPath
At first I thought that
groupPath is

LDAP://CN=GRUPA TESTOWA,OU=Security,OU=Groups,OU=Krakow,OU=PL-PMPL,OU=PMI,OU=Users & Workstations,DC=LORDAC,DC=NET

and ouPath is:

LDAP://OU=Security,OU=Groups,OU=Krakow,OU=PL-PMPL,OU=PMI,OU=Users & Workstations,DC=LORDAC,DC=NET

But it doesnt work...
I need to delete group and I really dunno how to modify that code :/
Can you help me?
Thanks in advance!

The code you listed above is from an awesome article written by my good friend and coworker, Thund3rstruck. You can read the entire thing with complete explanations on CodeProject. The article is entitled, "Howto: (Almost) Everything in Active Directory Via C#". Here is the link: http://www.codeproject.com/KB/system/everythingInAD.aspx#33

The code you listed above is from an awesome article written by my good friend and coworker, Thund3rstruck. You can read the entire thing with complete explanations on CodeProject. The article is entitled, "Howto: (Almost) Everything in Active Directory Via C#". Here is the link: http://www.codeproject.com/KB/system/everythingInAD.aspx#33

Yeah I took it directly from that page.. :)

Yeah I took it directly from that page.. :)

What is it that you don't understand, or cannot get working? What is the environment you are using (AD)?

I cannot get it working...
I dunno if I provide input data well...
ouPath and groupPath...
I think that ouPath is the same like groupPath - but without CN part, Right?
Unfortunately when I provide input in that manner, i receive an error (GENERAL ACCESS ERROR)...Its strange because I have all accesses...I can delete that group manually in AD or by using DS commands from command line...

Hmmh checked several combinations (paths with "LDAP://" and wothout "LDAP://")
Still it doesnt work :(

This article has been dead for over six months. Start a new discussion instead.