diff --git a/Doc/reference/ldap.rst b/Doc/reference/ldap.rst index fdd5d356..9cb1d520 100644 --- a/Doc/reference/ldap.rst +++ b/Doc/reference/ldap.rst @@ -1000,9 +1000,9 @@ and wait for and return with the server's result, or with *serverctrls* and *clientctrls* like described in section :ref:`ldap-controls`. -.. py:method:: LDAPObject.simple_bind([who='' [, cred='' [, serverctrls=None [, clientctrls=None]]]]) -> int +.. py:method:: LDAPObject.simple_bind([who=None [, cred=None [, serverctrls=None [, clientctrls=None]]]]) -> int -.. py:method:: LDAPObject.simple_bind_s([who='' [, cred='' [, serverctrls=None [, clientctrls=None]]]]) -> None +.. py:method:: LDAPObject.simple_bind_s([who=None [, cred=None [, serverctrls=None [, clientctrls=None]]]]) -> None After an LDAP object is created, and before any other operations can be attempted over the connection, a bind operation must be performed. @@ -1015,6 +1015,11 @@ and wait for and return with the server's result, or with *serverctrls* and *clientctrls* like described in section :ref:`ldap-controls`. + .. versionchanged:: 3.0 + + :meth:`~LDAPObject.simple_bind` and :meth:`~LDAPObject.simple_bind_s` + now accept ``None`` for *who* and *cred*, too. + .. py:method:: LDAPObject.search(base, scope [,filterstr='(objectClass=*)' [, attrlist=None [, attrsonly=0]]]) ->int diff --git a/Lib/ldap/ldapobject.py b/Lib/ldap/ldapobject.py index 69431eff..5a80bff7 100644 --- a/Lib/ldap/ldapobject.py +++ b/Lib/ldap/ldapobject.py @@ -406,7 +406,7 @@ def add(self,dn,modlist): def add_s(self,dn,modlist): return self.add_ext_s(dn,modlist,None,None) - def simple_bind(self,who='',cred='',serverctrls=None,clientctrls=None): + def simple_bind(self,who=None,cred=None,serverctrls=None,clientctrls=None): """ simple_bind([who='' [,cred='']]) -> int """ @@ -415,7 +415,7 @@ def simple_bind(self,who='',cred='',serverctrls=None,clientctrls=None): cred = self._bytesify_input('cred', cred) return self._ldap_call(self._l.simple_bind,who,cred,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls)) - def simple_bind_s(self,who='',cred='',serverctrls=None,clientctrls=None): + def simple_bind_s(self,who=None,cred=None,serverctrls=None,clientctrls=None): """ simple_bind_s([who='' [,cred='']]) -> 4-tuple """ @@ -1107,7 +1107,7 @@ def _apply_last_bind(self): func(self,*args,**kwargs) else: # Send explicit anon simple bind request to provoke ldap.SERVER_DOWN in method reconnect() - SimpleLDAPObject.simple_bind_s(self,'','') + SimpleLDAPObject.simple_bind_s(self, None, None) def _restore_options(self): """Restore all recorded options""" diff --git a/Modules/LDAPObject.c b/Modules/LDAPObject.c index addbe961..f8720fa4 100644 --- a/Modules/LDAPObject.c +++ b/Modules/LDAPObject.c @@ -499,7 +499,7 @@ l_ldap_simple_bind( LDAPObject* self, PyObject* args ) LDAPControl** client_ldcs = NULL; struct berval cred; - if (!PyArg_ParseTuple( args, "ss#|OO", &who, &cred.bv_val, &cred_len, &serverctrls, &clientctrls )) return NULL; + if (!PyArg_ParseTuple( args, "zz#|OO", &who, &cred.bv_val, &cred_len, &serverctrls, &clientctrls )) return NULL; cred.bv_len = (ber_len_t) cred_len; if (not_valid(self)) return NULL; diff --git a/Tests/t_ldapobject.py b/Tests/t_ldapobject.py index 243cd86d..27deadcd 100644 --- a/Tests/t_ldapobject.py +++ b/Tests/t_ldapobject.py @@ -401,6 +401,14 @@ def assertIsSubclass(self, cls, other): cls.__mro__ ) + def test_simple_bind_noarg(self): + l = self.ldap_object_class(self.server.ldap_uri) + l.simple_bind_s() + self.assertEqual(l.whoami_s(), u'') + l = self.ldap_object_class(self.server.ldap_uri) + l.simple_bind_s(None, None) + self.assertEqual(l.whoami_s(), u'') + @unittest.skipUnless(PY2, "no bytes_mode under Py3") def test_ldapbyteswarning(self): self.assertIsSubclass(ldap.LDAPBytesWarning, BytesWarning) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy