summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2011-06-27 15:15:34 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-06-30 14:09:10 -0400
commit0eb8bf8c05a5535ed44c71342f4bed5b821cfa06 (patch)
treeae25e0976782a779450947d956dcc221a4a00abd /src
parent7087d51975f4059591c04718def24ba7b753644c (diff)
downloadsssd-0eb8bf8c05a5535ed44c71342f4bed5b821cfa06.tar.gz
sssd-0eb8bf8c05a5535ed44c71342f4bed5b821cfa06.tar.xz
sssd-0eb8bf8c05a5535ed44c71342f4bed5b821cfa06.zip
Add sdap_call_conn_cb() to call add connection callback directly
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 f049fa6aa..b29b18dfa 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 05ea0b5c4..4fb67b82c 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
+}