protected function newLdap($config)
 {
     $ldap = new Ldap();
     $ldap->setHost($config['host']);
     $ldap->setPort($config['port']);
     $ldap->setDomain($config['domain']);
     $ldap->setLdapPrefix($config['suffix']);
     $ldap->setWindows(false);
     // FIXME: use configuration to determine this flag
     switch ($config['security']) {
         case 1:
             // TLS
             $ldap->setLdapTLS(true);
             $ldap->setLdapSecure(false);
             break;
         case 2:
             // SSL
             $ldap->setLdapTLS(false);
             $ldap->setLdapSecure(true);
             break;
         default:
             // unsecure
             $ldap->setLdapTLS(false);
             $ldap->setLdapSecure(false);
             break;
     }
     return $ldap;
 }