From 5ee0530e2f14784becf613658eefaffd66ce98e8 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Fri, 22 Feb 2008 23:21:11 +0000
Subject: [PATCH] Initial support for UNL's CAS Authentication

---
 library/Nmc/Auth/Adapter/Cas.php  |  1 +
 library/Nmc/Auth/Adapter/Ldap.php | 27 +++++++++++++++------------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/library/Nmc/Auth/Adapter/Cas.php b/library/Nmc/Auth/Adapter/Cas.php
index 7b175d6..e5a04f4 100644
--- a/library/Nmc/Auth/Adapter/Cas.php
+++ b/library/Nmc/Auth/Adapter/Cas.php
@@ -16,5 +16,6 @@ class Nmc_Auth_Adapter_Cas implements Zend_Auth_Adapter_Interface
         if ($loggedIn) {
             return new Zend_Auth_Result(true, phpCAS::getUser());
         }
+        return new Zend_Auth_Result(false, null, array('Not signed in to CAS.'));
     }
 }
\ No newline at end of file
diff --git a/library/Nmc/Auth/Adapter/Ldap.php b/library/Nmc/Auth/Adapter/Ldap.php
index 0162d08..4bb6e9a 100644
--- a/library/Nmc/Auth/Adapter/Ldap.php
+++ b/library/Nmc/Auth/Adapter/Ldap.php
@@ -27,21 +27,24 @@ class Nmc_Auth_Adapter_Ldap implements Zend_Auth_Adapter_Interface
         $userName = $this->_userName;
         $password = $this->_password;
 
-	    try {
-            $this->_connection->bind("uid=$userName,ou=people,dc=unl,dc=edu", $password);
+        if (!$userName) {
+            return new Zend_Auth_Result(false, null, array('LDAP: No username specified.'));
+        }
 
-    		$filter = 'uid=' . $user_name;
-    		$this->_connection->search('ou=people,dc=unl,dc=edu', $filter );
-	    } catch (Nmc_Ldap_Exception $e) {
-	        if ($e->getCode() == 49) {
-	            return new Zend_Auth_Result(false, null, array($e->getMessage()));
-	        } else {
+        try {
+            $this->_connection->bind("uid=$userName,ou=people,dc=unl,dc=edu", $password);
+            $filter = 'uid=' . $userName;
+            $this->_connection->search('ou=people,dc=unl,dc=edu', $filter );
+        } catch (Nmc_Ldap_Exception $e) {
+            if ($e->getCode() == 49) {
+                return new Zend_Auth_Result(false, null, array($e->getMessage()));
+            } else {
                 throw new Zend_Auth_Adapter_Exception($e->getMessage(), $e->getCode());
-	        }
-	    } catch (Exception $e) {
+            }
+        } catch (Exception $e) {
             throw new Zend_Auth_Adapter_Exception($e->getMessage(), $e->getCode());
-	    }
+        }
 
-	    return new Zend_Auth_Result(true, $userName);
+        return new Zend_Auth_Result(true, $userName);
     }
 }
-- 
GitLab