So I’ve got a project that requires I write a web app that checks against Active Directory (an ADAM instance, as it happens).
It doesn’t seem to work, for the longest time.
I’ve got my server’s address set out, I remember to use the “Distinguished Name” format of the user name, and I have the right password. I’ve selected the right AuthenticationType, and I still get an exception:
“Unknown exception (0x8000500)”.
Here’s the code that failed:
const string adamServer = “ldap://servername:389/DC=example,DC=com”;
const string adamSvcUser = “CN=userName,CN=Roles,DC=example,DC=com”;
const string adamSvcPassword = “cwazqa”;
protected void subClick(string sUserName, string sPassword)
// Find User in ADAM
DirectoryEntry root = new DirectoryEntry(adamServer,
adamSvcUser, adamSvcPassword, AuthenticationTypes.None);
I just couldn’t see anything wrong.
I’ll come back and edit this post later with the answer…
Okay, so nobody else saw the answer either – that makes me feel better.
The answer is simply that I put “ldap://” at the start of the adamServer string. The protocol specifier is case-sensitive.
Who thought that one up? Is “ldap” really different from “LDAP”? How? To what protocol does “LDAP” refer, if not to “ldap”?
So there’s your answer – the string should have been “LDAP://servername:389/DC=example,DC=com” – elements in the string other than “LDAP” are all case-insensitive.