def _open_conn(self, bind=True): """ Starts a server, and returns a LDAPObject bound to it """ l = _ldap.initialize(self.server.ldap_uri) if bind: self._bind_conn(l) return l
def _init(self, reuse_existing=True, bind=True): """Starts a server, and returns a LDAPObject bound to it""" server = self._init_server(reuse_existing) l = _ldap.initialize(server.get_url()) if bind: # Perform a simple bind l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3) m = l.simple_bind(server.get_root_dn(), server.get_root_password()) result,pmsg,msgid,ctrls = l.result4(m, _ldap.MSG_ONE, self.timeout) self.assertTrue(result, _ldap.RES_BIND) return l
def test_errno107(self): l = _ldap.initialize('ldap://127.0.0.1:42') try: m = l.simple_bind("", "") r = l.result4(m, _ldap.MSG_ALL, self.timeout) except _ldap.SERVER_DOWN as ldap_err: errno = ldap_err.args[0]['errno'] if errno != 107: self.fail("expected errno=107, got %d" % errno) else: self.fail("expected SERVER_DOWN, got %r" % r)
def _init(self, reuse_existing=True, bind=True): """Starts a server, and returns a LDAPObject bound to it""" server = self._init_server(reuse_existing) l = _ldap.initialize(server.get_url()) if bind: # Perform a simple bind l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3) m = l.simple_bind(server.get_root_dn(), server.get_root_password()) result,pmsg,msgid,ctrls = l.result3(m, _ldap.MSG_ONE, self.timeout) self.assertTrue(result, _ldap.RES_BIND) return l
def test_enotconn(self): l = _ldap.initialize('ldap://127.0.0.1:42') try: m = l.simple_bind("", "") r = l.result4(m, _ldap.MSG_ALL, self.timeout) except _ldap.SERVER_DOWN as ldap_err: errno_val = ldap_err.args[0]['errno'] if errno_val != errno.ENOTCONN: self.fail("expected errno=%d, got %d" % (errno.ENOTCONN, errno_val)) else: self.fail("expected SERVER_DOWN, got %r" % r)
def _open_conn(self, bind=True): """ Starts a server, and returns a LDAPObject bound to it """ l = _ldap.initialize(self.server.ldap_uri) if bind: # Perform a simple bind l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3) m = l.simple_bind(self.server.root_dn, self.server.root_pw) result, pmsg, msgid, ctrls = l.result4(m, _ldap.MSG_ONE, self.timeout) self.assertEqual(result, _ldap.RES_BIND) self.assertEqual(type(msgid), type(0)) return l