LdapTools\Connection\LdapControl::toArray PHP Method

toArray() public method

Get the control array structure that ldap_set_option expects.
public toArray ( ) : array
return array
    public function toArray()
    {
        $control = ['oid' => $this->oid, 'iscritical' => $this->criticality];
        if (!is_null($this->value)) {
            $control['value'] = $this->value;
        }
        return $control;
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function setControl(LdapControl $control)
 {
     // To set a a server control we must first be bound...
     if (!$this->isBound()) {
         $this->connect();
     }
     if (!@ldap_set_option($this->connection, LDAP_OPT_SERVER_CONTROLS, [$control->toArray()]) && $control->getCriticality()) {
         throw new LdapConnectionException(sprintf('Unable to set control for OID "%s".', $control->getOid()));
     }
 }