You are here

public function SimpleLdapServer::__set in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 SimpleLdapServer.class.php \SimpleLdapServer::__set()

Magic __set() function, handles changing server settings.

Parameters

string $name: The name of the attribute to set.

mixed $value: The value to assigned to the given attribute.

File

./SimpleLdapServer.class.php, line 192
Class to handle LDAP server connections and related operations.

Class

SimpleLdapServer
Simple LDAP server class.

Code

public function __set($name, $value) {
  switch ($name) {
    case 'host':
    case 'port':
    case 'starttls':
      $this
        ->disconnect();
    case 'binddn':
    case 'bindpw':
      $this
        ->unbind();
    case 'pagesize':
      $this->{$name} = $value;
      break;

    // Handle PHP LDAP options.
    case 'LDAP_OPT_DEREF':
    case 'LDAP_OPT_SIZELIMIT':
    case 'LDAP_OPT_TIMELIMIT':
    case 'LDAP_OPT_NETWORK_TIMEOUT':
    case 'LDAP_OPT_ERROR_NUMBER':
    case 'LDAP_OPT_REFERRALS':
    case 'LDAP_OPT_RESTART':
    case 'LDAP_OPT_HOST_NAME':
    case 'LDAP_OPT_ERROR_STRING':
    case 'LDAP_OPT_MATCHED_DN':
    case 'LDAP_OPT_SERVER_CONTROLS':
    case 'LDAP_OPT_CLIENT_CONTROLS':
      $this
        ->connect();
      SimpleLdap::ldap_get_option($this->resource, constant($name), $old_value);
      $result = SimpleLdap::ldap_set_option($this->resource, constant($name), $value);
      if ($result && $old_value != $value) {
        $this
          ->unbind();
      }
      break;

    // LDAPv3 is required, do not allow it to be changed.
    case 'LDAP_OPT_PROTOCOL_VERSION':
      return FALSE;
    default:
  }
}