I've got some processes that require the domain name of the current LDAP provider (basically, to synchronize user info from AD).
The process prompts the user for the source LDAP server, but provides info on the default one (so one can just use the default value).
The following code works for user workstations, but fails on servers:
var uri = "LDAP://" + Environment.GetEnvironmentVariable("LOGONSERVER");
I also tried "ldap://rootDSE"
but a NotSupportedException
was thrown:
The provider does not support searching and cannot search LDAP://rootDSE.
So, I've got a few questions:
- Why is
LOGONSERVER
envvar unavailable on servers? - What can I do instead?
- As I take it, RootDSE is a stepping stone towards the real LDAP server?
After further investigating RootDSE, I came up with this code:
It seems to do what I need.
However, the rest of my questions above remain unanswered.