'Returns the ldap module. The unit test harness will assign a mock object
to _LDAPConfig.ldap. It is imperative that the ldap module not be
imported anywhere else so that the unit tests will pass in the absence
of python-ldap.'

def get_ldap(cls, global_options=None):

    if (cls.ldap is None):
        import ldap.filter
        try:
            import ldap.dn
        except ImportError:
            from django_auth_ldap import dn
            ldap.dn = dn
        cls.ldap = ldap
    if ((not cls._ldap_configured) and (global_options is not None)):
        for (opt, value) in global_options.items():
            cls.ldap.set_option(opt, value)
        cls._ldap_configured = True
    return cls.ldap
