0

I use the same DirectoryEntry/DirectorySearcher code in all of my programs (minor changes obviously for whatever it is I am searching for) and it works on every machine except for my development machine. Maybe its the Visual Studio, IDK, I installed a new .NET Framework because I thought maybe something was screwed up.

Whenever I try to bind to AD and search for an object it gives me a "The network path was not found" error on the DirectorySearcher.FindAll() line.

Again all this code works on any other machine except this one machine which so happens to be my machine where I create and compile the code., Not that any of this matters but i thought i would mention it.

Anyone ever experience this?

Thanks

Deeeyewhy
  • 19
  • 5
  • Is this the solution https://stackoverflow.com/questions/51890580/ldap-the-network-path-was-not-found – user2316116 Mar 31 '20 at 20:49
  • Thanks, but I am not using a windows service. This is a straight console app using my main account. – Deeeyewhy Mar 31 '20 at 21:30
  • "The network path was not found" could be caused by a number of things. You can try to call same search in powershell, or vbscript to see if you get same results from there. – user2316116 Mar 31 '20 at 21:44
  • Funny enough I am able to perform AD Searches using vbScript. – Deeeyewhy Mar 31 '20 at 23:14
  • ok so on this machine I dont have admin rights. If I open a command prompt with an account with admin rights I can query AD on this machine. My question, is this a .NET Trust issue? Why can I query AD using vbScript with my account but not in .NET in my C# program? – Deeeyewhy Apr 01 '20 at 00:26

1 Answers1

1

You'll have to show us the code you're using to be sure, but I'm guessing that it's just not connecting to the domain you think it is.

If you are not setting the SearchRoot explicitly, then it uses the domain of the current user by default. So that can make sense why it works with one account and not the other - if your normal account is on a different domain than the admin account you are trying with.

That's my best guess, but you'll have to update your question with your code if you need more help than that.

Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84