mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
Improved but still broken client tools.
This commit is contained in:
parent
aa0067bc50
commit
20e6dcec3b
@ -456,25 +456,30 @@ static int dodelete(
|
||||
|
||||
rc = ldap_delete_ext( ld, dn, NULL, NULL, &id );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_delete_ext" );
|
||||
fprintf( stderr, "ldapdelete: ldap_delete_ext: %s (%d)\n",
|
||||
ldap_err2string( rc ), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res );
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, NULL, &res );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
fprintf( stderr, "ldapdelete: ldap_result: %s (%d)\n",
|
||||
ldap_err2string( rc ), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_parse_result" );
|
||||
fprintf( stderr, "ldapdelete: ldap_parse_result: %s (%d)\n",
|
||||
ldap_err2string( rc ), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
if( verbose || code != LDAP_SUCCESS || matcheddn || text || refs ) {
|
||||
printf( "Result: %s (%d)\n", ldap_err2string( code ), code );
|
||||
if( verbose || code != LDAP_SUCCESS ||
|
||||
(matcheddn && *matcheddn) || (text && *text) || (refs && *refs) )
|
||||
{
|
||||
printf( "Delete Result: %s (%d)\n", ldap_err2string( code ), code );
|
||||
|
||||
if( text && *text ) {
|
||||
printf( "Additional info: %s\n", text );
|
||||
@ -494,7 +499,7 @@ static int dodelete(
|
||||
|
||||
ber_memfree( text );
|
||||
ber_memfree( matcheddn );
|
||||
ber_memvfree( refs );
|
||||
ber_memvfree( (void **) refs );
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -509,25 +509,31 @@ static int domodrdn(
|
||||
NULL, NULL, &id );
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_rename" );
|
||||
fprintf( stderr, "ldapmodrdn: ldap_rename: %s (%d)\n",
|
||||
ldap_err2string( rc ), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res );
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, NULL, &res );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
fprintf( stderr, "ldapmodrdn: ldap_result: %s (%d)\n",
|
||||
ldap_err2string( rc ), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_parse_result" );
|
||||
fprintf( stderr, "ldapmodrdn: ldap_parse_result: %s (%d)\n",
|
||||
ldap_err2string( rc ), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
if( verbose || code != LDAP_SUCCESS || matcheddn || text || refs ) {
|
||||
printf( "Result: %s (%d)\n", ldap_err2string( code ), code );
|
||||
if( verbose || code != LDAP_SUCCESS ||
|
||||
(matcheddn && *matcheddn) || (text && *text) || (refs && *refs) )
|
||||
{
|
||||
printf( "Rename Result: %s (%d)\n",
|
||||
ldap_err2string( code ), code );
|
||||
|
||||
if( text && *text ) {
|
||||
printf( "Additional info: %s\n", text );
|
||||
@ -547,7 +553,7 @@ static int domodrdn(
|
||||
|
||||
ber_memfree( text );
|
||||
ber_memfree( matcheddn );
|
||||
ber_memvfree( refs );
|
||||
ber_memvfree( (void **) refs );
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ main( int argc, char *argv[] )
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res );
|
||||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, NULL, &res );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_result" );
|
||||
return rc;
|
||||
|
@ -713,15 +713,18 @@ static int dosearch(
|
||||
sctrls, cctrls, timelimit, sizelimit, &msgid );
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_search" );
|
||||
fprintf( stderr, "ldapsearch: ldap_search_ext: %s (%d)",
|
||||
ldap_err2string( rc ), rc );
|
||||
return( rc );
|
||||
}
|
||||
|
||||
nresponses = nentries = nreferences = nextended = npartial = 0;
|
||||
|
||||
res = NULL;
|
||||
|
||||
while ((rc = ldap_result( ld, LDAP_RES_ANY,
|
||||
sortattr ? 1 : 0, NULL, &res )) > 0 )
|
||||
sortattr ? LDAP_MSG_ALL : LDAP_MSG_ONE,
|
||||
NULL, &res )) > 0 )
|
||||
{
|
||||
if( sortattr ) {
|
||||
(void) ldap_sort_entries( ld, &res,
|
||||
|
@ -266,8 +266,8 @@ typedef struct ldapcontrol {
|
||||
#define LDAP_RES_EXTENDED ((ber_tag_t) 0x78U) /* V3: application + constructed */
|
||||
#define LDAP_RES_EXTENDED_PARTIAL ((ber_tag_t) 0x79U) /* V3+: application + constructed */
|
||||
|
||||
#define LDAP_RES_ANY ((ber_tag_t)(-1))
|
||||
#define LDAP_RES_UNSOLICITED ((ber_tag_t)(0))
|
||||
#define LDAP_RES_ANY (-1)
|
||||
#define LDAP_RES_UNSOLICITED (0)
|
||||
|
||||
|
||||
/* sasl methods */
|
||||
|
@ -211,7 +211,6 @@ ldap_parse_result(
|
||||
LDAPMessage *lm;
|
||||
ber_int_t errcode = LDAP_SUCCESS;
|
||||
|
||||
int rc;
|
||||
ber_tag_t tag;
|
||||
BerElement *ber;
|
||||
|
||||
@ -307,7 +306,7 @@ ldap_parse_result(
|
||||
}
|
||||
|
||||
if( tag != LBER_ERROR ) {
|
||||
rc = ldap_int_get_controls( ber, serverctrls );
|
||||
int rc = ldap_int_get_controls( ber, serverctrls );
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
tag = LBER_ERROR;
|
||||
|
@ -67,12 +67,14 @@ static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPReques
|
||||
|
||||
/*
|
||||
* ldap_result - wait for an ldap result response to a message from the
|
||||
* ldap server. If msgid is -1, any message will be accepted, otherwise
|
||||
* ldap_result will wait for a response with msgid. If all is 0 the
|
||||
* first message with id msgid will be accepted, otherwise, ldap_result
|
||||
* will wait for all responses with id msgid and then return a pointer to
|
||||
* the entire list of messages. This is only useful for search responses,
|
||||
* which can be of two message types (zero or more entries, followed by an
|
||||
* ldap server. If msgid is LDAP_RES_ANY (-1), any message will be
|
||||
* accepted. If msgid is LDAP_RES_UNSOLICITED (0), any unsolicited
|
||||
* message is accepted. Otherwise ldap_result will wait for a response
|
||||
* with msgid. If all is LDAP_MSG_ONE (0) the first message with id
|
||||
* msgid will be accepted, otherwise, ldap_result will wait for all
|
||||
* responses with id msgid and then return a pointer to the entire list
|
||||
* of messages. This is only useful for search responses, which can be
|
||||
* of two message types (zero or more entries, followed by an
|
||||
* ldap result). The type of the first message received is returned.
|
||||
* When waiting, any messages that have been abandoned are discarded.
|
||||
*
|
||||
|
@ -21,7 +21,7 @@ echo "Running slapadd to build slapd database..."
|
||||
$LDIF2LDBM -f $CONF -l $LDIF
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "slapadd failed!"
|
||||
echo "slapadd failed ($RC)!"
|
||||
exit $RC
|
||||
fi
|
||||
|
||||
@ -42,7 +42,7 @@ for i in 0 1 2 3 4 5; do
|
||||
done
|
||||
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapsearch failed!"
|
||||
echo "ldapsearch failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
@ -50,23 +50,23 @@ fi
|
||||
# -r used to do remove of old rdn
|
||||
|
||||
echo "Testing modrdn(deleteoldrdn=0)..."
|
||||
$LDAPMODRDN -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
|
||||
$LDAPMODRDN -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
|
||||
$TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
|
||||
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapmodrdn failed!"
|
||||
echo "ldapmodrdn failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
|
||||
echo "Testing modrdn(deleteoldrdn=1)..."
|
||||
$LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD >> \
|
||||
$LDAPMODRDN -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD >> \
|
||||
$TESTOUT 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US' 'cn=James A Jones II'
|
||||
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapmodrdn failed!"
|
||||
echo "ldapmodrdn failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
@ -78,7 +78,7 @@ $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
|
||||
'cn=James A Jones III' > $SEARCHOUT 2>&1
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapsearch failed!"
|
||||
echo "ldapsearch failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
@ -105,7 +105,7 @@ $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
|
||||
'cn=James A Jones II' > $SEARCHOUT 2>&1
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapsearch failed!"
|
||||
echo "ldapsearch failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
@ -135,7 +135,7 @@ $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
kill -HUP $PID
|
||||
echo "ldapsearch failed!"
|
||||
echo "ldapsearch failed ($RC)!"
|
||||
exit $RC
|
||||
fi
|
||||
$CMP $SEARCHOUT /dev/null
|
||||
@ -151,7 +151,7 @@ $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
kill -HUP $PID
|
||||
echo "ldapsearch failed!"
|
||||
echo "ldapsearch failed ($RC)!"
|
||||
exit $RC
|
||||
fi
|
||||
|
||||
@ -172,12 +172,12 @@ fi
|
||||
|
||||
|
||||
echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
|
||||
$LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
|
||||
$LDAPMODRDN -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
|
||||
/dev/null 2>&1 'cn=James A Jones III, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones 1'
|
||||
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapmodrdn failed!"
|
||||
echo "ldapmodrdn failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
@ -190,7 +190,7 @@ $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
|
||||
'cn=James A Jones 1' > $SEARCHOUT 2>&1
|
||||
RC=$?
|
||||
if test $RC != 0 ; then
|
||||
echo "ldapsearch failed!"
|
||||
echo "ldapsearch failed ($RC)!"
|
||||
kill -HUP $PID
|
||||
exit $RC
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user