18
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
##############################################################################
21
from string import Template
22
23
class LDAPOperator:
25
26
class contains(LDAPOperator):
26
def check_value(self, ldap_entry, attribute, value):
27
def check_value(self, ldap_entry, attribute, value, ldap_config, company,
27
29
return (attribute in ldap_entry[1]) and (value in ldap_entry[1][attribute])
29
31
class equals(LDAPOperator):
30
def check_value(self, ldap_entry, attribute, value):
32
def check_value(self, ldap_entry, attribute, value, ldap_config, company,
31
34
return (attribute in ldap_entry[1]) and (str(value)==str(ldap_entry[1][attribute]))
36
class query(LDAPOperator):
37
def check_value(self, ldap_entry, attribute, value, ldap_config, company,
39
query_string=Template(value).safe_substitute(dict([(attribute,
40
ldap_entry[1][attribute][0]) for attribute in ldap_entry[1]]))
41
logger.debug('evaluating query group mapping, filter: %s'%query_string)
42
results=company.query(ldap_config, query_string)