0

Our users in Active Directory are in various 'root' Organizational Units, how can I search for them?

What I currently have working is:

$search = "CN=John Doe"
$user = "username"
$psw = "password"
$server = "ldap://servername.eng.company.co.uk";
$dn = "OU=North,DC=eng,DC=company,DC=co,DC=uk"; //this is where we have others, like OU=South,DC=eng,DC=company,DC=co,DC=uk but I need the users to search them all as they don't know what OU they are in
$ds=ldap_connect($server);
$r=ldap_bind($ds, $user , $psw); 
$sr=ldap_search($ds, $dn, $search);
$data = ldap_get_entries($ds, $sr); 

if I remove the OU part completely then it brings nothing back.

I have tried making it an array and doing the ldap_search in a foreach loop but that brings nothing back either.

Please can someone point me in the right direction? many thanks

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Maff
  • 441
  • 1
  • 6
  • 27

1 Answers1

0

As ldap_search by default does a subtree-search you should be able to use

$dn = "dc=company,dc=co,dc=uk";

heiglandreas
  • 3,803
  • 1
  • 17
  • 23