From 3985daa5e0b33f1d709e581972f2184fcfbe2eea Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 17 Aug 2009 09:06:18 +0000
Subject: [PATCH] ldap: Add 'debug' and 'timeout' options.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1681 44740490-163a-0410-bde0-09ae8108e29a
---
 config-templates/authsources.php  | 12 ++++++++++++
 modules/ldap/lib/ConfigHelper.php | 20 +++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/config-templates/authsources.php b/config-templates/authsources.php
index fd16d4cf4..aee707ce1 100644
--- a/config-templates/authsources.php
+++ b/config-templates/authsources.php
@@ -95,6 +95,18 @@ $config = array(
 		/* Whether SSL/TLS should be used when contacting the LDAP server. */
 		'enable_tls' => FALSE,
 
+		/*
+		 * Whether debug output from the LDAP library should be enabled.
+		 * Default is FALSE.
+		 */
+		'debug' => FALSE,
+
+		/*
+		 * The timeout for accessing the LDAP server, in seconds.
+		 * The default is 0, which means no timeout.
+		 */
+		'timeout' => 0,
+
 		/*
 		 * Which attributes should be retrieved from the LDAP server.
 		 * This can be an array of attribute names, or NULL, in which case
diff --git a/modules/ldap/lib/ConfigHelper.php b/modules/ldap/lib/ConfigHelper.php
index b7b514e86..8f1dd5634 100644
--- a/modules/ldap/lib/ConfigHelper.php
+++ b/modules/ldap/lib/ConfigHelper.php
@@ -31,6 +31,22 @@ class sspmod_ldap_ConfigHelper {
 	private $enableTLS;
 
 
+	/**
+	 * Whether debug output is enabled.
+	 *
+	 * @var bool
+	 */
+	private $debug;
+
+
+	/**
+	 * The timeout for accessing the LDAP server.
+	 *
+	 * @var int
+	 */
+	private $timeout;
+
+
 	/**
 	 * Whether we need to search for the users DN.
 	 */
@@ -108,6 +124,8 @@ class sspmod_ldap_ConfigHelper {
 
 		$this->hostname = $config->getString('hostname');
 		$this->enableTLS = $config->getBoolean('enable_tls', FALSE);
+		$this->debug = $config->getBoolean('debug', FALSE);
+		$this->timeout = $config->getInteger('timeout', 0);
 		$this->searchEnable = $config->getBoolean('search.enable', FALSE);
 		$this->privRead = $config->getBoolean('priv.read', FALSE);
 
@@ -148,7 +166,7 @@ class sspmod_ldap_ConfigHelper {
 		assert('is_string($username)');
 		assert('is_string($password)');
 
-		$ldap = new SimpleSAML_Auth_LDAP($this->hostname, $this->enableTLS);
+		$ldap = new SimpleSAML_Auth_LDAP($this->hostname, $this->enableTLS, $this->debug, $this->timeout);
 
 		if (!$this->searchEnable) {
 			$ldapusername = addcslashes($username, ',+"\\<>;*');
-- 
GitLab