r26638: libndr: Require explicitly specifying iconv_convenience for ndr_struct_push_b...
[ira/wip.git] / source4 / dsdb / samdb / ldb_modules / samba3sam.c
index 1653812b8807dca28bd8365bb5991005bba757c1..c8266a5f4644db8707b27baaaa4f3a39e2a0a4bb 100644 (file)
@@ -9,7 +9,7 @@
 #include "ldb/include/ldb.h"
 #include "ldb/include/ldb_private.h"
 #include "ldb/include/ldb_errors.h"
-#include "ldb/modules/ldb_map.h"
+#include "ldb/ldb_map/ldb_map.h"
 #include "system/passwd.h"
 
 #include "librpc/gen_ndr/ndr_security.h"
@@ -84,7 +84,7 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char
        const struct ldb_val *sidval;
        char *sidstring;
        struct dom_sid *sid;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
 
        /* We need the domain, so we get it from the objectSid that we hope is here... */
        sidval = ldb_msg_find_ldb_val(local, "objectSid");
@@ -96,8 +96,9 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char
        if (sid == NULL) {
                return;
        }
-       status = ndr_pull_struct_blob(sidval, sid, sid, (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
-       if (!NT_STATUS_IS_OK(status)) {
+
+       ndr_err = ndr_pull_struct_blob(sidval, sid, sid, (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(sid);
                return;
        }
@@ -179,17 +180,18 @@ static struct ldb_val encode_sid(struct ldb_module *module, TALLOC_CTX *ctx, con
 {
        struct ldb_val out = data_blob(NULL, 0);
        struct dom_sid *sid;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
 
        sid = dom_sid_parse_talloc(ctx, (char *)val->data);
        if (sid == NULL) {
                return out;
        }
 
-       status = ndr_push_struct_blob(&out, ctx, sid,
-                                     (ndr_push_flags_fn_t)ndr_push_dom_sid);
+       ndr_err = ndr_push_struct_blob(&out, ctx, 
+                                      NULL,
+                                      sid, (ndr_push_flags_fn_t)ndr_push_dom_sid);
        talloc_free(sid);
-       if (!NT_STATUS_IS_OK(status)) {
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return out;
        }
 
@@ -201,16 +203,16 @@ static struct ldb_val decode_sid(struct ldb_module *module, TALLOC_CTX *ctx, con
 {
        struct ldb_val out = data_blob(NULL, 0);
        struct dom_sid *sid;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
 
        sid = talloc(ctx, struct dom_sid);
        if (sid == NULL) {
                return out;
        }
 
-       status = ndr_pull_struct_blob(val, sid, sid,
-                                     (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
-       if (!NT_STATUS_IS_OK(status)) {
+       ndr_err = ndr_pull_struct_blob(val, sid, sid,
+                                      (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                goto done;
        }
 
@@ -246,15 +248,11 @@ static struct ldb_val hex2bin(struct ldb_module *module, TALLOC_CTX *ctx, const
 {
        struct ldb_val out;
        struct samr_Password *pwd;
-       pwd = smbpasswd_gethexpwd(ctx, talloc_strndup(ctx, (const char *)val->data, val->length));
+       pwd = smbpasswd_gethexpwd(ctx, (const char *)val->data);
        if (!pwd) {
                return data_blob(NULL, 0);
        }
-       out.data = talloc_memdup(ctx, pwd->hash, sizeof(pwd->hash));
-       if (!out.data) {
-               return data_blob(NULL, 0);
-       }
-       out.length = sizeof(pwd->hash);
+       out = data_blob_talloc(ctx, pwd->hash, sizeof(pwd->hash));
        return out;
 }
 
@@ -331,7 +329,7 @@ const struct ldb_map_attribute samba3_attributes[] =
 
        /* sambaLMPassword -> lmPwdHash*/
        {
-               .local_name = "lmpwdhash",
+               .local_name = "dBCSPwd",
                .type = MAP_CONVERT,
                .u = {
                        .convert = {