# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-from django import db
from django.conf import settings
-from ldapdb.router import Router
-
def escape_ldap_filter(value):
value = unicode(value)
return value.replace('\\', '\\5c') \
# Legacy single database support
if hasattr(settings, 'LDAPDB_SERVER_URI'):
+ from django import db
+ from ldapdb.router import Router
+
# Add the LDAP backend
settings.DATABASES['ldap'] = {
'ENGINE': 'ldapdb.backends.ldap',
'NAME': settings.LDAPDB_SERVER_URI,
'USER': settings.LDAPDB_BIND_DN,
'PASSWORD': settings.LDAPDB_BIND_PASSWORD}
- connection = db.connections['ldap']
# Add the LDAP router
db.router.routers.append(Router())