From: W. Trevor King Date: Fri, 11 May 2012 06:10:12 +0000 (-0400) Subject: Add auth.gssapi option to mutt-ldap.py (for use with Kerberos). X-Git-Tag: v0.1~31 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a2e94b1634fbbe1661bd5fd4c033b12a402602fa;p=mutt-ldap.git Add auth.gssapi option to mutt-ldap.py (for use with Kerberos). --- diff --git a/mutt-ldap.py b/mutt-ldap.py index 8fac78e..8d22ff6 100755 --- a/mutt-ldap.py +++ b/mutt-ldap.py @@ -39,6 +39,7 @@ import os.path import ConfigParser import ldap +import ldap.sasl CONFIG = ConfigParser.SafeConfigParser() @@ -46,9 +47,11 @@ CONFIG.add_section('connection') CONFIG.set('connection', 'server', 'domaincontroller.yourdomain.com') CONFIG.set('connection', 'port', '389') # set to 636 for default over SSL CONFIG.set('connection', 'ssl', 'no') -CONFIG.set('connection', 'user', '') -CONFIG.set('connection', 'password', '') CONFIG.set('connection', 'basedn', 'ou=x co.,dc=example,dc=net') +CONFIG.add_section('auth') +CONFIG.set('auth', 'user', '') +CONFIG.set('auth', 'password', '') +CONFIG.set('auth', 'gssapi', 'no') CONFIG.read(os.path.expanduser('~/.mutt-ldap.rc')) def connect(): @@ -60,10 +63,14 @@ def connect(): CONFIG.get('connection', 'server'), CONFIG.get('connection', 'port')) connection = ldap.initialize(url) - connection.bind( - CONFIG.get('connection', 'user'), - CONFIG.get('connection', 'password'), - ldap.AUTH_SIMPLE) + if CONFIG.getboolean('auth', 'gssapi'): + sasl = ldap.sasl.gssapi() + connection.sasl_interactive_bind_s('', sasl) + else: + connection.bind( + CONFIG.get('auth', 'user'), + CONFIG.get('auth', 'password'), + ldap.AUTH_SIMPLE) return connection def search(query, connection=None):