So I have a little console app that I got from an article here by John O'Donnell which queries the local Active directory and gets a list of qualified users for my app. Works like a charm.
Now all I want to do is take that same code that works perfectly and put it into a company intranet app. So I copy the code into it's class wire it up etc. Then when I got to use it, ass soon as it hits the mySearcher.FindAll() I get :
The specified domain either does not exist or could not be contacted
Now this is the exact same code that worked from the console. Here's a snippet of the code:
[STAThread]
public void get_IT()
{
DirectoryEntry entry = new DirectoryEntry("LDAP://DC=mydomain, DC=lan");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(&(objectClass=group)(CN=IT))");
foreach(SearchResult resEnt in mySearcher.FindAll()) {
.
.
.
I just cannot get my webapp to connect to the ADcontroller no matter what I use as the LDAP address.
I've tried :
LDAP://DC=mydomain.lan
LDAP://DC=server.mydomain, DC=lan
LDAP://DC=server.mydomain.lan
LDAP://DC=server/DC=mydomain, DC=lan
and several other variants. Does anyone have an idea of what to try next?