Skip to content

Commit

Permalink
ldap.ldapobject.LDAPObject: New convenience methods for SASL GSSAPI o…
Browse files Browse the repository at this point in the history
…r EXTERNAL binds
  • Loading branch information
stroeder committed Jun 11, 2015
1 parent 7248568 commit 0b665e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Changes since 2.4.19:
Lib/
* Abandoned old syntax when raising ValueError in modules ldif and
ldapurl, more information in some exceptions.
* ldap.ldapobject.LDAPObject:
New convenience methods for SASL GSSAPI or EXTERNAL binds

----------------------------------------------------------------
Released 2.4.19 2015-01-10
Expand Down Expand Up @@ -1156,4 +1158,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.342 2015/06/05 21:03:06 stroeder Exp $
$Id: CHANGES,v 1.343 2015/06/11 15:13:44 stroeder Exp $
22 changes: 20 additions & 2 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.145 2015/06/06 09:21:38 stroeder Exp $
\$Id: ldapobject.py,v 1.146 2015/06/11 15:13:43 stroeder Exp $
Compability:
- Tested with Python 2.0+ but should work with Python 1.5.x
Expand Down Expand Up @@ -32,7 +32,7 @@
# Tracing is only supported in debugging mode
import traceback

import sys,time,pprint,_ldap,ldap,ldap.functions
import sys,time,pprint,_ldap,ldap,ldap.sasl,ldap.functions

from ldap.schema import SCHEMA_ATTRS
from ldap.controls import LDAPControl,DecodeControlTuples,RequestControlTuples
Expand Down Expand Up @@ -243,6 +243,24 @@ 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):
"""
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))

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

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

def sasl_bind_s(self,dn,mechanism,cred,serverctrls=None,clientctrls=None):
"""
sasl_bind_s(dn, mechanism, cred [,serverctrls=None[,clientctrls=None]]) -> int|str
Expand Down

0 comments on commit 0b665e2

Please sign in to comment.