You are here

public function SimpleLdap::ldapUnbind in Simple LDAP 8

Wrapper function for ldap_unbind().

Return value

boolean TRUE on success

Throws

SimpleLdapException

1 call to SimpleLdap::ldapUnbind()
SimpleLdap::__destruct in src/SimpleLdap.php

File

src/SimpleLdap.php, line 244

Class

SimpleLdap
A wrapper for PHP's LDAP functions, with associated helper methods.

Namespace

Drupal\simple_ldap

Code

public function ldapUnbind() {
  $return = FALSE;

  // Check that the LDAP connection is currently bound.
  if ($this->bound && $this->connection
    ->getResource()) {

    // If unbinding is successful, $return should be TRUE.
    $return = @ldap_unbind($this->connection
      ->getResource());
    if (!$return) {
      throw new SimpleLdapException('ldap_unbind wrapper: ', $this->connection
        ->getResource());
    }
  }
  $this->bound = FALSE;
  return $return;
}