s4:ldap_backend.c - map error codes - add a change which allows custom WERROR codes
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sun, 15 Aug 2010 07:25:58 +0000 (09:25 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sun, 15 Aug 2010 17:42:39 +0000 (19:42 +0200)
This is strictly needed by my recent passwords work, since I want to remove
most of the password change stuff in "samr_password.c". Since AD gives us
CONSTRAINT_VIOLATION on all change problems I cannot distinguish on the SAMR
level which the real cause was about. Therefore I need the extended WERROR codes
here.

source4/ldap_server/ldap_backend.c

index d5b1a39181046e725be702bb410834d5d77d5601..ffe637d7d47ed1c93078210fedf379161048920c 100644 (file)
@@ -45,6 +45,19 @@ static int map_ldb_error(TALLOC_CTX *mem_ctx, int ldb_err,
 {
        WERROR err;
 
+       /* Certain LDB modules need to return very special WERROR codes. Proof
+        * for them here and if they exist skip the rest of the mapping. */
+       if (add_err_string != NULL) {
+               char *endptr;
+               strtol(add_err_string, &endptr, 16);
+               if (endptr != add_err_string) {
+                       *errstring = add_err_string;
+                       return ldb_err;
+               }
+       }
+
+       /* Otherwise we calculate here a generic, but appropriate WERROR. */
+
        switch (ldb_err) {
        case LDB_SUCCESS:
                err = WERR_OK;