From ea04a6eabbda3a117472866512f771a6507d9f66 Mon Sep 17 00:00:00 2001
From: Mads Freek Petersen <freek@wayf.dk>
Date: Tue, 4 Nov 2008 23:52:20 +0000
Subject: [PATCH] =?UTF-8?q?Always=20bind=20with=20priv=5Fuser=5Fdn=20if=20?=
 =?UTF-8?q?configured=20in=20validate=20as=20per=20Miguel=20Cabe=C3=A7a's?=
 =?UTF-8?q?=20patch.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Otherwise using validate for getting attributes (not authenticate eg. from cas)
would only bind with priv_user_dn when also searching for the dn was configured.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@976 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Auth/LDAP.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php
index e304c79f9..328bd6e9c 100644
--- a/lib/SimpleSAML/Auth/LDAP.php
+++ b/lib/SimpleSAML/Auth/LDAP.php
@@ -186,12 +186,12 @@ class SimpleSAML_Auth_LDAP {
 		$username = addcslashes($username, ',+"\\<>;*');
 		$password = addcslashes($password, ',+"\\<>;*');
 		
+		if (isset($config['priv_user_dn']) && !$this->bind($config['priv_user_dn'], $config['priv_user_pw']) ) {
+			throw new Exception('Could not bind with system user: ' . $config['priv_user_dn']);
+		}
 		if (isset($config['dnpattern'])) {
 			$dn = str_replace('%username%', $username, $config['dnpattern']);
 		} else {
-			if (isset($config['priv_user_dn']) && !$this->bind($config['priv_user_dn'], $config['priv_user_pw']) ) {
-				throw new Exception('Could not bind with system user: ' . $config['priv_user_dn']);
-			}
 			$dn = $this->searchfordn($config['searchbase'], $config['searchattributes'], $username);	
 		}
 
-- 
GitLab