note 125081 added to function.ldap-search
| From: | peter dot mlich at volny dot cz | Date: | Fri, 05 Jun 2020 06:57:03 +0000 |
| Subject: | note 125081 added to function.ldap-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214722@lists.php.net to get a copy of this message | ||
Example code from my ldap class.
public function query($_filter, $_att, $_ref=2, $count_bool=true)
{
$fn = 'query';
$config = $this->config;
$conn = $this->conn;
if (!$conn)
{return $this->errorConnection($fn);}
ldap_set_option($conn, LDAP_OPT_DEREF, $_ref);
$result = ldap_search($conn, $config['baseDn'], $_filter, $_att); // or
die(ldap_error($conn))
if ($result===false)
{
$this->error("Search error, neexistuje!");
return false;
}
$count = ldap_count_entries($conn, $result);
if ($count_bool && $count!=1)
{
$this->error("Search error, neni unikatni! count=".$count);
ldap_free_result($result);
return false;
}
$data = ldap_get_entries($conn, $result);
ldap_free_result($result);
return $data;
}
// ---
$filter = "(&(objectclass=person)(cn=" . $user_name . "))";
$att = array(
'uid',
'workforceID',
'employeeID',
'givenName',
'sn',
'mail'
);
$data = $this->query($filter, $att, 2, true);
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.167.36 (proxied: 2001:718:2601:258:4dbc:3838:5a25:f2e0)
----
Manual Page -- http://php.net/manual/en/function.ldap-search.php
Edit -- https://master.php.net/note/edit/125081
Del: integrated -- https://master.php.net/note/delete/125081/integrated
Del: useless -- https://master.php.net/note/delete/125081/useless
Del: bad code -- https://master.php.net/note/delete/125081/bad+code
Del: spam -- https://master.php.net/note/delete/125081/spam
Del: non-english -- https://master.php.net/note/delete/125081/non-english
Del: in docs -- https://master.php.net/note/delete/125081/in+docs
Del: other reasons-- https://master.php.net/note/delete/125081
Reject -- https://master.php.net/note/reject/125081
Search -- https://master.php.net/manage/user-notes.php