I have a problem with C# accessing AD objects. The goal of the code is to retrieve a users's groups. We have 2 domains involved - the domain where the application and many users reside, plus a trusted domain that also contains users so the code must be able to get groups from both domains.
I am using a DirectorySearcher object and filtering it based on the user SID. It's packaged into a DLL to be used by applications. The application currently uses the same code and it works, but when it calls the DLL, the DLL won't return anything from AD. It cannot retrieve any users from the FindOne() call.
We ran into a similar problem when using a search for users before when we only had 1 domain involved, but found a workaround - we could open the user object directly, and didn't search for the object. Now that we have a second domain involved, we have to use the user's SID, and we can't just open the object.
The DLL works in one test environment, but will not work in 2 other test environments. What could be causing this type of behavior? Is this a problem with the DLL? AD Security? Application security? How do we determine if the user has access to search?
Alternatively (if we can't find a solution to this problem), how else can I get a user's groups based on their SID without using a search?