def get_directory_at(socket, user, password, basedn=None, use_tls=False, server_type=STANDARD_LDAP): res = LDAPResource() res.server = socket res.login = user res.password = password res.basedn = basedn res.tls = use_tls res.server_type = server_type directory = Directory() directory.connect(res) return directory
def get_directory(): global _directory if not _directory: res = LDAPResource() res.server = config.LDAP_SOCKET res.login = config.LDAP_LOGIN res.password = config.LDAP_PASSWORD res.tls = getattr(config, 'LDAP_TLS', False) res.basedn = config.LDAP_BASEDN _directory = Directory() _directory.connect(res) return _directory