def get_ldap(cls, global_options=None):
if cls.ldap is None:<EOL><INDENT>import ldap.filter<EOL>try:<EOL><INDENT>import ldap.dn<EOL><DEDENT>except ImportError:<EOL><INDENT>from django_auth_ldap import dn<EOL>ldap.dn = dn<EOL><DEDENT>cls.ldap = ldap<EOL><DEDENT>if (not cls._ldap_configured) and (global_options is not None):<EOL><INDENT>for opt, value in global_options.items():<EOL><INDENT>cls.ldap.set_option(opt, value)<EOL><DEDENT>cls._ldap_configured = True<EOL><DEDENT>return cls.ldap<EOL>
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.