I have 2 Domains. Domain A and Domain B connected via a 2 way Trust. I'm trying to perform an LDAP query in .NET to the Active Directory from one Domain to the other Domain.
The Active Directory sits in Domain B. I've logged in from my PC which sits in Domain A started up Visual Studio and created a ConsoleApp in C#. My code is below.
Every time it executes the FindOne() method, it throws a "Logon failure: unknown user name or bad password" error.
I am extremely frustrated why this is not working because I can't seem to query an Active Directory in Domain B from Domain A.
I have already asked our Network Admin to create a service account in Domain B.
Can somebody please help? I am stumped!!!
DirectoryEntry dEntry = new DirectoryEntry("LDAP://OU=Users,OU=ABC,DC=XXX,DC=YYY,DC=local", "XXX.YYY.local\\serviceAccount", "password");
DirectorySearcher dSearcher = new DirectorySearcher(dEntry);
dSearcher.Filter = "(SAMAccountName=firstname.lastname)";
SearchResult result = dSearcher.FindOne();