1

Basically I want to connect to an LDAP database from C# .Net and return an array of objects.

We have a third party piece of software which is successfully doing this in PHP, the PHP code is below:

$ds = @ldap_connect("127.0.0.1",4000)
@ldap_bind($ds,"XXXXX","88888")
$sr=@ldap_list($ds,"cn=Registrations","objectclass=RegistrationRecord",$att);
$info=@ldap_get_entries($ds,$sr);

Where the heck do I start repeating this in C#? I'm not even looking for a full solution, just a nudge in the right direction from somebody would help massively as I am lost!

Thanks

John

Darren
  • 68,902
  • 24
  • 138
  • 144
JMK
  • 27,273
  • 52
  • 163
  • 280

1 Answers1

2

You can use the Directory Entry or LdapConnection Class:

DirectoryEntry de = new DirectoryEntry("LDAP://127.0.0.1","admin","password",AuthenticationTypes.None);
DirectorySearcher ds = new DirectorySearcher(de);
var findAll = ds.FindAll();

Sources:

Connecting to LDAP from C# using DirectoryServices

LDAP Connection

Connecting to an LDAP Connection

Community
  • 1
  • 1
Darren
  • 68,902
  • 24
  • 138
  • 144