Check for ldap_initialize and other functions that Solaris (Mozilla-based)
authorKen Raeburn <raeburn@mit.edu>
Sat, 7 Oct 2006 06:10:27 +0000 (06:10 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sat, 7 Oct 2006 06:10:27 +0000 (06:10 +0000)
LDAP does not provide, and define versions a couple of them if needed.
Based on patches from and discussions with Will Fiveash.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18665 dc483132-0cff-0310-8789-dd5450dbe970

src/configure.in
src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h
src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c

index f23211ea2dc8b881ee4804c74050c7d88eb45bc7..8bd81705793710f42028fb88a21591146aab4413 100644 (file)
@@ -909,6 +909,10 @@ if test -n "$OPENLDAP_PLUGIN"; then
   if test $ac_cv_header_ldap_h = no || test $ac_cv_header_lber_h = no; then
     AC_ERROR(OpenLDAP headers missing)
   fi
+  old_LIBS="$LIBS"
+  LIBS="$LIBS -lldap"
+  AC_CHECK_FUNCS(ldap_initialize ldap_url_parse_nodn ldap_unbind_ext_s ldap_str2dn ldap_explode_dn)
+  LIBS="$old_LIBS"
   AC_CONFIG_SUBDIRS(plugins/kdb/ldap/libkdb_ldap)
   K5_GEN_MAKEFILE(plugins/kdb/ldap)
   K5_GEN_MAKEFILE(plugins/kdb/ldap/ldap_util)
index a8ec7aa6ddeeac151c5e2fb4f39dada2dcfd715a..93a47acf9d44a0cb0edd6ef61833e007087d82c8 100644 (file)
@@ -304,4 +304,13 @@ krb5_ldap_errcode_2_string( krb5_context, long );
 void
 krb5_ldap_release_errcode_string (krb5_context, const char *);
 
+#ifndef HAVE_LDAP_INITIALIZE
+int
+ldap_initialize(LDAP **, char *);
+#endif
+#ifndef HAVE_LDAP_UNBIND_EXT_S
+int
+ldap_unbind_ext_s(LDAP *, LDAPControl **, LDAPControl **);
+#endif
+
 #endif
index f7275916ab2f0859947fe78852d661da1fd4f49e..6a767fe68842282d609a5fc61e66c293c824ab42 100644 (file)
@@ -1845,3 +1845,54 @@ krb5_error_code remove_overlapping_subtrees(char **listin, char ***listop, int *
     }
     return 0;
 }
+
+/*
+ * Solaris libldap does not provide the following functions which are in
+ * OpenLDAP.
+ */
+#ifndef HAVE_LDAP_INITIALIZE
+int
+ldap_initialize(LDAP **ldp, char *url)
+{
+    int rc = 0;
+    LDAP *ld = NULL;
+    LDAPURLDesc *ludp = NULL;
+
+    /* For now, we don't use any DN that may be provided.  And on
+       Solaris (based on Mozilla's LDAP client code), we need the
+       _nodn form to parse "ldap://host" without a trailing slash.
+
+       Also, this version won't handle an input string which contains
+       multiple URLs, unlike the OpenLDAP ldap_initialize.  See
+       https://bugzilla.mozilla.org/show_bug.cgi?id=353336#c1 .  */
+#ifdef HAVE_LDAP_URL_PARSE_NODN
+    rc = ldap_url_parse_nodn(url, &ludp);
+#else
+    rc = ldap_url_parse(url, &ludp);
+#endif
+    if (rc == 0) {
+
+       ld = ldap_init(ludp->lud_host, ludp->lud_port);
+       if (ld != NULL) {
+           *ldp = ld;
+#if 0
+           printf("lud_host %s lud_port %d\n", ludp->lud_host,
+                  ludp->lud_port);
+#endif
+       }
+       else
+           rc = KRB5_KDB_ACCESS_ERROR;
+
+       ldap_free_urldesc(ludp);
+    }
+    return rc;
+}
+#endif /* HAVE_LDAP_INITIALIZE */
+
+#ifndef HAVE_LDAP_UNBIND_EXT_S
+int
+ldap_unbind_ext_s(LDAP *ld, LDAPControl **sctrls, LDAPControl **cctrls)
+{
+    return ldap_unbind_ext(ld, sctrls, cctrls);
+}
+#endif /* HAVE_LDAP_UNBIND_EXT_S */