]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/error.c
ITS#5360 move tls option setup
[openldap] / libraries / libldap / error.c
index 529a3e2eeabd23a75ee02ec9f4fa241471678af8..250f2b9f1adef00c3b5018396d4b91074dc84fc9 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2008 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -12,9 +12,6 @@
  * top-level directory of the distribution or, alternatively, at
  * <http://www.OpenLDAP.org/license.html>.
  */
-/* Portions Copyright (C) The Internet Society (1997)
- * ASN.1 fragments are from RFC 2251; see RFC for full legal notices.
- */
 
 #include "portable.h"
 
@@ -65,7 +62,6 @@ static struct ldaperror ldap_builtin_errlist[] = {
        {LDAP_IS_LEAF,                                  N_("Entry is a leaf")},
        {LDAP_ALIAS_DEREF_PROBLEM,              N_("Alias dereferencing problem")},
 
-       {LDAP_PROXY_AUTHZ_FAILURE,              N_("Proxy Authorization Failure")},
        {LDAP_INAPPROPRIATE_AUTH,               N_("Inappropriate authentication")},
        {LDAP_INVALID_CREDENTIALS,              N_("Invalid credentials")},
        {LDAP_INSUFFICIENT_ACCESS,              N_("Insufficient access")},
@@ -83,7 +79,7 @@ static struct ldaperror ldap_builtin_errlist[] = {
        {LDAP_RESULTS_TOO_LARGE,                N_("Results too large")},
        {LDAP_AFFECTS_MULTIPLE_DSAS,    N_("Operation affects multiple DSAs")},
 
-       {LDAP_OTHER,                                    N_("Internal (implementation specific) error")},
+       {LDAP_OTHER,                                    N_("Other (e.g., implementation specific) error")},
 
        {LDAP_CANCELLED,                                N_("Cancelled")},
        {LDAP_NO_SUCH_OPERATION,                N_("No Operation to Cancel")},
@@ -93,11 +89,25 @@ static struct ldaperror ldap_builtin_errlist[] = {
        {LDAP_ASSERTION_FAILED,                 N_("Assertion Failed")},
        {LDAP_X_ASSERTION_FAILED,               N_("Assertion Failed (X)")},
 
+       {LDAP_PROXIED_AUTHORIZATION_DENIED, N_("Proxied Authorization Denied")},
+       {LDAP_X_PROXY_AUTHZ_FAILURE,            N_("Proxy Authorization Failure (X)")},
+
        {LDAP_SYNC_REFRESH_REQUIRED,    N_("Content Sync Refresh Required")},
        {LDAP_X_SYNC_REFRESH_REQUIRED,  N_("Content Sync Refresh Required (X)")},
 
        {LDAP_X_NO_OPERATION,                   N_("No Operation (X)")},
 
+       {LDAP_CUP_RESOURCES_EXHAUSTED,  N_("LCUP Resources Exhausted")},
+       {LDAP_CUP_SECURITY_VIOLATION,   N_("LCUP Security Violation")},
+       {LDAP_CUP_INVALID_DATA,                 N_("LCUP Invalid Data")},
+       {LDAP_CUP_UNSUPPORTED_SCHEME,   N_("LCUP Unsupported Scheme")},
+       {LDAP_CUP_RELOAD_REQUIRED,              N_("LCUP Reload Required")},
+
+#ifdef LDAP_X_TXN
+       {LDAP_X_TXN_SPECIFY_OKAY,               N_("TXN specify okay")},
+       {LDAP_X_TXN_ID_INVALID,                 N_("TXN ID is invalid")},
+#endif
+
        /* API ResultCodes */
        {LDAP_SERVER_DOWN,                              N_("Can't contact LDAP server")},
        {LDAP_LOCAL_ERROR,                              N_("Local error")},
@@ -118,12 +128,6 @@ static struct ldaperror ldap_builtin_errlist[] = {
        {LDAP_CLIENT_LOOP,                              N_("Client Loop")},
        {LDAP_REFERRAL_LIMIT_EXCEEDED,  N_("Referral Limit Exceeded")},
 
-       {LDAP_CUP_RESOURCES_EXHAUSTED,  N_("LCUP Resources Exhausted")},
-       {LDAP_CUP_SECURITY_VIOLATION,   N_("LCUP Security Violation")},
-       {LDAP_CUP_INVALID_DATA,                 N_("LCUP Invalid Data")},
-       {LDAP_CUP_UNSUPPORTED_SCHEME,   N_("LCUP Unsupported Scheme")},
-       {LDAP_CUP_RELOAD_REQUIRED,              N_("LCUP Reload Required")},
-
        {0, NULL}
 };
 
@@ -278,10 +282,19 @@ ldap_parse_result(
 #endif
        /* Find the result, last msg in chain... */
        lm = r->lm_chain_tail;
-       if ((lm->lm_msgtype == LDAP_RES_SEARCH_ENTRY) ||
-               (lm->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) ||
-               (lm->lm_msgtype == LDAP_RES_INTERMEDIATE)) {
-               lm = NULL;      
+       /* 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;
+               }
        }
 
        if( lm == NULL ) {
@@ -310,11 +323,13 @@ ldap_parse_result(
        ber = ber_dup( lm->lm_ber );
 
        if ( ld->ld_version < LDAP_VERSION2 ) {
-               tag = ber_scanf( ber, "{ia}",
+               tag = ber_scanf( ber, "{iA}",
                        &ld->ld_errno, &ld->ld_error );
+
        } else {
                ber_len_t len;
-               tag = ber_scanf( ber, "{iaa" /*}*/,
+
+               tag = ber_scanf( ber, "{iAA" /*}*/,
                        &ld->ld_errno, &ld->ld_matched, &ld->ld_error );
 
                if( tag != LBER_ERROR ) {
@@ -376,10 +391,16 @@ ldap_parse_result(
        }
        if ( errcode == LDAP_SUCCESS ) {
                if( matcheddnp != NULL ) {
-                       *matcheddnp = LDAP_STRDUP( ld->ld_matched );
+                       if ( ld->ld_matched )
+                       {
+                               *matcheddnp = LDAP_STRDUP( ld->ld_matched );
+                       }
                }
                if( errmsgp != NULL ) {
-                       *errmsgp = LDAP_STRDUP( ld->ld_error );
+                       if ( ld->ld_error )
+                       {
+                               *errmsgp = LDAP_STRDUP( ld->ld_error );
+                       }
                }
 
                if( referralsp != NULL) {