#define LDAP_OPT_TIMEOUT 0x5002 /* default timeout */
#define LDAP_OPT_REFHOPLIMIT 0x5003 /* ref hop limit */
#define LDAP_OPT_NETWORK_TIMEOUT 0x5005 /* socket level timeout */
+#define LDAP_OPT_URI 0x5006
/* TLS options */
#define LDAP_OPT_X_TLS_CACERTFILE 0x6001
* types for ldap URL handling
*/
typedef struct ldap_url_desc {
+ struct ldap_url_desc *lud_next;
int lud_ldaps;
char *lud_host;
int lud_port;
#define ATTR_KV 3
#define ATTR_STRING 4
#define ATTR_TLS 5
+#define ATTR_URLS 6
struct ol_keyvalue {
const char * key;
offsetof(struct ldapoptions, ldo_timelimit)},
{ATTR_STRING, "BASE", NULL,
offsetof(struct ldapoptions, ldo_defbase)},
- {ATTR_STRING, "HOST", NULL,
- offsetof(struct ldapoptions, ldo_defhost)},
{ATTR_INT, "PORT", NULL,
offsetof(struct ldapoptions, ldo_defport)},
+ /* **** keep this around for backward compatibility */
+ {ATTR_URLS, "HOST", NULL, 1},
+ /* **** */
+ {ATTR_URLS, "URL", NULL, 0},
{ATTR_BOOL, "REFERRALS", NULL, LDAP_BOOL_REFERRALS},
{ATTR_BOOL, "RESTART", NULL, LDAP_BOOL_RESTART},
{ATTR_BOOL, "DNS", NULL, LDAP_BOOL_DNS},
ldap_pvt_tls_config( &gopts, attrs[i].offset, opt );
#endif
break;
+ case ATTR_URLS:
+ if (attrs[i].offset == 0) {
+ ldap_set_option( NULL, LDAP_OPT_URI, opt );
+ } else {
+ ldap_set_option( NULL, LDAP_OPT_HOST_NAME, opt );
+ }
+ break;
}
}
}
ldap_pvt_tls_config( &gopts, attrs[i].offset, value );
#endif
break;
+ case ATTR_URLS:
+ if (attrs[i].offset == 0) {
+ ldap_set_option( NULL, LDAP_OPT_URI, value );
+ } else {
+ ldap_set_option( NULL, LDAP_OPT_HOST_NAME, value );
+ }
+ break;
}
}
}
gopts.ldo_tm_api = (struct timeval *)NULL;
gopts.ldo_tm_net = (struct timeval *)NULL;
- gopts.ldo_defhost = LDAP_STRDUP("localhost");
+ ldap_url_parselist(&gopts.ldo_defludp, "ldap://localhost/");
gopts.ldo_defport = LDAP_PORT;
gopts.ldo_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
ber_int_t ldo_timelimit;
ber_int_t ldo_sizelimit;
+ LDAPURLDesc *ldo_defludp;
int ldo_defport;
char* ldo_defbase;
- char* ldo_defhost;
#ifdef LDAP_CONNECTIONLESS
int ldo_cldaptries; /* connectionless search retry count */
#define LDAP_CONNST_NEEDSOCKET 1
#define LDAP_CONNST_CONNECTING 2
#define LDAP_CONNST_CONNECTED 3
- LDAPServer *lconn_server;
+ LDAPURLDesc *lconn_server;
char *lconn_krbinstance;
struct ldap_conn *lconn_next;
BerElement *lconn_ber;/* ber receiving on this conn. */
* in open.c
*/
LIBLDAP_F (int) ldap_open_defconn( LDAP *ld );
-LIBLDAP_F (int) open_ldap_connection( LDAP *ld, Sockbuf *sb, const char *host, int defport, char **krbinstancep, int async );
+LIBLDAP_F (int) open_ldap_connection( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srvlist, char **krbinstancep, int async );
/*
LIBLDAP_F (BerElement *) ldap_alloc_ber_with_options( LDAP *ld );
LIBLDAP_F (void) ldap_set_ber_options( LDAP *ld, BerElement *ber );
-LIBLDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind );
-LIBLDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind );
+LIBLDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid, LDAPRequest *parentreq, LDAPURLDesc *srvlist, LDAPConn *lc, int bind );
+LIBLDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, int connect, int bind );
LIBLDAP_F (LDAPRequest *) ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
LIBLDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
LIBLDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
LDAPControl **sctrls,
LDAPControl **cctrls ));
+/*
+ * in url.c
+ */
+LIBLDAP_F (LDAPURLDesc *) ldap_url_dup LDAP_P((
+ LDAPURLDesc *ludp ));
+
+LIBLDAP_F (LDAPURLDesc *) ldap_url_duplist LDAP_P((
+ LDAPURLDesc *ludlist ));
+
+LIBLDAP_F (int) ldap_url_parselist LDAP_P((
+ LDAPURLDesc **ludlist,
+ const char *url ));
+
+LIBLDAP_F (int) ldap_url_parsehosts LDAP_P((
+ LDAPURLDesc **ludlist,
+ const char *hosts ));
+
+LIBLDAP_F (char *) ldap_url_list2hosts LDAP_P((
+ LDAPURLDesc *ludlist ));
+
+LIBLDAP_F (char *) ldap_url_list2urls LDAP_P((
+ LDAPURLDesc *ludlist ));
+
+LIBLDAP_F (void) ldap_free_urllist LDAP_P((
+ LDAPURLDesc *ludlist ));
+
+
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
/*
* in getdxbyname.c