From dc17dc83dbf83e41a71eb046cdde659785d3171b Mon Sep 17 00:00:00 2001 From: David Mulder Date: Fri, 30 Oct 2020 15:53:32 +0000 Subject: [PATCH] Fix double password prompt --- src/ads.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ads.in b/src/ads.in index a0b3e9b..e1b4e50 100644 --- a/src/ads.in +++ b/src/ads.in @@ -188,7 +188,8 @@ def ldap_posix_pwent(creds, container): def nss_getpwnam(args): if args.direct: - pw = ldap_posix_user(get_creds(args), args.object, user_container()) + creds = get_creds(args) + pw = ldap_posix_user(creds, args.object, user_container(creds)) else: realm = get_default_realm() pw = getpwnam(args.object) @@ -213,7 +214,7 @@ def nss_getgrnam_getgrid(args): def nss_getpwent(args): creds = get_creds(args) if 'direct' in args and args.direct: - ulist = ldap_posix_pwent(creds, user_container()) + ulist = ldap_posix_pwent(creds, user_container(creds)) else: ulist = getpwent(creds) for pw in ulist: @@ -340,10 +341,9 @@ def ldap_open(realm, creds): wkguiduc = 'A9D1CA15768811D1ADED00C04FD8D5CD' uc = None -def user_container(): +def user_container(creds): global uc, wkguiduc if not uc: - creds = get_creds(args) l = ldap_open(get_default_realm(), creds) results = l.search('' % (wkguiduc, realm_to_dn(get_default_realm())), ldb.SCOPE_SUBTREE, '(objectClass=container)', ['distinguishedName']) uc = results[0]['distinguishedName'][-1] @@ -371,7 +371,7 @@ def attrs(args): l = ldap_open(get_default_realm(), creds) container = args.c if not container: - container = user_container() + container = user_container(creds) results = l.search(container, ldb.SCOPE_SUBTREE, '(cn=%s)' % args.object, args.attributes) for result in results: print_ldap_object(result, args.b) @@ -383,7 +383,7 @@ def getdn(cn, container=None): creds = get_creds(args) l = ldap_open(get_default_realm(), creds) if not container: - container = user_container() + container = user_container(creds) results = l.search(container, ldb.SCOPE_SUBTREE, '(cn=%s)' % cn, ['distinguishedName']) return results[0]['distinguishedName'][-1]