def __init__(self, srv, ldapsrv, return_to, pattern, mako_template, template_lookup, ldap_user="", ldap_pwd="", verification_endpoints=["verify"]): """ :param srv: The server instance :param ldapsrv: Which LDAP server to us :param return_to: Where to send the user after authentication :param pattern: How to find the entry to log in to. Expected to be a dictionary where key is one of "dn" or "search". And the value a dictionary with values depends on the key: If "dn" only "pattern". If "search": "base", "filterstr", "scope" "base" and "filterstr" MUST be present :param ldap_user: If a search has to be done first which user to do that as. "" is a anonymous user :param ldap_pwd: The password for the ldap_user """ UsernamePasswordMako.__init__( self, srv, mako_template, template_lookup, None, return_to, verification_endpoints=verification_endpoints) self.ldap = ldap.initialize(ldapsrv) self.ldap.protocol_version = 3 self.ldap.set_option(ldap.OPT_REFERRALS, 0) self.pattern = pattern self.ldap_user = ldap_user self.ldap_pwd = ldap_pwd