search_attrs[k] = NULL;
}
+#if LDAP_UFN
/*
* If the user-supplied name has any commas in it, we
* assume that it is a UFN, and do everything right
}
ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
}
+#endif
/*
* Old users of the MTS *USERDIRECTORY will likely wrap the name
char *
ldap_dn2ufn( LDAP_CONST char *dn )
{
- char *p, *ufn, *r;
- int state;
+ char *ufn;
+ char **vals;
Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 );
+ /* produces completely untyped UFNs */
+
if( dn == NULL ) {
return NULL;
}
- if ( ( p = ldap_utf8_strpbrk( dn, "=" ) ) == NULL ) {
- return( LDAP_STRDUP( dn ) );
+ vals = ldap_explode_dn( dn , 1 );
+ if( vals == NULL ) {
+ return NULL;
}
- ufn = LDAP_STRDUP( ++p );
-
- if( ufn == NULL ) return NULL;
-
-#define INQUOTE 1
-#define OUTQUOTE 2
- state = OUTQUOTE;
- for ( p = ufn, r = ufn; *p; LDAP_UTF8_INCR(p) ) {
- switch ( *p ) {
- case '\\':
- if ( p[1] != '\0' ) {
- *r++ = '\\';
- LDAP_UTF8_COPY(r,++p);
- LDAP_UTF8_INCR(r);
- }
- break;
- case '"':
- if ( state == INQUOTE )
- state = OUTQUOTE;
- else
- state = INQUOTE;
- *r++ = *p;
- break;
+ ufn = ldap_charray2str( vals, ", " );
- case ';':
- case ',':
- if ( state == OUTQUOTE )
- *r++ = ',';
- else
- *r++ = *p;
- break;
-
- case '=':
- if ( state == INQUOTE ) {
- *r++ = *p;
- } else {
- char *rsave = r;
-
- *r = '\0';
- LDAP_UTF8_DECR( r );
-
- while ( !ldap_utf8_isspace( r )
- && *r != ';' && *r != ',' && r > ufn )
- {
- LDAP_UTF8_DECR( r );
- }
- LDAP_UTF8_INCR( r );
-
- if ( strcasecmp( r, "c" )
- && strcasecmp( r, "o" )
- && strcasecmp( r, "ou" )
- && strcasecmp( r, "st" )
- && strcasecmp( r, "l" )
- && strcasecmp( r, "cn" ) ) {
- r = rsave;
- *r++ = '=';
- }
- }
- break;
-
- default:
- LDAP_UTF8_COPY(r, p);
- LDAP_UTF8_INCR(r);
- break;
- }
- }
- *r = '\0';
-
- return( ufn );
+ ldap_memvfree( vals );
+ return ufn;
}
char **
return dn;
}
+#define INQUOTE 1
+#define OUTQUOTE 2
+
static char **
explode_name( const char *name, int notypes, int is_type )
{
timeout.tv_sec = atoi( line );
break;
+#ifdef LDAP_UFN
case 'U': /* set ufn search prefix */
getline( line, sizeof(line), stdin, "ufn prefix? " );
ldap_ufn_setprefix( ld, line );
}
free_list( types );
break;
+#endif
case 'l': /* URL search */
getline( line, sizeof(line), stdin,
printf( " [B]ind async [c]ompare [l]URL search\n" );
printf( " [modi]fy [modr]dn [rem]ove\n" );
printf( " [res]ult [s]earch [q]uit/unbind\n\n" );
- printf( " [u]fn search [ut]fn search with timeout\n" );
+#ifdef LDAP_UFN
+ printf( " [u]fn search [ut]fn search with timeout [U]fn prefix\n" );
+#endif
printf( " [d]ebug [e]nable cache set ms[g]id\n" );
printf( " d[n]suffix [t]imeout [v]ersion\n" );
- printf( " [U]fn prefix [x]uncache entry [X]uncache request\n" );
printf( " [?]help [o]ptions [O]cache options\n" );
printf( " [E]xplode dn [p]arse LDAP URL\n" );
+ printf( " [x]uncache entry [X]uncache request\n" );
break;
default: