summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/providers/ldap/sdap_async_private.h2
-rw-r--r--src/providers/ldap/sdap_fd_events.c38
2 files changed, 40 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap_async_private.h b/src/providers/ldap/sdap_async_private.h
index f049fa6a..b29b18df 100644
--- a/src/providers/ldap/sdap_async_private.h
+++ b/src/providers/ldap/sdap_async_private.h
@@ -40,6 +40,8 @@ int get_fd_from_ldap(LDAP *ldap, int *fd);
errno_t sdap_set_connected(struct sdap_handle *sh, struct tevent_context *ev);
+errno_t sdap_call_conn_cb(const char *uri,int fd, struct sdap_handle *sh);
+
int sdap_op_add(TALLOC_CTX *memctx, struct tevent_context *ev,
struct sdap_handle *sh, int msgid,
sdap_op_callback_t *callback, void *data,
diff --git a/src/providers/ldap/sdap_fd_events.c b/src/providers/ldap/sdap_fd_events.c
index 05ea0b5c..4fb67b82 100644
--- a/src/providers/ldap/sdap_fd_events.c
+++ b/src/providers/ldap/sdap_fd_events.c
@@ -278,3 +278,41 @@ errno_t sdap_set_connected(struct sdap_handle *sh, struct tevent_context *ev)
return ret;
}
+
+errno_t sdap_call_conn_cb(const char *uri,int fd, struct sdap_handle *sh)
+{
+#ifdef HAVE_LDAP_CONNCB
+ int ret;
+ Sockbuf *sb;
+ LDAPURLDesc *lud;
+
+ sb = ber_sockbuf_alloc();
+ if (sb == NULL) {
+ DEBUG(1, ("ber_sockbuf_alloc failed.\n"));
+ return ENOMEM;
+ }
+
+ ret = ber_sockbuf_ctrl(sb, LBER_SB_OPT_SET_FD, &fd);
+ if (ret != 1) {
+ DEBUG(1, ("ber_sockbuf_ctrl failed.\n"));
+ return EFAULT;
+ }
+
+ ret = ldap_url_parse(uri, &lud);
+ if (ret != 0) {
+ ber_sockbuf_free(sb);
+ DEBUG(1, ("ber_sockbuf_ctrl failed.\n"));
+ return EFAULT;
+ }
+
+ ret = sdap_ldap_connect_callback_add(NULL, sb, lud, NULL,
+ sh->sdap_fd_events->conncb);
+
+ ldap_free_urldesc(lud);
+ ber_sockbuf_free(sb);
+ return ret;
+#else
+ DEBUG(9, ("LDAP connection callbacks are not supported.\n"));
+ return EOK;
+#endif
+}