X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=ldapdb%2F__init__.py;h=f466bea042775db05af17b11cac52939b195b1d5;hb=29d308dca099fd6365d272c8a0bb2b8206562f87;hp=60b6c865710b64130469fe4f51f4a8194b1ade6f;hpb=42cdc5b4d6ae4524a450d71dd128129378040440;p=matthijs%2Fupstream%2Fdjango-ldapdb.git diff --git a/ldapdb/__init__.py b/ldapdb/__init__.py index 60b6c86..f466bea 100644 --- a/ldapdb/__init__.py +++ b/ldapdb/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # django-ldapdb -# Copyright (C) 2009 Bolloré telecom +# Copyright (C) 2009-2010 Bolloré telecom # See AUTHORS file for a full list of contributors. # # This program is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ import ldap from django.conf import settings +from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations def convert(field, value, func): if not value or field == 'jpegPhoto': @@ -31,12 +32,29 @@ def convert(field, value, func): return [ func(x) for x in value ] else: return func(value) - + +def escape_ldap_filter(value): + value = str(value) + return value.replace('\\', '\\5c') \ + .replace('*', '\\2a') \ + .replace('(', '\\28') \ + .replace(')', '\\29') \ + .replace('\0', '\\00') + +class DatabaseFeatures(BaseDatabaseFeatures): + pass + +class DatabaseOperations(BaseDatabaseOperations): + def quote_name(self, name): + return name + class LdapConnection(object): def __init__(self, server, bind_dn, bind_password): self.connection = ldap.initialize(server) self.connection.simple_bind_s(bind_dn, bind_password) self.charset = "utf-8" + self.features = DatabaseFeatures() + self.ops = DatabaseOperations() def add_s(self, dn, modlist): mods = []