ldap.ldapobject.LDAPObject: New convenience methods for SASL GSSAPI or EXTERNAL binds

This commit is contained in:
stroeder
2015-06-11 15:13:43 +00:00
parent 7248568cb3
commit 0b665e2b9b
2 changed files with 23 additions and 3 deletions

View File

@@ -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
@@ -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 $

View File

@@ -3,7 +3,7 @@ ldapobject.py - wraps class _ldap.LDAPObject
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
@@ -32,7 +32,7 @@ if __debug__:
# 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
@@ -243,6 +243,24 @@ class SimpleLDAPObject:
"""
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