ldap基本dn_LDAP DN语法用法

news/2023/12/1 18:18:34

对于读取操作,PHP支持称为并行搜索的功能。这并不像你想要的那么简单,但是你可以在一次操作中获得你想要的结果。

$links = array($link, $link); // yes, two references to the same link

$DNs = array(

'OU=Users,OU=NA1,DC=corp,DC=pvt',

'OU=Contacts,OU=NA1,DC=corp,DC=pvt'

);

$filter = 'attr=val';

// a regular call to ldap_search()

// only now, $results is and array of result identifiers

$results = ldap_search($links, $DNs, $filter);

你可以用这个进入功能,这将使通话更加简单,像:

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 as $i => $result) {

if ($result === false) {

trigger_error('LDAP search operation returned error for DN ' . $dns[$i], E_USER_WARNING);

continue;

}

$entries = ldap_get_entries($result);

unset($result['count']); // we'll calculate this properly at the end

$retVal = array_merge($retVal, array_values($entries));

}

$entries['count'] = count($entries);

return $entries;

}


http://www.inspinia.net/a/2403.html

相关文章