1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-26 15:16:36 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2009-01-22 08:40:04 +08:00
|
|
|
* Copyright 1998-2009 The OpenLDAP Foundation.
|
2003-11-26 15:16:36 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
1998-12-29 04:53:15 +08:00
|
|
|
*/
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1999-06-03 08:37:44 +08:00
|
|
|
|
|
|
|
#include <ac/stdlib.h>
|
1998-08-21 03:42:38 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/time.h>
|
1998-08-21 03:42:38 +08:00
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
#include "ldap-int.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2001-10-05 02:06:08 +08:00
|
|
|
void ldap_int_error_init( void ) {
|
|
|
|
}
|
|
|
|
|
1999-06-01 10:06:12 +08:00
|
|
|
char *
|
|
|
|
ldap_err2string( int err )
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
2009-07-08 04:05:09 +08:00
|
|
|
char *m;
|
1999-06-01 10:06:12 +08:00
|
|
|
|
2009-07-08 04:05:09 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 );
|
2004-12-31 07:04:41 +08:00
|
|
|
|
2009-07-08 04:05:09 +08:00
|
|
|
switch ( err ) {
|
|
|
|
# define C(code, message) case code: m = message; break
|
|
|
|
|
|
|
|
/* LDAPv3 (RFC 4511) codes */
|
|
|
|
C(LDAP_SUCCESS, N_("Success"));
|
|
|
|
C(LDAP_OPERATIONS_ERROR, N_("Operations error"));
|
|
|
|
C(LDAP_PROTOCOL_ERROR, N_("Protocol error"));
|
|
|
|
C(LDAP_TIMELIMIT_EXCEEDED, N_("Time limit exceeded"));
|
|
|
|
C(LDAP_SIZELIMIT_EXCEEDED, N_("Size limit exceeded"));
|
|
|
|
C(LDAP_COMPARE_FALSE, N_("Compare False"));
|
|
|
|
C(LDAP_COMPARE_TRUE, N_("Compare True"));
|
|
|
|
C(LDAP_STRONG_AUTH_NOT_SUPPORTED,N_("Authentication method not supported"));
|
|
|
|
C(LDAP_STRONG_AUTH_REQUIRED, N_("Strong(er) authentication required"));
|
|
|
|
|
|
|
|
C(LDAP_REFERRAL, N_("Referral"));
|
|
|
|
C(LDAP_ADMINLIMIT_EXCEEDED, N_("Administrative limit exceeded"));
|
|
|
|
C(LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
|
|
|
|
N_("Critical extension is unavailable"));
|
|
|
|
C(LDAP_CONFIDENTIALITY_REQUIRED,N_("Confidentiality required"));
|
|
|
|
C(LDAP_SASL_BIND_IN_PROGRESS, N_("SASL bind in progress"));
|
|
|
|
|
|
|
|
C(LDAP_NO_SUCH_ATTRIBUTE, N_("No such attribute"));
|
|
|
|
C(LDAP_UNDEFINED_TYPE, N_("Undefined attribute type"));
|
|
|
|
C(LDAP_INAPPROPRIATE_MATCHING, N_("Inappropriate matching"));
|
|
|
|
C(LDAP_CONSTRAINT_VIOLATION, N_("Constraint violation"));
|
|
|
|
C(LDAP_TYPE_OR_VALUE_EXISTS, N_("Type or value exists"));
|
|
|
|
C(LDAP_INVALID_SYNTAX, N_("Invalid syntax"));
|
|
|
|
|
|
|
|
C(LDAP_NO_SUCH_OBJECT, N_("No such object"));
|
|
|
|
C(LDAP_ALIAS_PROBLEM, N_("Alias problem"));
|
|
|
|
C(LDAP_INVALID_DN_SYNTAX, N_("Invalid DN syntax"));
|
|
|
|
|
|
|
|
C(LDAP_ALIAS_DEREF_PROBLEM, N_("Alias dereferencing problem"));
|
|
|
|
|
|
|
|
C(LDAP_INAPPROPRIATE_AUTH, N_("Inappropriate authentication"));
|
|
|
|
C(LDAP_INVALID_CREDENTIALS, N_("Invalid credentials"));
|
|
|
|
C(LDAP_INSUFFICIENT_ACCESS, N_("Insufficient access"));
|
|
|
|
C(LDAP_BUSY, N_("Server is busy"));
|
|
|
|
C(LDAP_UNAVAILABLE, N_("Server is unavailable"));
|
|
|
|
C(LDAP_UNWILLING_TO_PERFORM, N_("Server is unwilling to perform"));
|
|
|
|
C(LDAP_LOOP_DETECT, N_("Loop detected"));
|
|
|
|
|
|
|
|
C(LDAP_NAMING_VIOLATION, N_("Naming violation"));
|
|
|
|
C(LDAP_OBJECT_CLASS_VIOLATION, N_("Object class violation"));
|
|
|
|
C(LDAP_NOT_ALLOWED_ON_NONLEAF, N_("Operation not allowed on non-leaf"));
|
|
|
|
C(LDAP_NOT_ALLOWED_ON_RDN, N_("Operation not allowed on RDN"));
|
|
|
|
C(LDAP_ALREADY_EXISTS, N_("Already exists"));
|
|
|
|
C(LDAP_NO_OBJECT_CLASS_MODS, N_("Cannot modify object class"));
|
|
|
|
|
|
|
|
C(LDAP_AFFECTS_MULTIPLE_DSAS, N_("Operation affects multiple DSAs"));
|
|
|
|
|
2009-07-13 21:13:38 +08:00
|
|
|
/* Virtual List View draft */
|
|
|
|
C(LDAP_VLV_ERROR, N_("Virtual List View error"));
|
|
|
|
|
2009-07-08 04:05:09 +08:00
|
|
|
C(LDAP_OTHER, N_("Other (e.g., implementation specific) error"));
|
|
|
|
|
|
|
|
/* LDAPv2 (RFC 1777) codes */
|
|
|
|
C(LDAP_PARTIAL_RESULTS, N_("Partial results and referral received"));
|
|
|
|
C(LDAP_IS_LEAF, N_("Entry is a leaf"));
|
|
|
|
|
|
|
|
/* Connection-less LDAP (CLDAP - RFC 1798) code */
|
|
|
|
C(LDAP_RESULTS_TOO_LARGE, N_("Results too large"));
|
|
|
|
|
|
|
|
/* Cancel Operation (RFC 3909) codes */
|
|
|
|
C(LDAP_CANCELLED, N_("Cancelled"));
|
|
|
|
C(LDAP_NO_SUCH_OPERATION, N_("No Operation to Cancel"));
|
|
|
|
C(LDAP_TOO_LATE, N_("Too Late to Cancel"));
|
|
|
|
C(LDAP_CANNOT_CANCEL, N_("Cannot Cancel"));
|
|
|
|
|
|
|
|
/* Assert Control (RFC 4528 and old internet-draft) codes */
|
|
|
|
C(LDAP_ASSERTION_FAILED, N_("Assertion Failed"));
|
|
|
|
C(LDAP_X_ASSERTION_FAILED, N_("Assertion Failed (X)"));
|
|
|
|
|
|
|
|
/* Proxied Authorization Control (RFC 4370 and I-D) codes */
|
|
|
|
C(LDAP_PROXIED_AUTHORIZATION_DENIED, N_("Proxied Authorization Denied"));
|
|
|
|
C(LDAP_X_PROXY_AUTHZ_FAILURE, N_("Proxy Authorization Failure (X)"));
|
|
|
|
|
|
|
|
/* Content Sync Operation (RFC 4533 and I-D) codes */
|
|
|
|
C(LDAP_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required"));
|
|
|
|
C(LDAP_X_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required (X)"));
|
|
|
|
|
|
|
|
/* No-Op Control (draft-zeilenga-ldap-noop) code */
|
|
|
|
C(LDAP_X_NO_OPERATION, N_("No Operation (X)"));
|
|
|
|
|
|
|
|
/* Client Update Protocol (RFC 3928) codes */
|
|
|
|
C(LDAP_CUP_RESOURCES_EXHAUSTED, N_("LCUP Resources Exhausted"));
|
|
|
|
C(LDAP_CUP_SECURITY_VIOLATION, N_("LCUP Security Violation"));
|
|
|
|
C(LDAP_CUP_INVALID_DATA, N_("LCUP Invalid Data"));
|
|
|
|
C(LDAP_CUP_UNSUPPORTED_SCHEME, N_("LCUP Unsupported Scheme"));
|
|
|
|
C(LDAP_CUP_RELOAD_REQUIRED, N_("LCUP Reload Required"));
|
2004-12-31 07:04:41 +08:00
|
|
|
|
2009-07-08 04:05:09 +08:00
|
|
|
#ifdef LDAP_X_TXN
|
|
|
|
/* Codes related to LDAP Transactions (draft-zeilenga-ldap-txn) */
|
|
|
|
C(LDAP_X_TXN_SPECIFY_OKAY, N_("TXN specify okay"));
|
|
|
|
C(LDAP_X_TXN_ID_INVALID, N_("TXN ID is invalid"));
|
|
|
|
#endif
|
2004-12-31 07:04:41 +08:00
|
|
|
|
2009-07-08 04:05:09 +08:00
|
|
|
/* API codes - renumbered since draft-ietf-ldapext-ldap-c-api */
|
|
|
|
C(LDAP_SERVER_DOWN, N_("Can't contact LDAP server"));
|
|
|
|
C(LDAP_LOCAL_ERROR, N_("Local error"));
|
|
|
|
C(LDAP_ENCODING_ERROR, N_("Encoding error"));
|
|
|
|
C(LDAP_DECODING_ERROR, N_("Decoding error"));
|
|
|
|
C(LDAP_TIMEOUT, N_("Timed out"));
|
|
|
|
C(LDAP_AUTH_UNKNOWN, N_("Unknown authentication method"));
|
|
|
|
C(LDAP_FILTER_ERROR, N_("Bad search filter"));
|
|
|
|
C(LDAP_USER_CANCELLED, N_("User cancelled operation"));
|
|
|
|
C(LDAP_PARAM_ERROR, N_("Bad parameter to an ldap routine"));
|
|
|
|
C(LDAP_NO_MEMORY, N_("Out of memory"));
|
|
|
|
C(LDAP_CONNECT_ERROR, N_("Connect error"));
|
|
|
|
C(LDAP_NOT_SUPPORTED, N_("Not Supported"));
|
|
|
|
C(LDAP_CONTROL_NOT_FOUND, N_("Control not found"));
|
|
|
|
C(LDAP_NO_RESULTS_RETURNED, N_("No results returned"));
|
|
|
|
C(LDAP_MORE_RESULTS_TO_RETURN, N_("More results to return"));
|
|
|
|
C(LDAP_CLIENT_LOOP, N_("Client Loop"));
|
|
|
|
C(LDAP_REFERRAL_LIMIT_EXCEEDED, N_("Referral Limit Exceeded"));
|
|
|
|
# undef C
|
|
|
|
|
|
|
|
default:
|
|
|
|
m = (LDAP_API_ERROR(err) ? N_("Unknown API error")
|
|
|
|
: LDAP_E_ERROR(err) ? N_("Unknown (extension) error")
|
|
|
|
: LDAP_X_ERROR(err) ? N_("Unknown (private extension) error")
|
|
|
|
: N_("Unknown error"));
|
|
|
|
break;
|
2004-12-31 07:04:41 +08:00
|
|
|
}
|
|
|
|
|
2009-07-08 04:05:09 +08:00
|
|
|
return _(m);
|
1999-06-01 10:06:12 +08:00
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-06-01 10:06:12 +08:00
|
|
|
/* deprecated */
|
|
|
|
void
|
|
|
|
ldap_perror( LDAP *ld, LDAP_CONST char *str )
|
|
|
|
{
|
2002-10-03 03:14:02 +08:00
|
|
|
int i;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-06-01 10:06:12 +08:00
|
|
|
assert( ld != NULL );
|
|
|
|
assert( LDAP_VALID( ld ) );
|
2005-07-18 14:22:33 +08:00
|
|
|
assert( str != NULL );
|
1999-06-01 10:06:12 +08:00
|
|
|
|
2001-09-09 11:02:54 +08:00
|
|
|
fprintf( stderr, "%s: %s (%d)\n",
|
|
|
|
str ? str : "ldap_perror",
|
2009-07-08 04:05:09 +08:00
|
|
|
ldap_err2string( ld->ld_errno ),
|
2001-09-09 11:02:54 +08:00
|
|
|
ld->ld_errno );
|
1999-06-01 10:06:12 +08:00
|
|
|
|
1999-08-03 04:03:50 +08:00
|
|
|
if ( ld->ld_matched != NULL && ld->ld_matched[0] != '\0' ) {
|
2003-04-06 11:50:05 +08:00
|
|
|
fprintf( stderr, _("\tmatched DN: %s\n"), ld->ld_matched );
|
1999-06-01 10:06:12 +08:00
|
|
|
}
|
|
|
|
|
1999-08-03 04:03:50 +08:00
|
|
|
if ( ld->ld_error != NULL && ld->ld_error[0] != '\0' ) {
|
2003-04-06 11:50:05 +08:00
|
|
|
fprintf( stderr, _("\tadditional info: %s\n"), ld->ld_error );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
2002-10-03 03:14:02 +08:00
|
|
|
if ( ld->ld_referrals != NULL && ld->ld_referrals[0] != NULL) {
|
2003-04-06 11:50:05 +08:00
|
|
|
fprintf( stderr, _("\treferrals:\n") );
|
2002-10-03 03:14:02 +08:00
|
|
|
for (i=0; ld->ld_referrals[i]; i++) {
|
2003-04-06 11:50:05 +08:00
|
|
|
fprintf( stderr, _("\t\t%s\n"), ld->ld_referrals[i] );
|
2002-10-03 03:14:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
fflush( stderr );
|
1998-11-13 05:07:28 +08:00
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-09-24 08:16:16 +08:00
|
|
|
/* deprecated */
|
1998-08-09 08:43:13 +08:00
|
|
|
int
|
|
|
|
ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit )
|
1999-06-29 06:33:03 +08:00
|
|
|
{
|
|
|
|
int rc, err;
|
|
|
|
|
|
|
|
rc = ldap_parse_result( ld, r, &err,
|
|
|
|
NULL, NULL, NULL, NULL, freeit );
|
|
|
|
|
1999-09-24 08:16:16 +08:00
|
|
|
return err != LDAP_SUCCESS ? err : rc;
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse LDAPResult Messages:
|
|
|
|
*
|
|
|
|
* LDAPResult ::= SEQUENCE {
|
|
|
|
* resultCode ENUMERATED,
|
|
|
|
* matchedDN LDAPDN,
|
|
|
|
* errorMessage LDAPString,
|
|
|
|
* referral [3] Referral OPTIONAL }
|
|
|
|
*
|
|
|
|
* including Bind results:
|
|
|
|
*
|
|
|
|
* BindResponse ::= [APPLICATION 1] SEQUENCE {
|
|
|
|
* COMPONENTS OF LDAPResult,
|
|
|
|
* serverSaslCreds [7] OCTET STRING OPTIONAL }
|
2004-12-31 07:04:41 +08:00
|
|
|
*
|
1999-06-29 06:33:03 +08:00
|
|
|
* and ExtendedOp results:
|
|
|
|
*
|
|
|
|
* ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
|
|
|
|
* COMPONENTS OF LDAPResult,
|
|
|
|
* responseName [10] LDAPOID OPTIONAL,
|
|
|
|
* response [11] OCTET STRING OPTIONAL }
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ldap_parse_result(
|
|
|
|
LDAP *ld,
|
|
|
|
LDAPMessage *r,
|
|
|
|
int *errcodep,
|
|
|
|
char **matcheddnp,
|
|
|
|
char **errmsgp,
|
|
|
|
char ***referralsp,
|
|
|
|
LDAPControl ***serverctrls,
|
|
|
|
int freeit )
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
|
|
|
LDAPMessage *lm;
|
1999-09-24 06:10:22 +08:00
|
|
|
ber_int_t errcode = LDAP_SUCCESS;
|
1999-06-29 06:33:03 +08:00
|
|
|
|
|
|
|
ber_tag_t tag;
|
|
|
|
BerElement *ber;
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-06-29 06:33:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "ldap_parse_result\n", 0, 0, 0 );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-06-01 10:06:12 +08:00
|
|
|
assert( ld != NULL );
|
|
|
|
assert( LDAP_VALID( ld ) );
|
|
|
|
assert( r != NULL );
|
|
|
|
|
1999-09-24 06:10:22 +08:00
|
|
|
if(errcodep != NULL) *errcodep = LDAP_SUCCESS;
|
1999-06-29 06:33:03 +08:00
|
|
|
if(matcheddnp != NULL) *matcheddnp = NULL;
|
|
|
|
if(errmsgp != NULL) *errmsgp = NULL;
|
|
|
|
if(referralsp != NULL) *referralsp = NULL;
|
|
|
|
if(serverctrls != NULL) *serverctrls = NULL;
|
|
|
|
|
2003-02-14 07:02:31 +08:00
|
|
|
#ifdef LDAP_R_COMPILE
|
|
|
|
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
|
|
|
|
#endif
|
2005-10-09 02:51:14 +08:00
|
|
|
/* Find the result, last msg in chain... */
|
|
|
|
lm = r->lm_chain_tail;
|
2006-03-24 02:36:10 +08:00
|
|
|
/* FIXME: either this is not possible (assert?)
|
|
|
|
* or it should be handled */
|
|
|
|
if ( lm != NULL ) {
|
|
|
|
switch ( lm->lm_msgtype ) {
|
|
|
|
case LDAP_RES_SEARCH_ENTRY:
|
|
|
|
case LDAP_RES_SEARCH_REFERENCE:
|
|
|
|
case LDAP_RES_INTERMEDIATE:
|
|
|
|
lm = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if( lm == NULL ) {
|
2010-03-26 22:05:47 +08:00
|
|
|
errcode = ld->ld_errno = LDAP_NO_RESULTS_RETURNED;
|
2003-02-14 07:02:31 +08:00
|
|
|
#ifdef LDAP_R_COMPILE
|
|
|
|
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
|
|
|
|
#endif
|
2010-03-26 22:05:47 +08:00
|
|
|
goto done;
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
if ( ld->ld_error ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( ld->ld_error );
|
1998-08-09 08:43:13 +08:00
|
|
|
ld->ld_error = NULL;
|
|
|
|
}
|
|
|
|
if ( ld->ld_matched ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE( ld->ld_matched );
|
1998-08-09 08:43:13 +08:00
|
|
|
ld->ld_matched = NULL;
|
|
|
|
}
|
2002-10-03 03:14:02 +08:00
|
|
|
if ( ld->ld_referrals ) {
|
|
|
|
LDAP_VFREE( ld->ld_referrals );
|
|
|
|
ld->ld_referrals = NULL;
|
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-06-29 06:33:03 +08:00
|
|
|
/* parse results */
|
|
|
|
|
|
|
|
ber = ber_dup( lm->lm_ber );
|
1999-06-01 10:06:12 +08:00
|
|
|
|
|
|
|
if ( ld->ld_version < LDAP_VERSION2 ) {
|
2005-11-13 02:42:03 +08:00
|
|
|
tag = ber_scanf( ber, "{iA}",
|
|
|
|
&ld->ld_errno, &ld->ld_error );
|
|
|
|
|
1999-06-01 10:06:12 +08:00
|
|
|
} else {
|
1999-06-29 06:33:03 +08:00
|
|
|
ber_len_t len;
|
2005-11-13 02:42:03 +08:00
|
|
|
|
|
|
|
tag = ber_scanf( ber, "{iAA" /*}*/,
|
|
|
|
&ld->ld_errno, &ld->ld_matched, &ld->ld_error );
|
1999-06-29 06:33:03 +08:00
|
|
|
|
|
|
|
if( tag != LBER_ERROR ) {
|
|
|
|
/* peek for referrals */
|
|
|
|
if( ber_peek_tag(ber, &len) == LDAP_TAG_REFERRAL ) {
|
2002-10-03 03:14:02 +08:00
|
|
|
tag = ber_scanf( ber, "v", &ld->ld_referrals );
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* need to clean out misc items */
|
|
|
|
if( tag != LBER_ERROR ) {
|
|
|
|
if( lm->lm_msgtype == LDAP_RES_BIND ) {
|
|
|
|
/* look for sasl result creditials */
|
|
|
|
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SASL_RES_CREDS ) {
|
|
|
|
/* skip 'em */
|
|
|
|
tag = ber_scanf( ber, "x" );
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if( lm->lm_msgtype == LDAP_RES_EXTENDED ) {
|
|
|
|
/* look for exop result oid or value */
|
|
|
|
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_EXOP_RES_OID ) {
|
|
|
|
/* skip 'em */
|
|
|
|
tag = ber_scanf( ber, "x" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( tag != LBER_ERROR &&
|
|
|
|
ber_peek_tag( ber, &len ) == LDAP_TAG_EXOP_RES_VALUE )
|
|
|
|
{
|
|
|
|
/* skip 'em */
|
|
|
|
tag = ber_scanf( ber, "x" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( tag != LBER_ERROR ) {
|
2003-10-12 16:14:28 +08:00
|
|
|
int rc = ldap_pvt_get_controls( ber, serverctrls );
|
1999-06-29 06:33:03 +08:00
|
|
|
|
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
tag = LBER_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( tag != LBER_ERROR ) {
|
|
|
|
tag = ber_scanf( ber, /*{*/"}" );
|
|
|
|
}
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
1999-05-19 14:13:44 +08:00
|
|
|
|
1999-06-29 06:33:03 +08:00
|
|
|
if ( tag == LBER_ERROR ) {
|
1999-09-24 06:35:58 +08:00
|
|
|
ld->ld_errno = errcode = LDAP_DECODING_ERROR;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
|
1999-06-29 06:33:03 +08:00
|
|
|
if( ber != NULL ) {
|
|
|
|
ber_free( ber, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return */
|
1999-10-08 08:51:35 +08:00
|
|
|
if( errcodep != NULL ) {
|
|
|
|
*errcodep = ld->ld_errno;
|
|
|
|
}
|
1999-06-29 06:33:03 +08:00
|
|
|
if ( errcode == LDAP_SUCCESS ) {
|
|
|
|
if( matcheddnp != NULL ) {
|
2005-11-13 02:42:03 +08:00
|
|
|
if ( ld->ld_matched )
|
|
|
|
{
|
|
|
|
*matcheddnp = LDAP_STRDUP( ld->ld_matched );
|
|
|
|
}
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
if( errmsgp != NULL ) {
|
2005-11-13 02:42:03 +08:00
|
|
|
if ( ld->ld_error )
|
|
|
|
{
|
|
|
|
*errmsgp = LDAP_STRDUP( ld->ld_error );
|
|
|
|
}
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
|
2002-10-03 03:14:02 +08:00
|
|
|
if( referralsp != NULL) {
|
|
|
|
*referralsp = ldap_value_dup( ld->ld_referrals );
|
|
|
|
}
|
1999-06-29 06:33:03 +08:00
|
|
|
}
|
|
|
|
|
2003-02-14 07:02:31 +08:00
|
|
|
#ifdef LDAP_R_COMPILE
|
|
|
|
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
|
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2010-03-26 22:05:47 +08:00
|
|
|
done:
|
|
|
|
if ( freeit ) {
|
|
|
|
ldap_msgfree( r );
|
|
|
|
}
|
|
|
|
|
|
|
|
return errcode;
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|