Search code examples
c#c#-4.0active-directoryldapdirectoryentry

exception while trying to connect to Active Directory


As a project for my company I am trying to query two ADs with asp.net c#. A local one and a remote one. The local one didn't give me any trouble, connected, queried and every thing is working great.

The problem is with the remote one (located in a servers farm at the ISP location).

I am getting the "A local error has occurred" error.

The connection code I wrote:

DirectoryEntry directoryObject = new DirectoryEntry("LDAP://[SERVER IP ADDRESS]/OU=[THE OU],DC=[SUB DOMAIN],DC=[COMPANY DOMAIN NAME],DC=co,DC=il", "site\admin", "abc1234");

I've checked the port and it is open in the Firewall and I am trying to query the AD users and YES, the users list is not under users, but under a deferent OU.

Maybe some one know this? what to look for? do i need to use the DC part if i am using an IP, i just can't find a documentation about this...

Was I supposed to open 389 port as i read in the documentation??? Thank you, Erez


Solution

  • The answer was the order of the directories in the AD, the connection to defferent directories in the AD is done defferently. user is cn and other directories are ou for example...

    Thank you, Erez