diff --git a/auth/cas/auth.php b/auth/cas/auth.php
index <HASH>..<HASH> 100644
--- a/auth/cas/auth.php
+++ b/auth/cas/auth.php
@@ -422,6 +422,7 @@ class auth_plugin_cas extends auth_plugin_ldap {
 
         // Test for group creator
         if (!empty($this->config->groupecreators)) {
+            $ldapconnection = $this->ldap_connect();
             if ($this->config->memberattribute_isdn) {
                 if(!($userid = $this->ldap_find_userdn($ldapconnection, $extusername))) {
                     return false;
MDL-<I> auth_cas: Fixed issue with undefined variable: ldapconnection