summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/Makefile.am4
-rw-r--r--server/external/ldap.m49
-rw-r--r--server/providers/ldap/sdap.c1
-rw-r--r--server/providers/ldap/sdap.h2
-rw-r--r--server/providers/ldap/sdap_async.c12
-rw-r--r--server/util/sss_ldap.c70
-rw-r--r--server/util/sss_ldap.h30
7 files changed, 119 insertions, 9 deletions
diff --git a/server/Makefile.am b/server/Makefile.am
index a700eea5..19b9095c 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -238,6 +238,7 @@ dist_noinst_HEADERS = \
util/sssd-i18n.h \
util/util.h \
util/strtonum.h \
+ util/sss_ldap.h \
config.h \
monitor/monitor.h \
monitor/monitor_interfaces.h \
@@ -427,7 +428,8 @@ libsss_ldap_la_SOURCES = \
providers/ldap/ldap_id.c \
providers/ldap/ldap_auth.c \
providers/ldap/sdap_async.c \
- providers/ldap/sdap.c
+ providers/ldap/sdap.c \
+ util/sss_ldap.c
libsss_ldap_la_CFLAGS = \
$(AM_CFLAGS) \
$(LDAP_CFLAGS) \
diff --git a/server/external/ldap.m4 b/server/external/ldap.m4
index 5e817b82..a17ed7e9 100644
--- a/server/external/ldap.m4
+++ b/server/external/ldap.m4
@@ -38,3 +38,12 @@ else
fi
AC_SUBST(OPENLDAP_LIBS)
+
+SAVE_CFLAGS=$CFLAGS
+SAVE_LIBS=$LIBS
+CFLAGS="$CFLAGS $OPENLDAP_CFLAGS"
+LIBS="$LIBS $OPENLDAP_LIBS"
+AC_CHECK_FUNCS([ldap_control_create])
+CFLAGS=$SAVE_CFLAGS
+LIBS=$SAVE_LIBS
+
diff --git a/server/providers/ldap/sdap.c b/server/providers/ldap/sdap.c
index 47f76f9c..ba234ed0 100644
--- a/server/providers/ldap/sdap.c
+++ b/server/providers/ldap/sdap.c
@@ -20,7 +20,6 @@
*/
#define LDAP_DEPRECATED 1
-#include <ldap.h>
#include "util/util.h"
#include "confdb/confdb.h"
#include "providers/ldap/sdap.h"
diff --git a/server/providers/ldap/sdap.h b/server/providers/ldap/sdap.h
index 3aa29a37..650ce5f1 100644
--- a/server/providers/ldap/sdap.h
+++ b/server/providers/ldap/sdap.h
@@ -21,7 +21,7 @@
#include "confdb/confdb.h"
#include "db/sysdb.h"
-#include <ldap.h>
+#include "util/sss_ldap.h"
struct sdap_msg {
struct sdap_msg *next;
diff --git a/server/providers/ldap/sdap_async.c b/server/providers/ldap/sdap_async.c
index 80b7e046..4f9294c5 100644
--- a/server/providers/ldap/sdap_async.c
+++ b/server/providers/ldap/sdap_async.c
@@ -676,10 +676,10 @@ static struct tevent_req *simple_bind_send(TALLOC_CTX *memctx,
state->user_dn = user_dn;
state->pw = pw;
- ret = ldap_control_create(LDAP_CONTROL_PASSWORDPOLICYREQUEST, 0, NULL, 0,
- &request_controls[0]);
+ ret = sss_ldap_control_create(LDAP_CONTROL_PASSWORDPOLICYREQUEST,
+ 0, NULL, 0, &request_controls[0]);
if (ret != LDAP_SUCCESS) {
- DEBUG(1, ("ldap_control_create failed.\n"));
+ DEBUG(1, ("sss_ldap_control_create failed.\n"));
goto fail;
}
request_controls[1] = NULL;
@@ -2699,10 +2699,10 @@ struct tevent_req *sdap_exop_modify_passwd_send(TALLOC_CTX *memctx,
return NULL;
}
- ret = ldap_control_create(LDAP_CONTROL_PASSWORDPOLICYREQUEST, 0, NULL, 0,
- &request_controls[0]);
+ ret = sss_ldap_control_create(LDAP_CONTROL_PASSWORDPOLICYREQUEST,
+ 0, NULL, 0, &request_controls[0]);
if (ret != LDAP_SUCCESS) {
- DEBUG(1, ("ldap_control_create failed.\n"));
+ DEBUG(1, ("sss_ldap_control_create failed.\n"));
goto fail;
}
request_controls[1] = NULL;
diff --git a/server/util/sss_ldap.c b/server/util/sss_ldap.c
new file mode 100644
index 00000000..f098e7d6
--- /dev/null
+++ b/server/util/sss_ldap.c
@@ -0,0 +1,70 @@
+/*
+ Authors:
+ Sumit Bose <sbose@redhat.com>
+
+ Copyright (C) 2009 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include <stdlib.h>
+
+#include "config.h"
+
+#include "util/sss_ldap.h"
+
+
+int sss_ldap_control_create(const char *oid, int iscritical,
+ struct berval *value, int dupval,
+ LDAPControl **ctrlp)
+{
+#ifdef HAVE_LDAP_CONTROL_CREATE
+ return ldap_control_create(oid, iscritical, value, dupval, ctrlp);
+#else
+ LDAPControl *lc = NULL;
+
+ if (oid == NULL || ctrlp == NULL) {
+ return LDAP_PARAM_ERROR;
+ }
+
+ lc = calloc(sizeof(LDAPControl), 1);
+ if (lc == NULL) {
+ return LDAP_NO_MEMORY;
+ }
+
+ lc->ldctl_oid = strdup(oid);
+ if (lc->ldctl_oid == NULL) {
+ free(lc);
+ return LDAP_NO_MEMORY;
+ }
+
+ if (value != NULL && value->bv_val != NULL) {
+ if (dupval == 0) {
+ lc->ldctl_value = *value;
+ } else {
+ ber_dupbv(&lc->ldctl_value, value);
+ if (lc->ldctl_value.bv_val == NULL) {
+ free(lc->ldctl_oid);
+ free(lc);
+ return LDAP_NO_MEMORY;
+ }
+ }
+ }
+
+ lc->ldctl_iscritical = iscritical;
+
+ *ctrlp = lc;
+
+ return LDAP_SUCCESS;
+#endif
+}
diff --git a/server/util/sss_ldap.h b/server/util/sss_ldap.h
new file mode 100644
index 00000000..14747dff
--- /dev/null
+++ b/server/util/sss_ldap.h
@@ -0,0 +1,30 @@
+/*
+ Authors:
+ Sumit Bose <sbose@redhat.com>
+
+ Copyright (C) 2009 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __SSS_LDAP_H__
+#define __SSS_LDAP_H__
+
+#include <ldap.h>
+
+int sss_ldap_control_create(const char *oid, int iscritical,
+ struct berval *value, int dupval,
+ LDAPControl **ctrlp);
+
+#endif /* __SSS_LDAP_H__ */