c# - Active Directory - Find a computer in a group -
i trying simple ad query see if computer in group. following code seems intuitive enough not work. ldapstring distinguised name group computer referenced netbiosname memberof. public bool iscomputerinadgroup(string ldapstring, string netbiosname) { using (directoryentry entry = new directoryentry(string.format(@"ldap://{0}", ldapstring))) using (directorysearcher computersearch = new directorysearcher(entry)) { computersearch.filter = string.format("(&(objectcategory=computer)(cn={0}))", netbiosname); searchresult match = computersearch.findone(); if (match != null) { return true; } } return false; } can please explain why incorrect , correct/fastest way to perform search is. thanks p your basic assumption wrong - computer (or user) cannot in group implying "containment" inside group; user or computer inside ou. a user or computer can member of number of gr...