php - LDAP dn syntax usage -


this original syntax :

$dn = "ou=users,ou=na1,dc=corp,dc=pvt"; 

i want add 1 more ou $dn.

directory structure below.
ou=na1, there 2 active directories under na1 : users , contacts

so call both active directories in single line below. (note: syntax not working)

$dn = "ou=users+contacts,ou=na1,dc=corp,dc=pvt";  

is there way add both active directories in single line?

for read operations, php supports feature called parallel searches. not simple might like, can achieve results want in single operation.

$links = array($link, $link); // yes, 2 references same link  $dns = array(     'ou=users,ou=na1,dc=corp,dc=pvt',     'ou=contacts,ou=na1,dc=corp,dc=pvt' );  $filter = 'attr=val';  // regular call ldap_search() // now, $results , array of result identifiers $results = ldap_search($links, $dns, $filter); 

you can wrap function make call simpler, like:

function ldap_multi_search($link, array $dns, $filter, array $attributes = null, $attrsonly = null, $sizelimit = null, $timelimit = null, $deref = null) {     $dns = array_values($dns);     $links = array_fill(0, count($dns), $link);      $results = ldap_search($links, $dns, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);      $retval = array();     foreach ($results $i => $result) {         if ($result === false) {             trigger_error('ldap search operation returned error dn ' . $dns[$i], e_user_warning);             continue;         }          $entries = ldap_get_entries($result);         unset($result['count']); // we'll calculate @ end          $retval = array_merge($retval, array_values($entries));     }     $entries['count'] = count($entries);      return $entries; } 

Comments