26 #ifndef CURL_DISABLE_LDAP
33 #include <sys/types.h>
37 #if defined(WIN32) && !defined(__GNUC__)
54 #define _MPRINTF_REPLACE
57 typedef void * (*dynafunc)(
void *
input);
59 #define DYNA_GET_FUNCTION(type, fnc) \
60 (fnc) = (type)DynaGetFunction(#fnc); \
61 if ((fnc) == NULL) { \
62 return CURLE_FUNCTION_NOT_FOUND; \
67 static void *libldap =
NULL;
68 static void *liblber =
NULL;
70 static void DynaOpen(
void)
72 #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
73 if (libldap ==
NULL) {
79 liblber = dlopen(
"liblber.so",
80 #ifdef RTLD_LAZY_GLOBAL
84 RTLD_LAZY | RTLD_GLOBAL
91 libldap = dlopen(
"libldap.so", RTLD_LAZY);
96 static void DynaClose(
void)
98 #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
114 #if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
116 func = (
dynafunc) dlsym(libldap, name);
143 void *(*ldap_init)(
char *,
int);
144 int (*ldap_simple_bind_s)(
void *,
char *,
char *);
145 int (*ldap_unbind_s)(
void *);
147 void (*ldap_free_urldesc)(
void *);
148 int (*ldap_search_s)(
void *,
char *,
int,
char *,
char **,
int,
void **);
149 int (*ldap_search_st)(
void *,
char *,
int,
char *,
char **,
int,
void *,
void **);
150 void *(*ldap_first_entry)(
void *,
void *);
151 void *(*ldap_next_entry)(
void *,
void *);
152 char *(*ldap_err2string)(
int);
153 char *(*ldap_get_dn)(
void *,
void *);
154 char *(*ldap_first_attribute)(
void *,
void *,
void **);
155 char *(*ldap_next_attribute)(
void *,
void *,
void *);
156 char **(*ldap_get_values)(
void *,
void *,
char *);
157 void (*ldap_value_free)(
char **);
158 void (*ldap_memfree)(
void *);
173 if (libldap ==
NULL) {
174 failf(data,
"The needed LDAP library/libraries couldn't be opened");
186 DYNA_GET_FUNCTION(
int (*)(
void *,
char *,
int,
char *,
char **,
int,
void **), ldap_search_s);
187 DYNA_GET_FUNCTION(
int (*)(
void *,
char *,
int,
char *,
char **,
int,
void *,
void **), ldap_search_st);
200 if (server ==
NULL) {
201 failf(data,
"LDAP: Cannot connect to %s:%d",
206 rc = ldap_simple_bind_s(server,
210 failf(data,
"LDAP: %s", ldap_err2string(rc));
214 rc = ldap_url_parse(data->
change.
url, &ludp);
216 failf(data,
"LDAP: %s", ldap_err2string(rc));
223 failf(data,
"LDAP: %s", ldap_err2string(rc));
227 for (entryIterator = ldap_first_entry(server, result);
229 entryIterator = ldap_next_entry(server, entryIterator)) {
230 char *dn = ldap_get_dn(server, entryIterator);
237 for(attribute = ldap_first_attribute(server, entryIterator,
240 attribute = ldap_next_attribute(server, entryIterator,
242 vals = ldap_get_values(server, entryIterator, attribute);
244 for(i = 0; (vals[
i] !=
NULL); i++) {
254 ldap_value_free(vals);
258 ldap_memfree(attribute);
260 if (ber) ber_free(ber, 0);
264 ldap_free_urldesc(ludp);
266 ldap_unbind_s(server);
struct DynamicStatic change
CURLcode Curl_client_write(struct SessionHandle *data, int type, char *ptr, size_t len)
CURLcode Curl_ldap(struct connectdata *conn)
GLsizei GLsizei GLenum GLenum const GLvoid * data
struct ldap_url_desc LDAPURLDesc
GLenum GLenum GLenum input
CURLcode Curl_Transfer(struct connectdata *c_conn, int sockindex, curl_off_t size, bool getheader, curl_off_t *bytecountp, int writesockindex, curl_off_t *writecountp)
struct SessionHandle * data
void *(* dynafunc)(void *input)
struct ldap_url_desc * lud_next
#define DYNA_GET_FUNCTION(type, fnc)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red