LdapTools\DomainConfiguration::getUseTls PHP Method

getUseTls() public method

Get whether TLS will be used for the connection or not.
public getUseTls ( ) : boolean
return boolean
    public function getUseTls()
    {
        return $this->config['useTls'];
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Makes the initial connection to LDAP, sets connection options, and starts TLS if specified.
  *
  * @param null|string $server
  * @throws LdapConnectionException
  */
 protected function initiateLdapConnection($server = null)
 {
     list($ldapUrl, $server) = $this->getLdapUrl($server);
     $this->connection = @ldap_connect($ldapUrl);
     if (!$this->connection) {
         throw new LdapConnectionException(sprintf("Failed to initiate LDAP connection with URI: %s", $ldapUrl));
     }
     foreach ($this->config->getLdapOptions() as $option => $value) {
         if (!ldap_set_option($this->connection, $option, $value)) {
             throw new LdapConnectionException("Failed to set LDAP connection option.");
         }
     }
     if ($this->config->getUseTls() && !@ldap_start_tls($this->connection)) {
         throw new LdapConnectionException(sprintf("Failed to start TLS: %s", $this->getLastError()), $this->getExtendedErrorNumber());
     }
     $this->server = $server;
 }