File tree Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -176,9 +176,7 @@ def connect(self):
176
176
connect() -> None
177
177
Establishes LDAP connection if needed.
178
178
"""
179
- if _ldap .VENDOR_VERSION >= 20500 :
180
- return self ._ldap_call (self ._l .connect )
181
- raise NotImplementedError
179
+ return self ._ldap_call (self ._l .connect )
182
180
183
181
def abandon_ext (self ,msgid ,serverctrls = None ,clientctrls = None ):
184
182
"""
Original file line number Diff line number Diff line change @@ -1507,12 +1507,21 @@ l_ldap_extended_operation(LDAPObject *self, PyObject *args)
1507
1507
1508
1508
/* ldap_connect */
1509
1509
1510
- #if LDAP_VENDOR_VERSION >= 20500
1511
1510
static PyObject *
1512
1511
l_ldap_connect (LDAPObject * self , PyObject Py_UNUSED (args ))
1513
1512
{
1513
+ #if LDAP_VENDOR_VERSION >= 20500
1514
1514
int ldaperror ;
1515
1515
1516
+ if (ldap_version_info .ldapai_vendor_version < 20500 )
1517
+ #endif
1518
+ {
1519
+ PyErr_SetString (PyExc_NotImplementedError ,
1520
+ "loaded libldap doesn't support this feature" );
1521
+ return NULL ;
1522
+ }
1523
+
1524
+ #if LDAP_VENDOR_VERSION >= 20500
1516
1525
if (not_valid (self ))
1517
1526
return NULL ;
1518
1527
@@ -1525,8 +1534,8 @@ l_ldap_connect(LDAPObject *self, PyObject Py_UNUSED(args))
1525
1534
1526
1535
Py_INCREF (Py_None );
1527
1536
return Py_None ;
1528
- }
1529
1537
#endif
1538
+ }
1530
1539
1531
1540
/* methods */
1532
1541
@@ -1557,9 +1566,7 @@ static PyMethodDef methods[] = {
1557
1566
{"cancel" , (PyCFunction )l_ldap_cancel , METH_VARARGS },
1558
1567
#endif
1559
1568
{"extop" , (PyCFunction )l_ldap_extended_operation , METH_VARARGS },
1560
- #if LDAP_VENDOR_VERSION >= 20500
1561
1569
{"connect" , (PyCFunction )l_ldap_connect , METH_NOARGS },
1562
- #endif
1563
1570
{NULL , NULL }
1564
1571
};
1565
1572
Original file line number Diff line number Diff line change @@ -281,7 +281,8 @@ def test_simple_anonymous_bind(self):
281
281
self .assertEqual (ctrls , [])
282
282
283
283
@unittest .skipUnless (
284
- _ldap .VENDOR_VERSION >= 20500 ,
284
+ _ldap .VENDOR_VERSION >= 20500 and \
285
+ _ldap ._VENDOR_VERSION_RUNTIME >= 20500 ,
285
286
reason = "Test requires libldap 2.5+"
286
287
)
287
288
def test_connect (self ):
@@ -293,6 +294,15 @@ def test_connect(self):
293
294
294
295
self ._bind_conn (l )
295
296
297
+ @unittest .skipUnless (
298
+ _ldap ._VENDOR_VERSION_RUNTIME < 20500 ,
299
+ reason = "Test requires linking to libldap < 2.5"
300
+ )
301
+ def test_connect_notimpl (self ):
302
+ l = self ._open_conn (bind = False )
303
+ with self .assertRaises (NotImplementedError ):
304
+ l .connect ()
305
+
296
306
def test_anon_rootdse_search (self ):
297
307
l = self ._open_conn (bind = False )
298
308
# see if we can get the rootdse with anon search (without prior bind)
You can’t perform that action at this time.
0 commit comments