LDAP
LDAP
- Full name:
\Hazaar\Net\LDAP
Properties
conn
private ?\LDAP\Connection $conn
suffix
private string $suffix
Methods
__construct
LDAP constructor.
public __construct(string $host, int $port = 389, int $version = 3): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$host | string | If you are using OpenLDAP 2.x.x you can specify a URL instead of the hostname. To use LDAP with SSL, compile OpenLDAP 2.x.x with SSL support, configure PHP with SSL, and set this parameter as ldaps://hostname/. |
$port | int | The port to connect to. Not used when using URLs. |
$version | int | The LDAP protocol version used to communicate with the server |
setBaseSuffix
Sets the BaseDN suffix to apply to method calls.
public setBaseSuffix(string $base): void
This suffix is applied to methods that require a baseDN parameter, such as Hazaar\LDAP::search().
Parameters:
Parameter | Type | Description |
---|---|---|
$base | string | The base DN to append |
bind
public bind(string $user, ?string $secret = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$user | string | |
$secret | ?string |
search
Search LDAP tree.
public search(string $filter, string $base = null, string[] $attributes = null, null $attrsonly = null, null $sizelimit = null, null $timelimit = null, null $deref = null): array|false
Performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory.
Parameters:
Parameter | Type | Description |
---|---|---|
$filter | string | The search filter can be simple or advanced, using boolean operators in the format described in the LDAP documentation (see the » Netscape Directory SDK for full information on filters). |
$base | string | The base DN for the directory |
$attributes | string[] | An array of the required attributes, e.g. ["mail", "sn", "cn"]. Note that the "dn" is always returned irrespective of which attributes types are requested. Using this parameter is much more efficient than the default action (which is to return all attributes and their associated values). The use of this parameter should therefore be considered good practice. |
$attrsonly | null | Should be set to 1 if only attribute types are wanted. If set to 0 both attributes types and attribute values are fetched which is the default behaviour. |
$sizelimit | null | Enables you to limit the count of entries fetched. Setting this to 0 means no limit. p(notice). This parameter can NOT override server-side preset sizelimit. You can set it lower though. Some directory server hosts will be configured to return no more than a preset number of entries. If this occurs, the server will indicate that it has only returned a partial results set. This also occurs if you use this parameter to limit the count of fetched entries. |
$timelimit | null | Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit. p(notice). This parameter can NOT override server-side preset timelimit. You can set it lower though. |
$deref | null | Specifies how aliases should be handled during the search. It can be one of the following: * LDAP_DEREF_NEVER - (default) aliases are never dereferenced. * LDAP_DEREF_SEARCHING - aliases should be dereferenced during the search but not when locating the base object of the search. * LDAP_DEREF_FINDING - aliases should be dereferenced when locating the base object but not during the search. * LDAP_DEREF_ALWAYS - aliases should be dereferenced always. |
add
Add entries to LDAP directory.
public add(string $dn, array $entry): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$dn | string | The distinguished name of an LDAP entity |
$entry | array | An array that specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0. |
modify
Modify the existing entries in the LDAP directory.
public modify(string $dn, array $entry): bool
The structure of the entry is same as in Hazaar\LDAP::add().
Parameters:
Parameter | Type | Description |
---|---|---|
$dn | string | The distinguished name of an LDAP entity |
$entry | array | An array that specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0. |
delete
Delete an entry from a directory.
public delete(string $dn): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$dn | string | The distinguished name of an LDAP entity |
modAdd
Add attribute values to current attributes.
public modAdd(string $dn, array $entry): bool
Adds one or more attributes to the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level additions are done by the Hazaar\LDAP::add() function.
Parameters:
Parameter | Type | Description |
---|---|---|
$dn | string | The distinguished name of an LDAP entity |
$entry | array |
modReplace
Replace attribute values to current attributes.
public modReplace(string $dn, array $entry): bool
Replaces one or more attributes from the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level modifications are done by the Hazaar\LDAP::modify() function.
Parameters:
Parameter | Type | Description |
---|---|---|
$dn | string | The distinguished name of an LDAP entity |
$entry | array |
modDel
Delete attribute values from current attributes.
public modDel(string $dn, array $entry): bool
Removes one or more attributes from the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level deletions are done by the Hazaar\LDAP::delete() function.
Parameters:
Parameter | Type | Description |
---|---|---|
$dn | string | The distinguished name of an LDAP entity |
$entry | array |
Automatically generated on 2024-11-14