0
I would like to know how to list all AD groups with C# Forms, and list in a checkedListBox, in several searches I did, I only found how to list the groups of a specific user.
Note: I put the data of my AD user to do the search.
0
I would like to know how to list all AD groups with C# Forms, and list in a checkedListBox, in several searches I did, I only found how to list the groups of a specific user.
Note: I put the data of my AD user to do the search.
0
if (userName == "" || password == "")
{
return false;
}
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain, userName, password);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user)(|(cn=" + userName + ")(sAMAccountName=" + userName + ")))";
SearchResult result = mySearcher.FindOne();
foreach (string GroupPath in result.Properties["memberOf"])
{
checkedListBox1.Items.Add(GroupPath);
if (GroupPath.Contains(group))
{
return true;
}
}
}
catch (DirectoryServicesCOMException)
{
}
return false;
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
What have you tried?
– Jéf Bueno
Show how you are doing the query.
– Leandro Angelo
I posted the code that I came closest to getting.
– Anderson User777