+ case LDAP_BACK_CFG_URI: {
+ LDAPURLDesc *tmpludp;
+ char **urllist;
+ int urlrc, i;
+
+ if ( c->argc != 2 ) {
+ fprintf( stderr, "%s: line %d: "
+ "missing uri "
+ "in \"uri <uri>\" line\n",
+ c->fname, c->lineno );
+ return 1;
+ }
+
+ if ( li->url != NULL ) {
+ ch_free( li->url );
+ }
+
+ if ( li->lud != NULL ) {
+ ldap_free_urllist( li->lud );
+ }
+
+#if 0
+ /* PARANOID: DN and more are not required nor allowed */
+ urlrc = ldap_url_parselist_ext( &li->lud, c->value_string, "\t" );
+#else
+ urlrc = ldap_url_parselist( &li->lud, c->value_string );
+#endif
+ if ( urlrc != LDAP_URL_SUCCESS ) {
+ char *why;
+
+ switch ( urlrc ) {
+ case LDAP_URL_ERR_MEM:
+ why = "no memory";
+ break;
+ case LDAP_URL_ERR_PARAM:
+ why = "parameter is bad";
+ break;
+ case LDAP_URL_ERR_BADSCHEME:
+ why = "URL doesn't begin with \"[c]ldap[si]://\"";
+ break;
+ case LDAP_URL_ERR_BADENCLOSURE:
+ why = "URL is missing trailing \">\"";
+ break;
+ case LDAP_URL_ERR_BADURL:
+ why = "URL is bad";
+ case LDAP_URL_ERR_BADHOST:
+ why = "host/port is bad";
+ break;
+ case LDAP_URL_ERR_BADATTRS:
+ why = "bad (or missing) attributes";
+ break;
+ case LDAP_URL_ERR_BADSCOPE:
+ why = "scope string is invalid (or missing)";
+ break;
+ case LDAP_URL_ERR_BADFILTER:
+ why = "bad or missing filter";
+ break;
+ case LDAP_URL_ERR_BADEXTS:
+ why = "bad or missing extensions";
+ break;
+ default:
+ why = "unknown reason";
+ break;
+ }
+ fprintf( stderr, "%s: line %d: "
+ "unable to parse uri \"%s\" "
+ "in \"uri <uri>\" line: %s\n",
+ c->fname, c->lineno, c->value_string, why );
+ return 1;
+ }
+
+ for ( i = 0, tmpludp = li->lud;
+ tmpludp;
+ i++, tmpludp = tmpludp->lud_next )
+ {
+ if ( ( tmpludp->lud_dn != NULL
+ && tmpludp->lud_dn[0] != '\0' )
+ || tmpludp->lud_attrs != NULL
+ /* || tmpludp->lud_scope != LDAP_SCOPE_DEFAULT */
+ || tmpludp->lud_filter != NULL
+ || tmpludp->lud_exts != NULL )
+ {
+ fprintf( stderr, "%s: line %d: "
+ "warning, only protocol, "
+ "host and port allowed "
+ "in \"uri <uri>\" statement "
+ "for uri #%d of \"%s\"\n",
+ c->fname, c->lineno, i, c->value_string );
+ }
+ }
+
+#if 0
+ for ( i = 0, tmpludp = li->lud;
+ tmpludp;
+ i++, tmpludp = tmpludp->lud_next )
+ /* just count */
+
+ urllist = ch_calloc( sizeof( char * ), i + 1 );
+
+ for ( i = 0, tmpludp = li->lud;
+ tmpludp;
+ i++, tmpludp = tmpludp->lud_next )
+ {
+ LDAPURLDesc tmplud;
+ ber_len_t oldlen = 0, len;
+
+ tmplud = *tmpludp;
+ tmplud.lud_dn = "";
+ tmplud.lud_attrs = NULL;
+ tmplud.lud_filter = NULL;
+ if ( !ldap_is_ldapi_url( tmplud.lud_scheme ) ) {
+ tmplud.lud_exts = NULL;
+ tmplud.lud_crit_exts = 0;
+ }
+
+ urllist[ i ] = ldap_url_desc2str( &tmplud );
+
+ if ( urllist[ i ] == NULL ) {
+ fprintf( stderr, "%s: line %d: "
+ "unable to rebuild uri "
+ "in \"uri <uri>\" statement "
+ "for \"%s\"\n",
+ c->fname, c->lineno, argv[ 1 ] );
+ return 1;
+ }
+ }
+
+ li->url = ldap_charray2str( urllist, " " );
+ ldap_charray_free( urllist );
+#else