This is not the answer you are waiting for, but I hope it can help.
First ; You believe that the code works in the domain, but I don’t see where it cares about the "main user group". If you select a group as a "user core group", that group is no longer part of the member attribute.
Second ; In my understanding, the way (I hope that it’s not the only one, but I’m still looking) is to see if the user is in the group, it will "return" to search for the user's DN in the "member" attribute of the group objects. Thus, in your case, you can specify your domain and another domain. You can do this by doing ONE domain search. Here is an example of such a “recursive single-shot search” using the control:
string sFromWhere = "LDAP://WIN-COMPUTER:389/"; DirectoryEntry deBase = new DirectoryEntry(sFromWhere, "dom\\user", "password"); DirectorySearcher dsLookFor = new DirectorySearcher(deBase); dsLookFor.Filter = "(member:1.2.840.113556.1.4.1941:=CN=user1 Users,OU=MonOu,DC=dom,DC=fr)"; dsLookFor.SearchScope = SearchScope.Subtree; dsLookFor.PropertiesToLoad.Add("cn"); SearchResultCollection srcGroups = dsLookFor.FindAll();
Note: you can use a more precise filter to exclude distribution groups, for example.
Edited (to answer comment questions):
First : do you need credentials? I would say no if the request is being executed from a computer belonging to a domain or an approved domain.
The second and third . Yes, Microsoft filters are documented in the Internet Search Filter Syntax . The way I wrote this filter is to deduce from the samples.
source share