You are here

protected function SimpleLdapServer::connect in Simple LDAP 7

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

Connect to the LDAP server.

@throw SimpleLdapException

Return value

boolean TRUE on success.

3 calls to SimpleLdapServer::connect()
SimpleLdapServer::bind in ./SimpleLdapServer.class.php
Connect and bind to the LDAP server.
SimpleLdapServer::__get in ./SimpleLdapServer.class.php
Magic __get() function.
SimpleLdapServer::__set in ./SimpleLdapServer.class.php
Magic __set() function, handles changing server settings.

File

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

Class

SimpleLdapServer
Simple LDAP server class.

Code

protected function connect() {
  if ($this->resource === FALSE) {

    // Set up the connection.
    $this->resource = SimpleLdap::ldap_connect($this->host, $this->port);

    // Set the LDAP version.
    SimpleLdap::ldap_set_option($this->resource, LDAP_OPT_PROTOCOL_VERSION, $this->version);

    // Set the advanced LDAP options.
    $opt_referrals = variable_get('simple_ldap_opt_referrals', TRUE);
    SimpleLdap::ldap_set_option($this->resource, LDAP_OPT_REFERRALS, (int) $opt_referrals);

    // StartTLS.
    if ($this->starttls) {
      SimpleLdap::ldap_start_tls($this->resource);
    }
  }
  return TRUE;
}