JLDAP/search
From Joomla! Documentation
< API16:JLDAPRevision as of 17:39, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Perform an LDAP search
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
...)
Revision as of 17:39, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Perform an LDAP search
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
...)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Perform an LDAP search
Template:Description:JLDAP/search
Syntax[edit]
search($filters, $dnoverride=null)
Parameter Name | Default Value | Description |
---|---|---|
$filters | Search Filters (array of strings) | |
$dnoverride | null | DN Override |
Returns[edit]
array Multidimensional array of results public
Defined in[edit]
libraries/joomla/client/ldap.php
Importing[edit]
jimport( 'joomla.client.ldap' );
Source Body[edit]
function search($filters, $dnoverride = null)
{
$attributes = array ();
if ($dnoverride) {
$dn = $dnoverride;
} else {
$dn = $this->base_dn;
}
$resource = $this->_resource;
foreach ($filters as $search_filter)
{
$search_result = @ldap_search($resource, $dn, $search_filter);
if ($search_result && ($count = @ldap_count_entries($resource, $search_result)) > 0)
{
for ($i = 0; $i < $count; $i++)
{
$attributes[$i] = Array ();
if (!$i) {
$firstentry = @ldap_first_entry($resource, $search_result);
} else {
$firstentry = @ldap_next_entry($resource, $firstentry);
}
$attributes_array = @ldap_get_attributes($resource, $firstentry); // load user-specified attributes
// ldap returns an array of arrays, fit this into attributes result array
foreach ($attributes_array as $ki => $ai)
{
if (is_array($ai))
{
$subcount = $ai['count'];
$attributes[$i][$ki] = Array ();
for ($k = 0; $k < $subcount; $k++) {
$attributes[$i][$ki][$k] = $ai[$k];
}
}
}
$attributes[$i]['dn'] = @ldap_get_dn($resource, $firstentry);
}
}
}
return $attributes;
}
[Edit See Also] Template:SeeAlso:JLDAP/search
Examples[edit]
<CodeExamplesForm />