bsw@1071: /* This file contains error code mappings of LDAP error codes and OpenLDAP bsw@1071: * error codes. bsw@1071: * bsw@1071: * The collection of error codes (mldap_errorcodes[]) has been derived from bsw@1071: * the file ldap.h that is part of OpenLDAP Software. OpenLDAP's license bsw@1071: * information is stated below: bsw@1071: * bsw@1071: * This work is part of OpenLDAP Software . bsw@1071: * bsw@1071: * Copyright 1998-2013 The OpenLDAP Foundation. bsw@1071: * All rights reserved. bsw@1071: * bsw@1071: * Redistribution and use in source and binary forms, with or without bsw@1071: * modification, are permitted only as authorized by the OpenLDAP bsw@1071: * Public License. bsw@1071: * bsw@1071: * A copy of this license is available below: bsw@1071: * bsw@1071: * The OpenLDAP Public License bsw@1071: * Version 2.8, 17 August 2003 bsw@1071: * bsw@1071: * Redistribution and use of this software and associated documentation bsw@1071: * ("Software"), with or without modification, are permitted provided bsw@1071: * that the following conditions are met: bsw@1071: * bsw@1071: * 1. Redistributions in source form must retain copyright statements bsw@1071: * and notices, bsw@1071: * bsw@1071: * 2. Redistributions in binary form must reproduce applicable copyright bsw@1071: * statements and notices, this list of conditions, and the following bsw@1071: * disclaimer in the documentation and/or other materials provided bsw@1071: * with the distribution, and bsw@1071: * bsw@1071: * 3. Redistributions must contain a verbatim copy of this document. bsw@1071: * bsw@1071: * The OpenLDAP Foundation may revise this license from time to time. bsw@1071: * Each revision is distinguished by a version number. You may use bsw@1071: * this Software under terms of this license revision or under the bsw@1071: * terms of any subsequent revision of the license. bsw@1071: * bsw@1071: * THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS bsw@1071: * CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, bsw@1071: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY bsw@1071: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT bsw@1071: * SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S) bsw@1071: * OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, bsw@1071: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, bsw@1071: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; bsw@1071: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER bsw@1071: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT bsw@1071: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN bsw@1071: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE bsw@1071: * POSSIBILITY OF SUCH DAMAGE. bsw@1071: * bsw@1071: * The names of the authors and copyright holders must not be used in bsw@1071: * advertising or otherwise to promote the sale, use or other dealing bsw@1071: * in this Software without specific, written prior permission. Title bsw@1071: * to copyright in this Software shall at all times remain with copyright bsw@1071: * holders. bsw@1071: * bsw@1071: * OpenLDAP is a registered trademark of the OpenLDAP Foundation. bsw@1071: * bsw@1071: * Copyright 1999-2003 The OpenLDAP Foundation, Redwood City, bsw@1071: * California, USA. All Rights Reserved. Permission to copy and bsw@1071: * distribute verbatim copies of this document is granted. bsw@1071: * bsw@1071: * End of OpenLDAP Public License bsw@1071: * bsw@1071: * Portions Copyright (c) 1990 Regents of the University of Michigan. bsw@1071: * All rights reserved. bsw@1071: * bsw@1071: * Redistribution and use in source and binary forms are permitted bsw@1071: * provided that this notice is preserved and that due credit is given bsw@1071: * to the University of Michigan at Ann Arbor. The name of the University bsw@1071: * may not be used to endorse or promote products derived from this bsw@1071: * software without specific prior written permission. This software bsw@1071: * is provided ``as is'' without express or implied warranty. bsw@1071: * bsw@1071: * End of OpenLDAP's license information bsw@1071: */ bsw@1071: bsw@1071: // type for entry in mldap_errorcodes[] array: bsw@1071: struct mldap_errorcode { bsw@1071: const char *ident; bsw@1071: int code; bsw@1071: }; bsw@1071: bsw@1071: // NULL terminated array of error code strings with error code integers bsw@1071: // derived from ldap.h (see above copyright notice): bsw@1071: static const struct mldap_errorcode mldap_errorcodes[] = { bsw@1071: {"operations_error", 1}, bsw@1071: {"protocol_error", 2}, bsw@1071: {"timelimit_exceeded", 3}, bsw@1071: {"sizelimit_exceeded", 4}, bsw@1071: {"compare_false", 5}, bsw@1071: {"compare_true", 6}, bsw@1071: // {"auth_method_not_supported", 7}, bsw@1071: {"strong_auth_not_supported", 7}, bsw@1071: {"strong_auth_required", 8}, bsw@1071: // {"stronger_auth_required", 8}, bsw@1071: {"partial_results", 9}, bsw@1071: {"referral", 10}, bsw@1071: {"adminlimit_exceeded", 11}, bsw@1071: {"unavailable_critical_extension", 12}, bsw@1071: {"confidentiality_required", 13}, bsw@1071: {"sasl_bind_in_progress", 14}, bsw@1071: {"no_such_attribute", 16}, bsw@1071: {"undefined_type", 17}, bsw@1071: {"inappropriate_matching", 18}, bsw@1071: {"constraint_violation", 19}, bsw@1071: {"type_or_value_exists", 20}, bsw@1071: {"invalid_syntax", 21}, bsw@1071: {"no_such_object", 32}, bsw@1071: {"alias_problem", 33}, bsw@1071: {"invalid_dn_syntax", 34}, bsw@1071: {"is_leaf", 35}, bsw@1071: {"alias_deref_problem", 36}, bsw@1071: {"x_proxy_authz_failure", 47}, bsw@1071: {"inappropriate_auth", 48}, bsw@1071: {"invalid_credentials", 49}, bsw@1071: {"insufficient_access", 50}, bsw@1071: {"busy", 51}, bsw@1071: {"unavailable", 52}, bsw@1071: {"unwilling_to_perform", 53}, bsw@1071: {"loop_detect", 54}, bsw@1071: {"naming_violation", 64}, bsw@1071: {"object_class_violation", 65}, bsw@1071: {"not_allowed_on_nonleaf", 66}, bsw@1071: {"not_allowed_on_rdn", 67}, bsw@1071: {"already_exists", 68}, bsw@1071: {"no_object_class_mods", 69}, bsw@1071: {"results_too_large", 70}, bsw@1071: {"affects_multiple_dsas", 71}, bsw@1071: {"vlv_error", 76}, bsw@1071: {"other", 80}, bsw@1071: {"cup_resources_exhausted", 113}, bsw@1071: {"cup_security_violation", 114}, bsw@1071: {"cup_invalid_data", 115}, bsw@1071: {"cup_unsupported_scheme", 116}, bsw@1071: {"cup_reload_required", 117}, bsw@1071: {"cancelled", 118}, bsw@1071: {"no_such_operation", 119}, bsw@1071: {"too_late", 120}, bsw@1071: {"cannot_cancel", 121}, bsw@1071: {"assertion_failed", 122}, bsw@1071: {"proxied_authorization_denied", 123}, bsw@1071: {"sync_refresh_required", 4096}, bsw@1071: {"x_sync_refresh_required", 16640}, bsw@1071: {"x_assertion_failed", 16655}, bsw@1071: {"x_no_operation", 16654}, bsw@1071: {"x_no_referrals_found", 16656}, bsw@1071: {"x_cannot_chain", 16657}, bsw@1071: {"x_invalidreference", 16658}, bsw@1071: {"x_txn_specify_okay", 16672}, bsw@1071: {"x_txn_id_invalid", 16673}, bsw@1071: {"server_down", (-1)}, bsw@1071: {"local_error", (-2)}, bsw@1071: {"encoding_error", (-3)}, bsw@1071: {"decoding_error", (-4)}, bsw@1071: {"timeout", (-5)}, bsw@1071: {"auth_unknown", (-6)}, bsw@1071: {"filter_error", (-7)}, bsw@1071: {"user_cancelled", (-8)}, bsw@1071: {"param_error", (-9)}, bsw@1071: {"no_memory", (-10)}, bsw@1071: {"connect_error", (-11)}, bsw@1071: {"not_supported", (-12)}, bsw@1071: {"control_not_found", (-13)}, bsw@1071: {"no_results_returned", (-14)}, bsw@1071: {"more_results_to_return", (-15)}, bsw@1071: {"client_loop", (-16)}, bsw@1071: {"referral_limit_exceeded", (-17)}, bsw@1071: {"x_connecting", (-18)}, bsw@1071: {NULL, 0} bsw@1071: }; bsw@1071: bsw@1071: void mldap_set_errorcodes(lua_State *L) { bsw@1071: // stores mldap_errorcodes[] mappings in the Lua table on top of the stack bsw@1071: // in both directions (string mapped to integer and vice versa) bsw@1071: bsw@1071: const struct mldap_errorcode *errorcode; // pointer to entry in mldap_errorcodes[] array bsw@1071: bsw@1071: // iterate through entries in mldap_errorcodes[] array: bsw@1071: for (errorcode=mldap_errorcodes; errorcode->ident; errorcode++) { bsw@1071: bsw@1071: // store a mapping from the string to the integer: bsw@1071: lua_pushstring(L, errorcode->ident); bsw@1071: lua_pushinteger(L, errorcode->code); bsw@1071: lua_settable(L, -3); bsw@1071: bsw@1071: // store a mapping from the integer to the string: bsw@1071: lua_pushinteger(L, errorcode->code); bsw@1071: lua_pushstring(L, errorcode->ident); bsw@1071: lua_settable(L, -3); bsw@1071: bsw@1071: } bsw@1071: bsw@1071: } bsw@1071: