error.c revision 1
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Portions Copyright 1999 Sun Microsystems, Inc. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Use is subject to license terms.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#pragma ident "%Z%%M% %I% %E% SMI"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <stdio.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <string.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <stdlib.h> /* free() for Solaris */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#ifdef MACOS
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#include <stdlib.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#else /* MACOS */
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#if defined( DOS ) || defined( _WIN32 )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#include <malloc.h>
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#include "msdos.h"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#else /* DOS */
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#include <sys/types.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <sys/socket.h>
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov#endif /* DOS */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#endif /* MACOS */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#include "lber.h"
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#include "ldap.h"
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#include "ldap-private.h"
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#include "ldap-int.h"
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchistruct ldaperror {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi int e_code;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi char *e_reason;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi};
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchistatic struct ldaperror ldap_errlist[] = {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#ifdef SUN
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_SUCCESS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_OPERATIONS_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_PROTOCOL_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_TIMELIMIT_EXCEEDED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_SIZELIMIT_EXCEEDED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_COMPARE_FALSE, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_COMPARE_TRUE, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_AUTH_METHOD_NOT_SUPPORTED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_STRONG_AUTH_REQUIRED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_PARTIAL_RESULTS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_REFERRAL, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ADMINLIMIT_EXCEEDED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNAVAILABLE_CRITICAL_EXTENSION, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONFIDENTIALITY_REQUIRED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_SUCH_ATTRIBUTE, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNDEFINED_TYPE, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INAPPROPRIATE_MATCHING, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONSTRAINT_VIOLATION, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_TYPE_OR_VALUE_EXISTS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INVALID_SYNTAX, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_SUCH_OBJECT, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ALIAS_PROBLEM, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INVALID_DN_SYNTAX, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_IS_LEAF, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ALIAS_DEREF_PROBLEM, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INAPPROPRIATE_AUTH, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INVALID_CREDENTIALS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INSUFFICIENT_ACCESS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_BUSY, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNAVAILABLE, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNWILLING_TO_PERFORM, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_LOOP_DETECT, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NAMING_VIOLATION, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_OBJECT_CLASS_VIOLATION, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NOT_ALLOWED_ON_NONLEAF, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NOT_ALLOWED_ON_RDN, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ALREADY_EXISTS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_OBJECT_CLASS_MODS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_RESULTS_TOO_LARGE, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_AFFECTS_MULTIPLE_DSAS, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_OTHER, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_SERVER_DOWN, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_LOCAL_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ENCODING_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_DECODING_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_TIMEOUT, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_AUTH_UNKNOWN, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_FILTER_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_USER_CANCELLED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_PARAM_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_MEMORY, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONNECT_ERROR, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NOT_SUPPORTED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONTROL_NOT_FOUND, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_RESULTS_RETURNED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_MORE_RESULTS_TO_RETURN, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CLIENT_LOOP, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_REFERRAL_LIMIT_EXCEEDED, 0,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#else
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_SUCCESS, "Success",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_OPERATIONS_ERROR, "Operations error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_PROTOCOL_ERROR, "Protocol error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_COMPARE_FALSE, "Compare false",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_COMPARE_TRUE, "Compare true",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_AUTH_METHOD_NOT_SUPPORTED, "Authentication method not supported",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_PARTIAL_RESULTS, "Partial results and referral received",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_REFERRAL, "Referral received",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ADMINLIMIT_EXCEEDED, "Admin. limit exceeded",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNAVAILABLE_CRITICAL_EXTENSION, "Unavailable critical extension",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONFIDENTIALITY_REQUIRED, "Confidentiality required",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_SUCH_ATTRIBUTE, "No such attribute",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNDEFINED_TYPE, "Undefined attribute type",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONSTRAINT_VIOLATION, "Constraint violation",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INVALID_SYNTAX, "Invalid syntax",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_SUCH_OBJECT, "No such object",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ALIAS_PROBLEM, "Alias problem",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_IS_LEAF, "Object is a leaf",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INVALID_CREDENTIALS, "Invalid credentials",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_INSUFFICIENT_ACCESS, "Insufficient access",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_BUSY, "DSA is busy",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNAVAILABLE, "DSA is unavailable",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_LOOP_DETECT, "Loop detected",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NAMING_VIOLATION, "Naming violation",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_OBJECT_CLASS_VIOLATION, "Object class violation",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ALREADY_EXISTS, "Already exists",
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_RESULTS_TOO_LARGE, "Results too large",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_AFFECTS_MULTIPLE_DSAS, "Affects multiple DSAs",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_OTHER, "Unknown error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_SERVER_DOWN, "Can't contact LDAP server",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_LOCAL_ERROR, "Local error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_ENCODING_ERROR, "Encoding error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_DECODING_ERROR, "Decoding error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_TIMEOUT, "Timed out",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_AUTH_UNKNOWN, "Unknown authentication method",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_FILTER_ERROR, "Bad search filter",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_USER_CANCELLED, "User cancelled operation",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_PARAM_ERROR, "Bad parameter to an ldap routine",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_MEMORY, "Out of memory",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONNECT_ERROR, "Connection error",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NOT_SUPPORTED, "Not supported",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CONTROL_NOT_FOUND, "Control not found",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_NO_RESULTS_RETURNED, "No results have been returned",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_MORE_RESULTS_TO_RETURN, "More results to return",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_CLIENT_LOOP, "Loop detected in referrals",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAP_REFERRAL_LIMIT_EXCEEDED, "Too many referrals followed",
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#endif
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe -1, 0
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe};
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#ifdef SUN
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#pragma init (fill_ldap_errlist)
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchistatic void fill_ldap_errlist()
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi{
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi int i=0;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi Debug(LDAP_DEBUG_TRACE, "fill_ldap_errlist\n", 0, 0, 0 );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 130, "Success");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 131, "Operations error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 132, "Protocol error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 133, "Timelimit exceeded");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 134, "Sizelimit exceeded");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 135, "Compare false");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 136, "Compare true");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 137, "Strong authentication not supported");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 138, "Strong authentication required");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 139, "Partial results and referral received");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1262, "Referral received");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1263, "Admin. limit exceeded");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1264, "Unavailable critical extension");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1265, "Confidentiality required");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 140, "No such attribute");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 141, "Undefined attribute type");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 142, "Inappropriate matching");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 143, "Constraint violation");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 144, "Type or value exists");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 145, "Invalid syntax");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 146, "No such object");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 147, "Alias problem");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 148, "Invalid DN syntax");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 149, "Object is a leaf");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 150, "Alias dereferencing problem");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 151, "Inappropriate authentication");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 152, "Invalid credentials");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 153, "Insufficient access");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 154, "DSA is busy");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 155, "DSA is unavailable");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 156, "DSA is unwilling to perform");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 157, "Loop detected");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 158, "Naming violation");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 159, "Object class violation");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 160, "Operation not allowed on nonleaf");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 161, "Operation not allowed on RDN");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 162, "Already exists");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 163, "Cannot modify object class");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 164, "Results too large");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* new with ldapv3 */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1266, "Affects multiple DSAs");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi/* end of new */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 165, "Unknown error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 166, "Can't contact LDAP server");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 167, "Local error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 168, "Encoding error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 169, "Decoding error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 170, "Timed out");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 171, "Unknown authentication method");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 172, "Bad search filter");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 173, "User cancelled operation");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 174, "Bad parameter to an ldap routine");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 175, "Out of memory");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1267, "Connection error");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1268, "Not supported");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1269, "Control not found");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1270, "No results have been returned");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1271, "More results to return");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1272, "Loop detected in referrals");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1273, "Too many referrals followed");
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi}
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#endif
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchichar *
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchildap_err2string( int err )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi{
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi int i;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( err == ldap_errlist[i].e_code )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi return( ldap_errlist[i].e_reason );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi return( catgets(slapdcat, 1 , 165, "Unknown error") );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi}
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#ifndef NO_USERINTERFACE
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchivoid
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchildap_perror( LDAP *ld, char *s )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi{
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi int i;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld == NULL ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi perror( s );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi return;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#ifdef SUN
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi /* for I18N */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ldap_errlist[0].e_reason == NULL ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi fill_ldap_errlist();
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi } /* end if */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#endif
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld->ld_errno == ldap_errlist[i].e_code ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi (void) fprintf( stderr, "%s: %s\n", s,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_errlist[i].e_reason );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld->ld_matched != NULL && *ld->ld_matched != '\0' )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi (void) fprintf( stderr, catgets(slapdcat, 1, 176, "%1$s: matched: %2$s\n"), s,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ld->ld_matched );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi (void) fprintf( stderr, catgets(slapdcat, 1, 177, "%1$s: additional info: %2$s\n"),
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi s, ld->ld_error );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi (void) fflush( stderr );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi return;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi (void) fprintf( stderr, catgets(slapdcat, 1, 178, "%1$s: Not an LDAP errno %2$d\n"), s, ld->ld_errno );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi (void) fflush( stderr );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi}
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#else
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchivoid
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchildap_perror( LDAP *ld, char *s )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi{
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi}
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi#endif /* NO_USERINTERFACE */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchiint
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchildap_result2error( LDAP *ld, LDAPMessage *r, int freeit )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi{
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi LDAPMessage *lm;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi BerElement ber;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi int along;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi int rc;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi Debug( LDAP_DEBUG_TRACE, "ldap_result2error\n", 0, 0, 0 );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( r == NULLMSG )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi return( LDAP_PARAM_ERROR );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi for ( lm = r; lm->lm_chain != NULL; lm = lm->lm_chain )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ; /* NULL */
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld->ld_error ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi free( ld->ld_error );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ld->ld_error = NULL;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld->ld_matched ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi free( ld->ld_matched );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ld->ld_matched = NULL;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ber = *(lm->lm_ber);
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( ld->ld_version == LDAP_VERSION2 ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi rc = ber_scanf( &ber, "{iaa}", &along, &ld->ld_matched,
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi &ld->ld_error );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi } else {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi rc = ber_scanf( &ber, "{ia}", &along, &ld->ld_error );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( rc == LBER_ERROR ) {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ld->ld_errno = LDAP_DECODING_ERROR;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi } else {
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ld->ld_errno = along;
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi }
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi if ( freeit )
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi ldap_msgfree( r );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi return( ld->ld_errno );
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi}
43051d2742bbe5911de73322064cb573b6aff975Robert Mustacchi