0


I'm trying to resolve this problem but I cannot get this to work.
The Question

What is wrong with my query?

The Code

private static void ExecuteQuery()
        {
            string sDomain = "10.12.14.165:389";
            string sDefaultOU = "CN=GeneralUsers,CN=Company,DC=Server,DC=LDS,DC=LOCAL";
            string sServiceUser = "myUser";
            string sServicePassword = "myPassword";


            DirectoryEntry ldapEntry = new DirectoryEntry("LDAP://" + sDomain + @"/" + sDefaultOU,
                                                          sServiceUser,
                                                          sServicePassword);

            DirectorySearcher ldapSearcher = new DirectorySearcher(ldapEntry);
            //Error Occurs here
            SearchResultCollection ldapResult = ldapSearcher.FindAll();
        }

The Error

@ SearchResultCollection ldapResult = ldapSearcher.FindAll();
Exception: There is no such object on the server.

Attention

The Object DOES Exist

Nick Prozee
  • 2,823
  • 4
  • 22
  • 49
  • 1
    If the object does exist and you are getting a message back saying it does not, most likely the service account you are using to perform the query do not have privileges to access that object – user469104 Sep 12 '14 at 13:35
  • 1
    If your server is not an AD LDS (ADAM) server, try not to specify 'sDefaultOU' in your DirectoryEntry constructor. See if the error goes away in this case. And by all means, please wrap EVERYTHING in 'using' block, especially SearchResultCollection – RX_DID_RX Sep 12 '14 at 13:36
  • 1
    the error actually seems to be here from what I am seeing at first glance`string sDefaultOU = "CN=GeneralUsers,CN=Company,DC=Server,DC=LDS,DC=LOCAL";` for example I just tried doing the following on my LDAP / AD server and I get results notice how I am using `DC=` `DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.somedomain.com/DC=somedomain,DC=com", userName, password);` – MethodMan Sep 12 '14 at 13:42
  • Without sDefaultOU i get "No such object on the server" – Nick Prozee Sep 12 '14 at 14:07
  • 1
    @NickProzee Try specifying FQDN of AD server instead its IP address. Also remove the port. – RX_DID_RX Sep 12 '14 at 14:24
  • Found it, my user was not authenticated. Changed it and now its working. Thanks everyone for all the input! I'll do some upvotes! – Nick Prozee Sep 12 '14 at 14:37

1 Answers1

0

The problem occured in the LDS Configuration. the user I was authenticating with had no rights to the LDS, the query I was using was working fine.

Nick Prozee
  • 2,823
  • 4
  • 22
  • 49