# Path: ldapcherry/exceptions.py
# class UserDoesntExist(Exception):
#     def __init__(self, user, backend):
#         self.user = user
#         self.bakend = backend
#         self.log = \
#             "user '" + user + "'" \
#             " does not exist" \
#             " in backend '" + backend + "'"
# 
# class GroupDoesntExist(Exception):
#     def __init__(self, group, backend):
#         self.group = group
#         self.bakend = backend
#         self.log = \
#             "group '" + group + "'" \
#             " does not exist" \
#             " in backend '" + backend + "'"
# 
# class UserAlreadyExists(Exception):
#     def __init__(self, user, backend):
#         self.user = user
#         self.bakend = backend
#         self.log = \
#             "user '" + user + "'" \
#             " already exists" \
#             " in backend '" + backend + "'"


import cherrypy
import ldap
import ldap.modlist as modlist
import ldap.filter
import logging
import ldapcherry.backend
import sys
import os
import re
from ldapcherry.exceptions import UserDoesntExist, \
    GroupDoesntExist, \
    UserAlreadyExists
    from sets import Set as set
# -*- coding: utf-8 -*-
# vim:set expandtab tabstop=4 shiftwidth=4:
#
# The MIT License (MIT)
# LdapCherry
# Copyright (c) 2014 Carpentier Pierre-Francois

if sys.version < '3':

PYTHON_LDAP_MAJOR_VERSION = ldap.__version__[0]


class CaFileDontExist(Exception):
    def __init__(self, cafile):
        self.cafile = cafile
        self.log = "CA file %(cafile)s does not exist" % {'cafile': cafile}


class MissingGroupAttr(Exception):
    def __init__(self, attr):
        self.attr = attr
        self.log = "User doesn't have %(attr)s in its attributes" \
            ", cannot use it to set group" % {'attr': attr}


class MultivaluedGroupAttr(Exception):

# Path: ldapcherry/exceptions.py
# class UserDoesntExist(Exception):
#     def __init__(self, user, backend):
#         self.user = user
#         self.bakend = backend
#         self.log = \
#             "user '" + user + "'" \
#             " does not exist" \
#             " in backend '" + backend + "'"
# 
# class GroupDoesntExist(Exception):
#     def __init__(self, group, backend):
#         self.group = group
#         self.bakend = backend
#         self.log = \
#             "group '" + group + "'" \
#             " does not exist" \
#             " in backend '" + backend + "'"
# 
# class UserAlreadyExists(Exception):
#     def __init__(self, user, backend):
#         self.user = user
#         self.bakend = backend
#         self.log = \
#             "user '" + user + "'" \
#             " already exists" \
#             " in backend '" + backend + "'"


# Path: ldapcherry/backend/backendLdap.py
import cherrypy
import ldap
import ldap.modlist as modlist
import ldap.filter
import logging
import ldapcherry.backend
import sys
import os
import re
from ldapcherry.exceptions import UserDoesntExist, \
    GroupDoesntExist, \
    UserAlreadyExists
    from sets import Set as set

# -*- coding: utf-8 -*-
# vim:set expandtab tabstop=4 shiftwidth=4:
#
# The MIT License (MIT)
# LdapCherry
# Copyright (c) 2014 Carpentier Pierre-Francois

if sys.version < '3':

PYTHON_LDAP_MAJOR_VERSION = ldap.__version__[0]


class CaFileDontExist(Exception):
    def __init__(self, cafile):
        self.cafile = cafile
        self.log = "CA file %(cafile)s does not exist" % {'cafile': cafile}


class MissingGroupAttr(Exception):
    def __init__(self, attr):
        self.attr = attr
        self.log = "User doesn't have %(attr)s in its attributes" \
            ", cannot use it to set group" % {'attr': attr}


class MultivaluedGroupAttr(Exception):

    def __init__(self, attr):