I have a list of Group names using the Ldap query... I have bound the list names to a data-grid in a WinForms app. When the user selects one of the group-names, an event is fired and the group name is passed to the method below:-
// Get a list of group specific users //
private List<Users> GetUsers(string groupName)
{
List<Users> groupSpecificUsers = new List<Users>();
DirectorySearcher ds = null;
DirectoryEntry de = new DirectoryEntry(domainPath);
ds = new DirectorySearcher(de);
ds.PropertiesToLoad.Add("SAMAccountName");
ds.PropertiesToLoad.Add("member");
ds.Filter = "(&(objectClass=group)(SAMAccountName=" + groupName + "))";
SearchResult sr = ds.FindOne();
if (sr != null)
{
// do whatever you need to do with the entry
}
.... return list of users that belong to the specific GroupName ....
When I put a breakpoint at the if statement... sr is listed as null... I am not understanding why its null...even though the selected group clearly has members in it...
I feel like, I dont quite understand how the specific group name is to be used in the ldap query... can anyone point me in the right direction?