Click here to Skip to main content
15,937,429 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to create group in server using idap connection. please tel me the solution
Posted

1 solution

Don't repost. Try something from answers to your previous question[^].
I already suggested to use
C#
public void Create(string ouPath, string name)
{
    if (!DirectoryEntry.Exists("LDAP://CN=" + name + "," + ouPath))
    {
        try
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://" + ouPath);
            DirectoryEntry group = entry.Children.Add("CN=" + name, "group");
            group.Properties["sAmAccountName"].Value = name;
            group.CommitChanges();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message.ToString());
        }
    }
    else { Console.WriteLine(path + " already exists"); }
}
 
Share this answer
 
v2
Comments
Nickos_me 14-Nov-11 6:57am    
Hm..
I think, it's not good that you don't use using across of DirectoryEntry:
http://connect.microsoft.com/VisualStudio/feedback/details/675780/net-4-0-directoryentry-memory-leaks
Or I did't right?
Prerak Patel 14-Nov-11 7:09am    
This code is from the linked article in OP's previous question. I was pointing him to that, so that he stops reposting the same question.
Nickos_me 14-Nov-11 9:00am    
Yes, sorry, I understand.
But I just ask you for your opinion :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900