I have a service running as NetworkService which tries to access a trusted AD server (we have tried both domain trust and forest trust), but there seems to be an issue with the AD server used. A wild guess is that I have to provide a server name and a valid user from the remote domain in the new LdapConnection
but I cannot find how to get a valid server name and user and password from the TrustRelationshipInformation
.
The following code is executed on a machine in production.local
, which has a two-way trust with test.local
:
using (LdapConnection Connection = new LdapConnection(""))
SearchRequest Request = new SearchRequest("DC=test,DC=local", filter, System.DirectoryServices.Protocols.SearchScope.Subtree, allRequiredProperties);
...
SearchResponse SearchResponse = (SearchResponse)Connection.SendRequest(Request);
and it throws the error
System.DirectoryServices.Protocols.DirectoryOperationException:
The server cannot handle directory requests