@@ -0,0 +1,1783 @@
+# -*- coding: utf-8 -*-%0A%0A# Andy Sayler%0A# Summer 2014%0A# Univerity of Colorado%0A%0Aimport logging%0A%0Aimport ldap%0A%0Aimport config%0A%0Alogger = logging.getLogger(__name__)%0Alogger.setLevel(logging.DEBUG)%0Alogger.addHandler(logging.NullHandler())%0A%0Aclass Authenticator(object):%0A%0A    def __init__(self):%0A%0A        # Call Parent%0A        super(Authenticator, self).__init__()%0A%0A        # Setup Vars%0A        self.host = config.AUTHMOD_LDAP_HOST%0A        self.basedn = config.AUTHMOD_LDAP_BASEDN%0A%0A    def auth_user(self, username, password):%0A%0A        logger.info(%22AUTH_INFO: Starting auth for %7B:s%7D%22.format(username))%0A%0A        user_dn = %22uid=%22+username+self.basedn%0A        base_dn = self.basedn%0A%0A        ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)%0A        l = ldap.initialize(self.host)%0A        l.set_option(ldap.OPT_REFERRALS, 0)%0A        l.set_option(ldap.OPT_PROTOCOL_VERSION, 3)%0A        l.set_option(ldap.OPT_X_TLS,ldap.OPT_X_TLS_DEMAND)%0A        l.set_option( ldap.OPT_X_TLS_DEMAND, True )%0A        l.set_option( ldap.OPT_DEBUG_LEVEL, 255 )%0A%0A        search_filter = %22uid=%22+username%0A%0A        try:%0A            logger.info(%22AUTH_ATTEMPT: Trying %7B:s%7D%22.format(username))%0A            l.bind_s(user_dn,password)%0A            result = l.search_s(base_dn,ldap.SCOPE_SUBTREE,search_filter)%0A            l.unbind_s()%0A            ret = True%0A        except ldap.LDAPError:%0A            l.unbind_s()%0A            logger.error(%22AUTH_ERROR: Failed %7B:s%7D - %7B:s%7D%22.format(username, e))%0A            ret = False%0A%0A        if ret:%0A            logger.info(%22AUTH_ALLOWED: Authenticated %7B:s%7D%22.format(username))%0A        else:%0A            logger.warning(%22AUTH_DENIED: Denied %7B:s%7D%22.format(username))%0A            ret = None%0A%0A        logger.info(%22AUTH_INFO: Completed auth for %7B:s%7D%22.format(username))%0A        return ret%0A

add initial authmod_ldap.py