1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

s4-dsdb: added a ldb err -> NTSTATUS mapping

this is not perfect, but its better than always giving
NT_STATUS_UNSUCCESSFUL in our RPC servers

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andrew Tridgell 2011-04-01 15:58:21 +11:00
parent db0316832a
commit 81f2dda626

View File

@ -4216,3 +4216,81 @@ bool is_attr_in_list(const char * const * attrs, const char *attr)
return false;
}
/*
map an ldb error code to an approximate NTSTATUS code
*/
NTSTATUS dsdb_ldb_err_to_ntstatus(int err)
{
switch (err) {
case LDB_SUCCESS:
return NT_STATUS_OK;
case LDB_ERR_PROTOCOL_ERROR:
return NT_STATUS_DEVICE_PROTOCOL_ERROR;
case LDB_ERR_TIME_LIMIT_EXCEEDED:
return NT_STATUS_IO_TIMEOUT;
case LDB_ERR_SIZE_LIMIT_EXCEEDED:
return NT_STATUS_BUFFER_TOO_SMALL;
case LDB_ERR_COMPARE_FALSE:
case LDB_ERR_COMPARE_TRUE:
return NT_STATUS_REVISION_MISMATCH;
case LDB_ERR_AUTH_METHOD_NOT_SUPPORTED:
return NT_STATUS_NOT_SUPPORTED;
case LDB_ERR_STRONG_AUTH_REQUIRED:
case LDB_ERR_CONFIDENTIALITY_REQUIRED:
case LDB_ERR_SASL_BIND_IN_PROGRESS:
case LDB_ERR_INAPPROPRIATE_AUTHENTICATION:
case LDB_ERR_INVALID_CREDENTIALS:
case LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS:
case LDB_ERR_UNWILLING_TO_PERFORM:
return NT_STATUS_ACCESS_DENIED;
case LDB_ERR_NO_SUCH_OBJECT:
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
case LDB_ERR_REFERRAL:
case LDB_ERR_NO_SUCH_ATTRIBUTE:
return NT_STATUS_NOT_FOUND;
case LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION:
return NT_STATUS_NOT_SUPPORTED;
case LDB_ERR_ADMIN_LIMIT_EXCEEDED:
return NT_STATUS_BUFFER_TOO_SMALL;
case LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE:
case LDB_ERR_INAPPROPRIATE_MATCHING:
case LDB_ERR_CONSTRAINT_VIOLATION:
case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX:
case LDB_ERR_INVALID_DN_SYNTAX:
case LDB_ERR_NAMING_VIOLATION:
case LDB_ERR_OBJECT_CLASS_VIOLATION:
case LDB_ERR_NOT_ALLOWED_ON_NON_LEAF:
case LDB_ERR_NOT_ALLOWED_ON_RDN:
return NT_STATUS_INVALID_PARAMETER;
case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS:
case LDB_ERR_ENTRY_ALREADY_EXISTS:
return NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS;
case LDB_ERR_BUSY:
return NT_STATUS_NETWORK_BUSY;
case LDB_ERR_ALIAS_PROBLEM:
case LDB_ERR_ALIAS_DEREFERENCING_PROBLEM:
case LDB_ERR_UNAVAILABLE:
case LDB_ERR_LOOP_DETECT:
case LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED:
case LDB_ERR_AFFECTS_MULTIPLE_DSAS:
case LDB_ERR_OTHER:
case LDB_ERR_OPERATIONS_ERROR:
break;
}
return NT_STATUS_UNSUCCESSFUL;
}