Skip to content

Commit

Permalink
Added key-word argument authz_id to LDAPObject methods sasl_non_inter…
Browse files Browse the repository at this point in the history
…active_bind_s(), sasl_external_bind_s() and sasl_gssapi_bind_s().
  • Loading branch information
stroeder committed Oct 24, 2015
1 parent 51ed535 commit 2cc6d11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Changes since 2.4.21:
Lib/
* LDIFParser now also accepts value-spec without a space
after the colon.
* Added key-word argument authz_id to LDAPObject methods
sasl_non_interactive_bind_s(), sasl_external_bind_s() and
sasl_gssapi_bind_s()

Doc/
* Started missing docs for sub-module ldap.sasl.
Expand Down Expand Up @@ -1207,4 +1210,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.359 2015/10/24 15:27:03 stroeder Exp $
$Id: CHANGES,v 1.360 2015/10/24 15:42:41 stroeder Exp $
20 changes: 13 additions & 7 deletions Lib/ldap/ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
\$Id: ldapobject.py,v 1.147 2015/08/08 13:37:41 stroeder Exp $
\$Id: ldapobject.py,v 1.148 2015/10/24 15:42:41 stroeder Exp $
Compability:
- Tested with Python 2.0+ but should work with Python 1.5.x
Expand Down Expand Up @@ -243,23 +243,29 @@ def sasl_interactive_bind_s(self,who,auth,serverctrls=None,clientctrls=None,sasl
"""
return self._ldap_call(self._l.sasl_interactive_bind_s,who,auth,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls),sasl_flags)

def sasl_non_interactive_bind_s(self,sasl_mech,serverctrls=None,clientctrls=None,sasl_flags=ldap.SASL_QUIET):
def sasl_non_interactive_bind_s(self,sasl_mech,serverctrls=None,clientctrls=None,sasl_flags=ldap.SASL_QUIET,authz_id=''):
"""
Send a SASL bind request using a non-interactive SASL method (e.g. GSSAPI, EXTERNAL)
"""
self.sasl_interactive_bind_s('',ldap.sasl.sasl({},sasl_mech))
self.sasl_interactive_bind_s(
'',
ldap.sasl.sasl(
{ldap.sasl.CB_USER:authz_id},
sasl_mech
)
)

def sasl_external_bind_s(self,serverctrls=None,clientctrls=None,sasl_flags=ldap.SASL_QUIET):
def sasl_external_bind_s(self,serverctrls=None,clientctrls=None,sasl_flags=ldap.SASL_QUIET,authz_id=''):
"""
Send SASL bind request using SASL mech EXTERNAL
"""
self.sasl_non_interactive_bind_s('EXTERNAL',serverctrls,clientctrls,sasl_flags)
self.sasl_non_interactive_bind_s('EXTERNAL',serverctrls,clientctrls,sasl_flags,authz_id)

def sasl_gssapi_bind_s(self,serverctrls=None,clientctrls=None,sasl_flags=ldap.SASL_QUIET):
def sasl_gssapi_bind_s(self,serverctrls=None,clientctrls=None,sasl_flags=ldap.SASL_QUIET,authz_id=''):
"""
Send SASL bind request using SASL mech GSSAPI
"""
self.sasl_non_interactive_bind_s('GSSAPI',serverctrls,clientctrls,sasl_flags)
self.sasl_non_interactive_bind_s('GSSAPI',serverctrls,clientctrls,sasl_flags,authz_id)

def sasl_bind_s(self,dn,mechanism,cred,serverctrls=None,clientctrls=None):
"""
Expand Down

0 comments on commit 2cc6d11

Please sign in to comment.