diff options
author | Werner Koch <wk@gnupg.org> | 2021-02-17 17:31:36 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2021-02-17 17:40:02 +0100 |
commit | ab7dc4b524c3e2ad5153acfdbfa879a9e62d2dbe (patch) | |
tree | 91e80e544bfc2169524614dc5772d06dae792ecd /dirmngr/ldap-parse-uri.c | |
parent | build: Update gpg-error.m4 again. (diff) | |
download | gnupg2-ab7dc4b524c3e2ad5153acfdbfa879a9e62d2dbe.tar.xz gnupg2-ab7dc4b524c3e2ad5153acfdbfa879a9e62d2dbe.zip |
dirmngr: Support new gpgNtds parameter in LDAP keyserver URLs.
* dirmngr/ldap-parse-uri.c (ldap_parse_uri): Support a new gpgNtds
extension.
* dirmngr/ks-engine-ldap.c (my_ldap_connect): Do ldap_init always with
hostname - which is NULL and thus the same if not given. Fix minor
error in error code handling.
--
Note that "gpgNtds" is per RFC-4512 case insensitive and has not yet
been officially regisetered. Thus for correctness the OID can be
used:
1.3.6.1.4.1.11591.2.5 LDAP URL extensions
1.3.6.1.4.1.11591.2.5.1 gpgNtds=1 (auth. with current user)
Note that the value must be 1; all other values won't enable AD
authentication and are resevered for future use.
This has been cherry-picked from the 2.2 branch,
commit 55f46b33df08e8e0ea520ade5f73b321bc01d705
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'dirmngr/ldap-parse-uri.c')
-rw-r--r-- | dirmngr/ldap-parse-uri.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/dirmngr/ldap-parse-uri.c b/dirmngr/ldap-parse-uri.c index 41633acf0..573bcc77f 100644 --- a/dirmngr/ldap-parse-uri.c +++ b/dirmngr/ldap-parse-uri.c @@ -71,6 +71,7 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri) char *dn = NULL; char *bindname = NULL; char *password = NULL; + char *gpg_ntds = NULL; char **s; @@ -107,6 +108,15 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri) else password = *s + 9; } + else if (!ascii_strncasecmp (*s, "gpgNtds=", 8) + || !strncmp (*s, "1.3.6.1.4.1.11591.2.5.1=", 24)) + { + if (gpg_ntds) + log_error ("gpgNtds given multiple times in URL '%s', ignoring.\n", + uri); + else + gpg_ntds = *s + (**s == 'g'? 8 : 24); + } else log_error ("Unhandled extension (%s) in URL '%s', ignoring.", *s, uri); @@ -167,10 +177,14 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri) puri->port = lud->lud_port; /* On Windows detect whether this is ldap:// or ldaps:// to indicate - * that authentication via AD and the current user is requested. */ + * that authentication via AD and the current user is requested. + * This is shortform of adding "gpgNtDs=1" as extension parameter to + * the URL. */ puri->ad_current = 0; + if (gpg_ntds && atoi (gpg_ntds) == 1) + puri->ad_current = 1; #ifdef HAVE_W32_SYSTEM - if ((!puri->host || !*puri->host) + else if ((!puri->host || !*puri->host) && (!puri->path || !*puri->path) && (!puri->auth || !*puri->auth) && !password |