ldap_pvt_url_scheme2tls LDAP_P((
const char * ));
+LDAP_F ( int )
+ldap_pvt_url_scheme_port LDAP_P((
+ const char *, int ));
+
struct ldap_url_desc; /* avoid pulling in <ldap.h> */
LDAP_F( int )
for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
lcu = lc->lconn_server;
- lcu_port = lcu->lud_port ? lcu->lud_port : LDAP_PORT;
+ lcu_port = ldap_pvt_url_scheme_port( lcu->lud_scheme,
+ lcu->lud_port );
+
for ( lsu = srv; lsu != NULL; lsu = lsu->lud_next ) {
- lsu_port = lsu->lud_port ? lsu->lud_port : LDAP_PORT;
+ lsu_port = ldap_pvt_url_scheme_port( lsu->lud_scheme,
+ lsu->lud_port );
+
if ( lcu->lud_host != NULL && *lcu->lud_host != '\0'
&& lsu->lud_host != NULL && *lsu->lud_host != '\0'
&& strcasecmp( lsu->lud_host, lcu->lud_host ) == 0
return -1;
}
+int ldap_pvt_url_scheme_port( const char *scheme, int port )
+{
+ assert( scheme );
+
+ if( port ) return port;
+ if( scheme == NULL ) return port;
+
+ if( strcmp("ldap", scheme) == 0 ) {
+ return LDAP_PORT;
+ }
+
+ if( strcmp("ldapi", scheme) == 0 ) {
+ return -1;
+ }
+
+ if( strcmp("ldaps", scheme) == 0 ) {
+ return LDAPS_PORT;
+ }
+
+#ifdef LDAP_CONNECTIONLESS
+ if( strcmp("cldap", scheme) == 0 ) {
+ return LDAP_PORT;
+ }
+#endif
+
+ return -1;
+}
+
int
ldap_pvt_url_scheme2tls( const char *scheme )
{