Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / libcli / util / nterr.c
index 45d0181103cc6bd776720d183b65fba97cc0f87b..8371837dcb574d682f5282996053e5c201dae3a1 100644 (file)
@@ -5,7 +5,7 @@
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /* NT error codes.  please read nterr.h */
 
 #include "includes.h"
-#include "pstring.h"
+#include "libcli/ldap/ldap_errors.h"
+#undef strcasecmp
 
 typedef struct
 {
@@ -30,6 +30,7 @@ typedef struct
 } nt_err_code_struct;
 
 #define DOS_CODE(class, code) { #class ":" #code, NT_STATUS_DOS(class, code) }
+#define LDAP_CODE(code) { #code, NT_STATUS_LDAP(code) }
 
 static const nt_err_code_struct nt_errs[] =
 {
@@ -544,8 +545,14 @@ static const nt_err_code_struct nt_errs[] =
         { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES },
        { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED },
        { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX },
+       { "NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED", NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED },
+       { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND },
+       { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED },
+       { "NT_STATUS_DS_BUSY", NT_STATUS_DS_BUSY },
        { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES },
        { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED },
+       { "STATUS_NOTIFY_CLEANUP", STATUS_NOTIFY_CLEANUP },
+       { "STATUS_NOTIFY_ENUM_DIR", STATUS_NOTIFY_ENUM_DIR },
 
        DOS_CODE(ERRDOS, ERRsuccess),
        DOS_CODE(ERRDOS, ERRbadfunc),
@@ -668,6 +675,46 @@ static const nt_err_code_struct nt_errs[] =
        DOS_CODE(ERRHRD, ERRsharebufexc),
        DOS_CODE(ERRHRD, ERRdiskfull),
 
+       LDAP_CODE(LDAP_SUCCESS),
+       LDAP_CODE(LDAP_OPERATIONS_ERROR),
+       LDAP_CODE(LDAP_PROTOCOL_ERROR),
+       LDAP_CODE(LDAP_TIME_LIMIT_EXCEEDED),
+       LDAP_CODE(LDAP_SIZE_LIMIT_EXCEEDED),
+       LDAP_CODE(LDAP_COMPARE_FALSE),
+       LDAP_CODE(LDAP_COMPARE_TRUE),
+       LDAP_CODE(LDAP_AUTH_METHOD_NOT_SUPPORTED),
+       LDAP_CODE(LDAP_STRONG_AUTH_REQUIRED),
+       LDAP_CODE(LDAP_REFERRAL),
+       LDAP_CODE(LDAP_ADMIN_LIMIT_EXCEEDED),
+       LDAP_CODE(LDAP_UNAVAILABLE_CRITICAL_EXTENSION),
+       LDAP_CODE(LDAP_CONFIDENTIALITY_REQUIRED),
+       LDAP_CODE(LDAP_SASL_BIND_IN_PROGRESS),
+       LDAP_CODE(LDAP_NO_SUCH_ATTRIBUTE),
+       LDAP_CODE(LDAP_UNDEFINED_ATTRIBUTE_TYPE),
+       LDAP_CODE(LDAP_INAPPROPRIATE_MATCHING),
+       LDAP_CODE(LDAP_CONSTRAINT_VIOLATION),
+       LDAP_CODE(LDAP_ATTRIBUTE_OR_VALUE_EXISTS),
+       LDAP_CODE(LDAP_INVALID_ATTRIBUTE_SYNTAX),
+       LDAP_CODE(LDAP_NO_SUCH_OBJECT),
+       LDAP_CODE(LDAP_ALIAS_PROBLEM),
+       LDAP_CODE(LDAP_INVALID_DN_SYNTAX),
+       LDAP_CODE(LDAP_ALIAS_DEREFERENCING_PROBLEM),
+       LDAP_CODE(LDAP_INAPPROPRIATE_AUTHENTICATION),
+       LDAP_CODE(LDAP_INVALID_CREDENTIALS),
+       LDAP_CODE(LDAP_INSUFFICIENT_ACCESS_RIGHTS),
+       LDAP_CODE(LDAP_BUSY),
+       LDAP_CODE(LDAP_UNAVAILABLE),
+       LDAP_CODE(LDAP_UNWILLING_TO_PERFORM),
+       LDAP_CODE(LDAP_LOOP_DETECT),
+       LDAP_CODE(LDAP_NAMING_VIOLATION),
+       LDAP_CODE(LDAP_OBJECT_CLASS_VIOLATION),
+       LDAP_CODE(LDAP_NOT_ALLOWED_ON_NON_LEAF),
+       LDAP_CODE(LDAP_NOT_ALLOWED_ON_RDN),
+       LDAP_CODE(LDAP_ENTRY_ALREADY_EXISTS),
+       LDAP_CODE(LDAP_OBJECT_CLASS_MODS_PROHIBITED),
+       LDAP_CODE(LDAP_AFFECTS_MULTIPLE_DSAS),
+       LDAP_CODE(LDAP_OTHER),
+
        { NULL, NT_STATUS(0) }
 };
 
@@ -769,7 +816,6 @@ static const nt_err_code_struct nt_err_desc[] =
        { NULL, NT_STATUS(0) }
 };
 
-
 /*****************************************************************************
  returns an NT error message.  not amazingly helpful, but better than a number.
  *****************************************************************************/
@@ -778,11 +824,6 @@ const char *nt_errstr(NTSTATUS nt_code)
         static char msg[40];
         int idx = 0;
 
-       if (NT_STATUS_IS_LDAP(nt_code)) {
-               slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code));
-               return msg;
-       }
-
        while (nt_errs[idx].nt_errstr != NULL) {
                if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 
                     NT_STATUS_V(nt_code)) {
@@ -791,6 +832,11 @@ const char *nt_errstr(NTSTATUS nt_code)
                idx++;
        }
 
+       if (NT_STATUS_IS_LDAP(nt_code)) {
+               slprintf(msg, sizeof(msg), "LDAP code %u", NT_STATUS_LDAP_CODE(nt_code));
+               return msg;
+       }
+
        slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code));
 
         return msg;
@@ -819,7 +865,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
  *****************************************************************************/
 const char *get_nt_error_c_code(NTSTATUS nt_code)
 {
-        static pstring out;
+        static char out[40];
         int idx = 0;
 
        while (nt_errs[idx].nt_errstr != NULL) {