Merge branch 'master' of ssh://git.samba.org/data/git/samba
[sfrench/samba-autobuild/.git] / source3 / librpc / gen_ndr / srv_lsa.c
index 8f8f985650ec277095ee79b37996075ea67ed6ce..c30f276800e210a88bda57ec5d4fb1b4c660ef18 100644 (file)
@@ -17,7 +17,7 @@ static bool api_lsa_Close(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CLOSE];
 
-       r = talloc(NULL, struct lsa_Close);
+       r = talloc(talloc_tos(), struct lsa_Close);
        if (r == NULL) {
                return false;
        }
@@ -27,7 +27,7 @@ static bool api_lsa_Close(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -58,7 +58,7 @@ static bool api_lsa_Close(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_Close, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -92,7 +92,7 @@ static bool api_lsa_Delete(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_DELETE];
 
-       r = talloc(NULL, struct lsa_Delete);
+       r = talloc(talloc_tos(), struct lsa_Delete);
        if (r == NULL) {
                return false;
        }
@@ -102,7 +102,7 @@ static bool api_lsa_Delete(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -131,7 +131,7 @@ static bool api_lsa_Delete(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_Delete, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -165,7 +165,7 @@ static bool api_lsa_EnumPrivs(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMPRIVS];
 
-       r = talloc(NULL, struct lsa_EnumPrivs);
+       r = talloc(talloc_tos(), struct lsa_EnumPrivs);
        if (r == NULL) {
                return false;
        }
@@ -175,7 +175,7 @@ static bool api_lsa_EnumPrivs(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -212,7 +212,7 @@ static bool api_lsa_EnumPrivs(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumPrivs, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -246,7 +246,7 @@ static bool api_lsa_QuerySecurity(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYSECURITY];
 
-       r = talloc(NULL, struct lsa_QuerySecurity);
+       r = talloc(talloc_tos(), struct lsa_QuerySecurity);
        if (r == NULL) {
                return false;
        }
@@ -256,7 +256,7 @@ static bool api_lsa_QuerySecurity(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -274,7 +274,7 @@ static bool api_lsa_QuerySecurity(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.sdbuf = talloc_zero(r, struct sec_desc_buf);
+       r->out.sdbuf = talloc_zero(r, struct sec_desc_buf *);
        if (r->out.sdbuf == NULL) {
                talloc_free(r);
                return false;
@@ -292,7 +292,7 @@ static bool api_lsa_QuerySecurity(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QuerySecurity, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -326,7 +326,7 @@ static bool api_lsa_SetSecObj(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETSECOBJ];
 
-       r = talloc(NULL, struct lsa_SetSecObj);
+       r = talloc(talloc_tos(), struct lsa_SetSecObj);
        if (r == NULL) {
                return false;
        }
@@ -336,7 +336,7 @@ static bool api_lsa_SetSecObj(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -365,7 +365,7 @@ static bool api_lsa_SetSecObj(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetSecObj, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -399,7 +399,7 @@ static bool api_lsa_ChangePassword(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CHANGEPASSWORD];
 
-       r = talloc(NULL, struct lsa_ChangePassword);
+       r = talloc(talloc_tos(), struct lsa_ChangePassword);
        if (r == NULL) {
                return false;
        }
@@ -409,7 +409,7 @@ static bool api_lsa_ChangePassword(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -438,7 +438,7 @@ static bool api_lsa_ChangePassword(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_ChangePassword, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -472,7 +472,7 @@ static bool api_lsa_OpenPolicy(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_OPENPOLICY];
 
-       r = talloc(NULL, struct lsa_OpenPolicy);
+       r = talloc(talloc_tos(), struct lsa_OpenPolicy);
        if (r == NULL) {
                return false;
        }
@@ -482,7 +482,7 @@ static bool api_lsa_OpenPolicy(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -518,7 +518,7 @@ static bool api_lsa_OpenPolicy(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_OpenPolicy, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -552,7 +552,7 @@ static bool api_lsa_QueryInfoPolicy(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYINFOPOLICY];
 
-       r = talloc(NULL, struct lsa_QueryInfoPolicy);
+       r = talloc(talloc_tos(), struct lsa_QueryInfoPolicy);
        if (r == NULL) {
                return false;
        }
@@ -562,7 +562,7 @@ static bool api_lsa_QueryInfoPolicy(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -580,7 +580,7 @@ static bool api_lsa_QueryInfoPolicy(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.info = talloc_zero(r, union lsa_PolicyInformation);
+       r->out.info = talloc_zero(r, union lsa_PolicyInformation *);
        if (r->out.info == NULL) {
                talloc_free(r);
                return false;
@@ -598,7 +598,7 @@ static bool api_lsa_QueryInfoPolicy(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QueryInfoPolicy, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -632,7 +632,7 @@ static bool api_lsa_SetInfoPolicy(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETINFOPOLICY];
 
-       r = talloc(NULL, struct lsa_SetInfoPolicy);
+       r = talloc(talloc_tos(), struct lsa_SetInfoPolicy);
        if (r == NULL) {
                return false;
        }
@@ -642,7 +642,7 @@ static bool api_lsa_SetInfoPolicy(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -671,7 +671,7 @@ static bool api_lsa_SetInfoPolicy(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetInfoPolicy, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -705,7 +705,7 @@ static bool api_lsa_ClearAuditLog(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CLEARAUDITLOG];
 
-       r = talloc(NULL, struct lsa_ClearAuditLog);
+       r = talloc(talloc_tos(), struct lsa_ClearAuditLog);
        if (r == NULL) {
                return false;
        }
@@ -715,7 +715,7 @@ static bool api_lsa_ClearAuditLog(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -744,7 +744,7 @@ static bool api_lsa_ClearAuditLog(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_ClearAuditLog, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -778,7 +778,7 @@ static bool api_lsa_CreateAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREATEACCOUNT];
 
-       r = talloc(NULL, struct lsa_CreateAccount);
+       r = talloc(talloc_tos(), struct lsa_CreateAccount);
        if (r == NULL) {
                return false;
        }
@@ -788,7 +788,7 @@ static bool api_lsa_CreateAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -824,7 +824,7 @@ static bool api_lsa_CreateAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CreateAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -858,7 +858,7 @@ static bool api_lsa_EnumAccounts(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMACCOUNTS];
 
-       r = talloc(NULL, struct lsa_EnumAccounts);
+       r = talloc(talloc_tos(), struct lsa_EnumAccounts);
        if (r == NULL) {
                return false;
        }
@@ -868,7 +868,7 @@ static bool api_lsa_EnumAccounts(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -905,7 +905,7 @@ static bool api_lsa_EnumAccounts(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumAccounts, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -939,7 +939,7 @@ static bool api_lsa_CreateTrustedDomain(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREATETRUSTEDDOMAIN];
 
-       r = talloc(NULL, struct lsa_CreateTrustedDomain);
+       r = talloc(talloc_tos(), struct lsa_CreateTrustedDomain);
        if (r == NULL) {
                return false;
        }
@@ -949,7 +949,7 @@ static bool api_lsa_CreateTrustedDomain(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -985,7 +985,7 @@ static bool api_lsa_CreateTrustedDomain(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CreateTrustedDomain, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1019,7 +1019,7 @@ static bool api_lsa_EnumTrustDom(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMTRUSTDOM];
 
-       r = talloc(NULL, struct lsa_EnumTrustDom);
+       r = talloc(talloc_tos(), struct lsa_EnumTrustDom);
        if (r == NULL) {
                return false;
        }
@@ -1029,7 +1029,7 @@ static bool api_lsa_EnumTrustDom(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1066,7 +1066,7 @@ static bool api_lsa_EnumTrustDom(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumTrustDom, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1100,7 +1100,7 @@ static bool api_lsa_LookupNames(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPNAMES];
 
-       r = talloc(NULL, struct lsa_LookupNames);
+       r = talloc(talloc_tos(), struct lsa_LookupNames);
        if (r == NULL) {
                return false;
        }
@@ -1110,7 +1110,7 @@ static bool api_lsa_LookupNames(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1128,14 +1128,14 @@ static bool api_lsa_LookupNames(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.sids = r->in.sids;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.sids = r->in.sids;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupNames(p, r);
 
        if (p->rng_fault_state) {
@@ -1148,7 +1148,7 @@ static bool api_lsa_LookupNames(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupNames, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1182,7 +1182,7 @@ static bool api_lsa_LookupSids(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPSIDS];
 
-       r = talloc(NULL, struct lsa_LookupSids);
+       r = talloc(talloc_tos(), struct lsa_LookupSids);
        if (r == NULL) {
                return false;
        }
@@ -1192,7 +1192,7 @@ static bool api_lsa_LookupSids(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1210,14 +1210,14 @@ static bool api_lsa_LookupSids(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.names = r->in.names;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.names = r->in.names;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupSids(p, r);
 
        if (p->rng_fault_state) {
@@ -1230,7 +1230,7 @@ static bool api_lsa_LookupSids(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupSids, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1264,7 +1264,7 @@ static bool api_lsa_CreateSecret(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREATESECRET];
 
-       r = talloc(NULL, struct lsa_CreateSecret);
+       r = talloc(talloc_tos(), struct lsa_CreateSecret);
        if (r == NULL) {
                return false;
        }
@@ -1274,7 +1274,7 @@ static bool api_lsa_CreateSecret(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1310,7 +1310,7 @@ static bool api_lsa_CreateSecret(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CreateSecret, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1344,7 +1344,7 @@ static bool api_lsa_OpenAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_OPENACCOUNT];
 
-       r = talloc(NULL, struct lsa_OpenAccount);
+       r = talloc(talloc_tos(), struct lsa_OpenAccount);
        if (r == NULL) {
                return false;
        }
@@ -1354,7 +1354,7 @@ static bool api_lsa_OpenAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1390,7 +1390,7 @@ static bool api_lsa_OpenAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_OpenAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1424,7 +1424,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMPRIVSACCOUNT];
 
-       r = talloc(NULL, struct lsa_EnumPrivsAccount);
+       r = talloc(talloc_tos(), struct lsa_EnumPrivsAccount);
        if (r == NULL) {
                return false;
        }
@@ -1434,7 +1434,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1452,7 +1452,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.privs = talloc_zero(r, struct lsa_PrivilegeSet);
+       r->out.privs = talloc_zero(r, struct lsa_PrivilegeSet *);
        if (r->out.privs == NULL) {
                talloc_free(r);
                return false;
@@ -1470,7 +1470,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumPrivsAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1504,7 +1504,7 @@ static bool api_lsa_AddPrivilegesToAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ADDPRIVILEGESTOACCOUNT];
 
-       r = talloc(NULL, struct lsa_AddPrivilegesToAccount);
+       r = talloc(talloc_tos(), struct lsa_AddPrivilegesToAccount);
        if (r == NULL) {
                return false;
        }
@@ -1514,7 +1514,7 @@ static bool api_lsa_AddPrivilegesToAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1543,7 +1543,7 @@ static bool api_lsa_AddPrivilegesToAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_AddPrivilegesToAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1577,7 +1577,7 @@ static bool api_lsa_RemovePrivilegesFromAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_REMOVEPRIVILEGESFROMACCOUNT];
 
-       r = talloc(NULL, struct lsa_RemovePrivilegesFromAccount);
+       r = talloc(talloc_tos(), struct lsa_RemovePrivilegesFromAccount);
        if (r == NULL) {
                return false;
        }
@@ -1587,7 +1587,7 @@ static bool api_lsa_RemovePrivilegesFromAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1616,7 +1616,7 @@ static bool api_lsa_RemovePrivilegesFromAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_RemovePrivilegesFromAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1650,7 +1650,7 @@ static bool api_lsa_GetQuotasForAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_GETQUOTASFORACCOUNT];
 
-       r = talloc(NULL, struct lsa_GetQuotasForAccount);
+       r = talloc(talloc_tos(), struct lsa_GetQuotasForAccount);
        if (r == NULL) {
                return false;
        }
@@ -1660,7 +1660,7 @@ static bool api_lsa_GetQuotasForAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1689,7 +1689,7 @@ static bool api_lsa_GetQuotasForAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_GetQuotasForAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1723,7 +1723,7 @@ static bool api_lsa_SetQuotasForAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETQUOTASFORACCOUNT];
 
-       r = talloc(NULL, struct lsa_SetQuotasForAccount);
+       r = talloc(talloc_tos(), struct lsa_SetQuotasForAccount);
        if (r == NULL) {
                return false;
        }
@@ -1733,7 +1733,7 @@ static bool api_lsa_SetQuotasForAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1762,7 +1762,7 @@ static bool api_lsa_SetQuotasForAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetQuotasForAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1796,7 +1796,7 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_GETSYSTEMACCESSACCOUNT];
 
-       r = talloc(NULL, struct lsa_GetSystemAccessAccount);
+       r = talloc(talloc_tos(), struct lsa_GetSystemAccessAccount);
        if (r == NULL) {
                return false;
        }
@@ -1806,7 +1806,7 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1823,6 +1823,13 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(lsa_GetSystemAccessAccount, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.access_mask = talloc_zero(r, uint32_t);
+       if (r->out.access_mask == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
        r->out.result = _lsa_GetSystemAccessAccount(p, r);
 
        if (p->rng_fault_state) {
@@ -1835,7 +1842,7 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_GetSystemAccessAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1869,7 +1876,7 @@ static bool api_lsa_SetSystemAccessAccount(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETSYSTEMACCESSACCOUNT];
 
-       r = talloc(NULL, struct lsa_SetSystemAccessAccount);
+       r = talloc(talloc_tos(), struct lsa_SetSystemAccessAccount);
        if (r == NULL) {
                return false;
        }
@@ -1879,7 +1886,7 @@ static bool api_lsa_SetSystemAccessAccount(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1908,7 +1915,7 @@ static bool api_lsa_SetSystemAccessAccount(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetSystemAccessAccount, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -1942,7 +1949,7 @@ static bool api_lsa_OpenTrustedDomain(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_OPENTRUSTEDDOMAIN];
 
-       r = talloc(NULL, struct lsa_OpenTrustedDomain);
+       r = talloc(talloc_tos(), struct lsa_OpenTrustedDomain);
        if (r == NULL) {
                return false;
        }
@@ -1952,7 +1959,7 @@ static bool api_lsa_OpenTrustedDomain(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -1988,7 +1995,7 @@ static bool api_lsa_OpenTrustedDomain(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_OpenTrustedDomain, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2022,7 +2029,7 @@ static bool api_lsa_QueryTrustedDomainInfo(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYTRUSTEDDOMAININFO];
 
-       r = talloc(NULL, struct lsa_QueryTrustedDomainInfo);
+       r = talloc(talloc_tos(), struct lsa_QueryTrustedDomainInfo);
        if (r == NULL) {
                return false;
        }
@@ -2032,7 +2039,7 @@ static bool api_lsa_QueryTrustedDomainInfo(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2050,7 +2057,7 @@ static bool api_lsa_QueryTrustedDomainInfo(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.info = talloc_zero(r, union lsa_TrustedDomainInfo);
+       r->out.info = talloc_zero(r, union lsa_TrustedDomainInfo *);
        if (r->out.info == NULL) {
                talloc_free(r);
                return false;
@@ -2068,7 +2075,7 @@ static bool api_lsa_QueryTrustedDomainInfo(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QueryTrustedDomainInfo, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2102,7 +2109,7 @@ static bool api_lsa_SetInformationTrustedDomain(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETINFORMATIONTRUSTEDDOMAIN];
 
-       r = talloc(NULL, struct lsa_SetInformationTrustedDomain);
+       r = talloc(talloc_tos(), struct lsa_SetInformationTrustedDomain);
        if (r == NULL) {
                return false;
        }
@@ -2112,7 +2119,7 @@ static bool api_lsa_SetInformationTrustedDomain(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2141,7 +2148,7 @@ static bool api_lsa_SetInformationTrustedDomain(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetInformationTrustedDomain, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2175,7 +2182,7 @@ static bool api_lsa_OpenSecret(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_OPENSECRET];
 
-       r = talloc(NULL, struct lsa_OpenSecret);
+       r = talloc(talloc_tos(), struct lsa_OpenSecret);
        if (r == NULL) {
                return false;
        }
@@ -2185,7 +2192,7 @@ static bool api_lsa_OpenSecret(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2221,7 +2228,7 @@ static bool api_lsa_OpenSecret(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_OpenSecret, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2255,7 +2262,7 @@ static bool api_lsa_SetSecret(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETSECRET];
 
-       r = talloc(NULL, struct lsa_SetSecret);
+       r = talloc(talloc_tos(), struct lsa_SetSecret);
        if (r == NULL) {
                return false;
        }
@@ -2265,7 +2272,7 @@ static bool api_lsa_SetSecret(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2294,7 +2301,7 @@ static bool api_lsa_SetSecret(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetSecret, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2328,7 +2335,7 @@ static bool api_lsa_QuerySecret(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYSECRET];
 
-       r = talloc(NULL, struct lsa_QuerySecret);
+       r = talloc(talloc_tos(), struct lsa_QuerySecret);
        if (r == NULL) {
                return false;
        }
@@ -2338,7 +2345,7 @@ static bool api_lsa_QuerySecret(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2372,7 +2379,7 @@ static bool api_lsa_QuerySecret(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QuerySecret, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2406,7 +2413,7 @@ static bool api_lsa_LookupPrivValue(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPPRIVVALUE];
 
-       r = talloc(NULL, struct lsa_LookupPrivValue);
+       r = talloc(talloc_tos(), struct lsa_LookupPrivValue);
        if (r == NULL) {
                return false;
        }
@@ -2416,7 +2423,7 @@ static bool api_lsa_LookupPrivValue(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2452,7 +2459,7 @@ static bool api_lsa_LookupPrivValue(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupPrivValue, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2486,7 +2493,7 @@ static bool api_lsa_LookupPrivName(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPPRIVNAME];
 
-       r = talloc(NULL, struct lsa_LookupPrivName);
+       r = talloc(talloc_tos(), struct lsa_LookupPrivName);
        if (r == NULL) {
                return false;
        }
@@ -2496,7 +2503,7 @@ static bool api_lsa_LookupPrivName(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2514,7 +2521,7 @@ static bool api_lsa_LookupPrivName(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.name = talloc_zero(r, struct lsa_StringLarge);
+       r->out.name = talloc_zero(r, struct lsa_StringLarge *);
        if (r->out.name == NULL) {
                talloc_free(r);
                return false;
@@ -2532,7 +2539,7 @@ static bool api_lsa_LookupPrivName(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupPrivName, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2566,7 +2573,7 @@ static bool api_lsa_LookupPrivDisplayName(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPPRIVDISPLAYNAME];
 
-       r = talloc(NULL, struct lsa_LookupPrivDisplayName);
+       r = talloc(talloc_tos(), struct lsa_LookupPrivDisplayName);
        if (r == NULL) {
                return false;
        }
@@ -2576,7 +2583,7 @@ static bool api_lsa_LookupPrivDisplayName(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2594,13 +2601,18 @@ static bool api_lsa_LookupPrivDisplayName(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.disp_name = talloc_zero(r, struct lsa_StringLarge);
+       r->out.disp_name = talloc_zero(r, struct lsa_StringLarge *);
        if (r->out.disp_name == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.language_id = r->in.language_id;
+       r->out.returned_language_id = talloc_zero(r, uint16_t);
+       if (r->out.returned_language_id == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
        r->out.result = _lsa_LookupPrivDisplayName(p, r);
 
        if (p->rng_fault_state) {
@@ -2613,7 +2625,7 @@ static bool api_lsa_LookupPrivDisplayName(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupPrivDisplayName, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2647,7 +2659,7 @@ static bool api_lsa_DeleteObject(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_DELETEOBJECT];
 
-       r = talloc(NULL, struct lsa_DeleteObject);
+       r = talloc(talloc_tos(), struct lsa_DeleteObject);
        if (r == NULL) {
                return false;
        }
@@ -2657,7 +2669,7 @@ static bool api_lsa_DeleteObject(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2674,6 +2686,8 @@ static bool api_lsa_DeleteObject(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(lsa_DeleteObject, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.handle = r->in.handle;
        r->out.result = _lsa_DeleteObject(p, r);
 
        if (p->rng_fault_state) {
@@ -2686,7 +2700,7 @@ static bool api_lsa_DeleteObject(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_DeleteObject, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2720,7 +2734,7 @@ static bool api_lsa_EnumAccountsWithUserRight(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMACCOUNTSWITHUSERRIGHT];
 
-       r = talloc(NULL, struct lsa_EnumAccountsWithUserRight);
+       r = talloc(talloc_tos(), struct lsa_EnumAccountsWithUserRight);
        if (r == NULL) {
                return false;
        }
@@ -2730,7 +2744,7 @@ static bool api_lsa_EnumAccountsWithUserRight(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2766,7 +2780,7 @@ static bool api_lsa_EnumAccountsWithUserRight(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumAccountsWithUserRight, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2800,7 +2814,7 @@ static bool api_lsa_EnumAccountRights(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMACCOUNTRIGHTS];
 
-       r = talloc(NULL, struct lsa_EnumAccountRights);
+       r = talloc(talloc_tos(), struct lsa_EnumAccountRights);
        if (r == NULL) {
                return false;
        }
@@ -2810,7 +2824,7 @@ static bool api_lsa_EnumAccountRights(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2846,7 +2860,7 @@ static bool api_lsa_EnumAccountRights(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumAccountRights, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2880,7 +2894,7 @@ static bool api_lsa_AddAccountRights(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ADDACCOUNTRIGHTS];
 
-       r = talloc(NULL, struct lsa_AddAccountRights);
+       r = talloc(talloc_tos(), struct lsa_AddAccountRights);
        if (r == NULL) {
                return false;
        }
@@ -2890,7 +2904,7 @@ static bool api_lsa_AddAccountRights(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2919,7 +2933,7 @@ static bool api_lsa_AddAccountRights(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_AddAccountRights, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -2953,7 +2967,7 @@ static bool api_lsa_RemoveAccountRights(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_REMOVEACCOUNTRIGHTS];
 
-       r = talloc(NULL, struct lsa_RemoveAccountRights);
+       r = talloc(talloc_tos(), struct lsa_RemoveAccountRights);
        if (r == NULL) {
                return false;
        }
@@ -2963,7 +2977,7 @@ static bool api_lsa_RemoveAccountRights(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -2992,7 +3006,7 @@ static bool api_lsa_RemoveAccountRights(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_RemoveAccountRights, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3026,7 +3040,7 @@ static bool api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYTRUSTEDDOMAININFOBYSID];
 
-       r = talloc(NULL, struct lsa_QueryTrustedDomainInfoBySid);
+       r = talloc(talloc_tos(), struct lsa_QueryTrustedDomainInfoBySid);
        if (r == NULL) {
                return false;
        }
@@ -3036,7 +3050,7 @@ static bool api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3054,7 +3068,7 @@ static bool api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.info = talloc_zero(r, union lsa_TrustedDomainInfo);
+       r->out.info = talloc_zero(r, union lsa_TrustedDomainInfo *);
        if (r->out.info == NULL) {
                talloc_free(r);
                return false;
@@ -3072,7 +3086,7 @@ static bool api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QueryTrustedDomainInfoBySid, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3106,7 +3120,7 @@ static bool api_lsa_SetTrustedDomainInfo(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETTRUSTEDDOMAININFO];
 
-       r = talloc(NULL, struct lsa_SetTrustedDomainInfo);
+       r = talloc(talloc_tos(), struct lsa_SetTrustedDomainInfo);
        if (r == NULL) {
                return false;
        }
@@ -3116,7 +3130,7 @@ static bool api_lsa_SetTrustedDomainInfo(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3145,7 +3159,7 @@ static bool api_lsa_SetTrustedDomainInfo(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetTrustedDomainInfo, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3179,7 +3193,7 @@ static bool api_lsa_DeleteTrustedDomain(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_DELETETRUSTEDDOMAIN];
 
-       r = talloc(NULL, struct lsa_DeleteTrustedDomain);
+       r = talloc(talloc_tos(), struct lsa_DeleteTrustedDomain);
        if (r == NULL) {
                return false;
        }
@@ -3189,7 +3203,7 @@ static bool api_lsa_DeleteTrustedDomain(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3218,7 +3232,7 @@ static bool api_lsa_DeleteTrustedDomain(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_DeleteTrustedDomain, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3252,7 +3266,7 @@ static bool api_lsa_StorePrivateData(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_STOREPRIVATEDATA];
 
-       r = talloc(NULL, struct lsa_StorePrivateData);
+       r = talloc(talloc_tos(), struct lsa_StorePrivateData);
        if (r == NULL) {
                return false;
        }
@@ -3262,7 +3276,7 @@ static bool api_lsa_StorePrivateData(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3291,7 +3305,7 @@ static bool api_lsa_StorePrivateData(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_StorePrivateData, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3325,7 +3339,7 @@ static bool api_lsa_RetrievePrivateData(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_RETRIEVEPRIVATEDATA];
 
-       r = talloc(NULL, struct lsa_RetrievePrivateData);
+       r = talloc(talloc_tos(), struct lsa_RetrievePrivateData);
        if (r == NULL) {
                return false;
        }
@@ -3335,7 +3349,7 @@ static bool api_lsa_RetrievePrivateData(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3364,7 +3378,7 @@ static bool api_lsa_RetrievePrivateData(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_RetrievePrivateData, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3398,7 +3412,7 @@ static bool api_lsa_OpenPolicy2(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_OPENPOLICY2];
 
-       r = talloc(NULL, struct lsa_OpenPolicy2);
+       r = talloc(talloc_tos(), struct lsa_OpenPolicy2);
        if (r == NULL) {
                return false;
        }
@@ -3408,7 +3422,7 @@ static bool api_lsa_OpenPolicy2(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3444,7 +3458,7 @@ static bool api_lsa_OpenPolicy2(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_OpenPolicy2, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3478,7 +3492,7 @@ static bool api_lsa_GetUserName(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_GETUSERNAME];
 
-       r = talloc(NULL, struct lsa_GetUserName);
+       r = talloc(talloc_tos(), struct lsa_GetUserName);
        if (r == NULL) {
                return false;
        }
@@ -3488,7 +3502,7 @@ static bool api_lsa_GetUserName(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3520,7 +3534,7 @@ static bool api_lsa_GetUserName(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_GetUserName, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3554,7 +3568,7 @@ static bool api_lsa_QueryInfoPolicy2(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYINFOPOLICY2];
 
-       r = talloc(NULL, struct lsa_QueryInfoPolicy2);
+       r = talloc(talloc_tos(), struct lsa_QueryInfoPolicy2);
        if (r == NULL) {
                return false;
        }
@@ -3564,7 +3578,7 @@ static bool api_lsa_QueryInfoPolicy2(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3582,7 +3596,7 @@ static bool api_lsa_QueryInfoPolicy2(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.info = talloc_zero(r, union lsa_PolicyInformation);
+       r->out.info = talloc_zero(r, union lsa_PolicyInformation *);
        if (r->out.info == NULL) {
                talloc_free(r);
                return false;
@@ -3600,7 +3614,7 @@ static bool api_lsa_QueryInfoPolicy2(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QueryInfoPolicy2, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3634,7 +3648,7 @@ static bool api_lsa_SetInfoPolicy2(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETINFOPOLICY2];
 
-       r = talloc(NULL, struct lsa_SetInfoPolicy2);
+       r = talloc(talloc_tos(), struct lsa_SetInfoPolicy2);
        if (r == NULL) {
                return false;
        }
@@ -3644,7 +3658,7 @@ static bool api_lsa_SetInfoPolicy2(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3673,7 +3687,7 @@ static bool api_lsa_SetInfoPolicy2(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetInfoPolicy2, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3707,7 +3721,7 @@ static bool api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYTRUSTEDDOMAININFOBYNAME];
 
-       r = talloc(NULL, struct lsa_QueryTrustedDomainInfoByName);
+       r = talloc(talloc_tos(), struct lsa_QueryTrustedDomainInfoByName);
        if (r == NULL) {
                return false;
        }
@@ -3717,7 +3731,7 @@ static bool api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3735,7 +3749,7 @@ static bool api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.info = talloc_zero(r, union lsa_TrustedDomainInfo);
+       r->out.info = talloc_zero(r, union lsa_TrustedDomainInfo *);
        if (r->out.info == NULL) {
                talloc_free(r);
                return false;
@@ -3753,7 +3767,7 @@ static bool api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QueryTrustedDomainInfoByName, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3787,7 +3801,7 @@ static bool api_lsa_SetTrustedDomainInfoByName(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETTRUSTEDDOMAININFOBYNAME];
 
-       r = talloc(NULL, struct lsa_SetTrustedDomainInfoByName);
+       r = talloc(talloc_tos(), struct lsa_SetTrustedDomainInfoByName);
        if (r == NULL) {
                return false;
        }
@@ -3797,7 +3811,7 @@ static bool api_lsa_SetTrustedDomainInfoByName(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3826,7 +3840,7 @@ static bool api_lsa_SetTrustedDomainInfoByName(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetTrustedDomainInfoByName, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3860,7 +3874,7 @@ static bool api_lsa_EnumTrustedDomainsEx(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_ENUMTRUSTEDDOMAINSEX];
 
-       r = talloc(NULL, struct lsa_EnumTrustedDomainsEx);
+       r = talloc(talloc_tos(), struct lsa_EnumTrustedDomainsEx);
        if (r == NULL) {
                return false;
        }
@@ -3870,7 +3884,7 @@ static bool api_lsa_EnumTrustedDomainsEx(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3907,7 +3921,7 @@ static bool api_lsa_EnumTrustedDomainsEx(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_EnumTrustedDomainsEx, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -3941,7 +3955,7 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREATETRUSTEDDOMAINEX];
 
-       r = talloc(NULL, struct lsa_CreateTrustedDomainEx);
+       r = talloc(talloc_tos(), struct lsa_CreateTrustedDomainEx);
        if (r == NULL) {
                return false;
        }
@@ -3951,7 +3965,7 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -3968,6 +3982,13 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(lsa_CreateTrustedDomainEx, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.trustdom_handle = talloc_zero(r, struct policy_handle);
+       if (r->out.trustdom_handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
        r->out.result = _lsa_CreateTrustedDomainEx(p, r);
 
        if (p->rng_fault_state) {
@@ -3980,7 +4001,7 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CreateTrustedDomainEx, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4014,7 +4035,7 @@ static bool api_lsa_CloseTrustedDomainEx(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CLOSETRUSTEDDOMAINEX];
 
-       r = talloc(NULL, struct lsa_CloseTrustedDomainEx);
+       r = talloc(talloc_tos(), struct lsa_CloseTrustedDomainEx);
        if (r == NULL) {
                return false;
        }
@@ -4024,7 +4045,7 @@ static bool api_lsa_CloseTrustedDomainEx(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4055,7 +4076,7 @@ static bool api_lsa_CloseTrustedDomainEx(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CloseTrustedDomainEx, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4089,7 +4110,7 @@ static bool api_lsa_QueryDomainInformationPolicy(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_QUERYDOMAININFORMATIONPOLICY];
 
-       r = talloc(NULL, struct lsa_QueryDomainInformationPolicy);
+       r = talloc(talloc_tos(), struct lsa_QueryDomainInformationPolicy);
        if (r == NULL) {
                return false;
        }
@@ -4099,7 +4120,7 @@ static bool api_lsa_QueryDomainInformationPolicy(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4117,7 +4138,7 @@ static bool api_lsa_QueryDomainInformationPolicy(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.info = talloc_zero(r, union lsa_DomainInformationPolicy);
+       r->out.info = talloc_zero(r, union lsa_DomainInformationPolicy *);
        if (r->out.info == NULL) {
                talloc_free(r);
                return false;
@@ -4135,7 +4156,7 @@ static bool api_lsa_QueryDomainInformationPolicy(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_QueryDomainInformationPolicy, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4169,7 +4190,7 @@ static bool api_lsa_SetDomainInformationPolicy(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_SETDOMAININFORMATIONPOLICY];
 
-       r = talloc(NULL, struct lsa_SetDomainInformationPolicy);
+       r = talloc(talloc_tos(), struct lsa_SetDomainInformationPolicy);
        if (r == NULL) {
                return false;
        }
@@ -4179,7 +4200,7 @@ static bool api_lsa_SetDomainInformationPolicy(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4208,7 +4229,7 @@ static bool api_lsa_SetDomainInformationPolicy(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_SetDomainInformationPolicy, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4242,7 +4263,7 @@ static bool api_lsa_OpenTrustedDomainByName(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_OPENTRUSTEDDOMAINBYNAME];
 
-       r = talloc(NULL, struct lsa_OpenTrustedDomainByName);
+       r = talloc(talloc_tos(), struct lsa_OpenTrustedDomainByName);
        if (r == NULL) {
                return false;
        }
@@ -4252,7 +4273,7 @@ static bool api_lsa_OpenTrustedDomainByName(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4288,7 +4309,7 @@ static bool api_lsa_OpenTrustedDomainByName(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_OpenTrustedDomainByName, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4322,7 +4343,7 @@ static bool api_lsa_TestCall(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_TESTCALL];
 
-       r = talloc(NULL, struct lsa_TestCall);
+       r = talloc(talloc_tos(), struct lsa_TestCall);
        if (r == NULL) {
                return false;
        }
@@ -4332,7 +4353,7 @@ static bool api_lsa_TestCall(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4361,7 +4382,7 @@ static bool api_lsa_TestCall(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_TestCall, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4395,7 +4416,7 @@ static bool api_lsa_LookupSids2(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPSIDS2];
 
-       r = talloc(NULL, struct lsa_LookupSids2);
+       r = talloc(talloc_tos(), struct lsa_LookupSids2);
        if (r == NULL) {
                return false;
        }
@@ -4405,7 +4426,7 @@ static bool api_lsa_LookupSids2(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4423,14 +4444,14 @@ static bool api_lsa_LookupSids2(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.names = r->in.names;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.names = r->in.names;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupSids2(p, r);
 
        if (p->rng_fault_state) {
@@ -4443,7 +4464,7 @@ static bool api_lsa_LookupSids2(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupSids2, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4477,7 +4498,7 @@ static bool api_lsa_LookupNames2(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPNAMES2];
 
-       r = talloc(NULL, struct lsa_LookupNames2);
+       r = talloc(talloc_tos(), struct lsa_LookupNames2);
        if (r == NULL) {
                return false;
        }
@@ -4487,7 +4508,7 @@ static bool api_lsa_LookupNames2(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4505,14 +4526,14 @@ static bool api_lsa_LookupNames2(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.sids = r->in.sids;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.sids = r->in.sids;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupNames2(p, r);
 
        if (p->rng_fault_state) {
@@ -4525,7 +4546,7 @@ static bool api_lsa_LookupNames2(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupNames2, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4559,7 +4580,7 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREATETRUSTEDDOMAINEX2];
 
-       r = talloc(NULL, struct lsa_CreateTrustedDomainEx2);
+       r = talloc(talloc_tos(), struct lsa_CreateTrustedDomainEx2);
        if (r == NULL) {
                return false;
        }
@@ -4569,7 +4590,7 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4586,6 +4607,13 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p)
                NDR_PRINT_IN_DEBUG(lsa_CreateTrustedDomainEx2, r);
        }
 
+       ZERO_STRUCT(r->out);
+       r->out.trustdom_handle = talloc_zero(r, struct policy_handle);
+       if (r->out.trustdom_handle == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
        r->out.result = _lsa_CreateTrustedDomainEx2(p, r);
 
        if (p->rng_fault_state) {
@@ -4598,7 +4626,7 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CreateTrustedDomainEx2, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4632,7 +4660,7 @@ static bool api_lsa_CREDRWRITE(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRWRITE];
 
-       r = talloc(NULL, struct lsa_CREDRWRITE);
+       r = talloc(talloc_tos(), struct lsa_CREDRWRITE);
        if (r == NULL) {
                return false;
        }
@@ -4642,7 +4670,7 @@ static bool api_lsa_CREDRWRITE(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4671,7 +4699,7 @@ static bool api_lsa_CREDRWRITE(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRWRITE, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4705,7 +4733,7 @@ static bool api_lsa_CREDRREAD(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRREAD];
 
-       r = talloc(NULL, struct lsa_CREDRREAD);
+       r = talloc(talloc_tos(), struct lsa_CREDRREAD);
        if (r == NULL) {
                return false;
        }
@@ -4715,7 +4743,7 @@ static bool api_lsa_CREDRREAD(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4744,7 +4772,7 @@ static bool api_lsa_CREDRREAD(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRREAD, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4778,7 +4806,7 @@ static bool api_lsa_CREDRENUMERATE(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRENUMERATE];
 
-       r = talloc(NULL, struct lsa_CREDRENUMERATE);
+       r = talloc(talloc_tos(), struct lsa_CREDRENUMERATE);
        if (r == NULL) {
                return false;
        }
@@ -4788,7 +4816,7 @@ static bool api_lsa_CREDRENUMERATE(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4817,7 +4845,7 @@ static bool api_lsa_CREDRENUMERATE(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRENUMERATE, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4851,7 +4879,7 @@ static bool api_lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRWRITEDOMAINCREDENTIALS];
 
-       r = talloc(NULL, struct lsa_CREDRWRITEDOMAINCREDENTIALS);
+       r = talloc(talloc_tos(), struct lsa_CREDRWRITEDOMAINCREDENTIALS);
        if (r == NULL) {
                return false;
        }
@@ -4861,7 +4889,7 @@ static bool api_lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4890,7 +4918,7 @@ static bool api_lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRWRITEDOMAINCREDENTIALS, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4924,7 +4952,7 @@ static bool api_lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRREADDOMAINCREDENTIALS];
 
-       r = talloc(NULL, struct lsa_CREDRREADDOMAINCREDENTIALS);
+       r = talloc(talloc_tos(), struct lsa_CREDRREADDOMAINCREDENTIALS);
        if (r == NULL) {
                return false;
        }
@@ -4934,7 +4962,7 @@ static bool api_lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -4963,7 +4991,7 @@ static bool api_lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRREADDOMAINCREDENTIALS, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -4997,7 +5025,7 @@ static bool api_lsa_CREDRDELETE(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRDELETE];
 
-       r = talloc(NULL, struct lsa_CREDRDELETE);
+       r = talloc(talloc_tos(), struct lsa_CREDRDELETE);
        if (r == NULL) {
                return false;
        }
@@ -5007,7 +5035,7 @@ static bool api_lsa_CREDRDELETE(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5036,7 +5064,7 @@ static bool api_lsa_CREDRDELETE(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRDELETE, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5070,7 +5098,7 @@ static bool api_lsa_CREDRGETTARGETINFO(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRGETTARGETINFO];
 
-       r = talloc(NULL, struct lsa_CREDRGETTARGETINFO);
+       r = talloc(talloc_tos(), struct lsa_CREDRGETTARGETINFO);
        if (r == NULL) {
                return false;
        }
@@ -5080,7 +5108,7 @@ static bool api_lsa_CREDRGETTARGETINFO(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5109,7 +5137,7 @@ static bool api_lsa_CREDRGETTARGETINFO(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRGETTARGETINFO, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5143,7 +5171,7 @@ static bool api_lsa_CREDRPROFILELOADED(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRPROFILELOADED];
 
-       r = talloc(NULL, struct lsa_CREDRPROFILELOADED);
+       r = talloc(talloc_tos(), struct lsa_CREDRPROFILELOADED);
        if (r == NULL) {
                return false;
        }
@@ -5153,7 +5181,7 @@ static bool api_lsa_CREDRPROFILELOADED(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5182,7 +5210,7 @@ static bool api_lsa_CREDRPROFILELOADED(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRPROFILELOADED, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5216,7 +5244,7 @@ static bool api_lsa_LookupNames3(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPNAMES3];
 
-       r = talloc(NULL, struct lsa_LookupNames3);
+       r = talloc(talloc_tos(), struct lsa_LookupNames3);
        if (r == NULL) {
                return false;
        }
@@ -5226,7 +5254,7 @@ static bool api_lsa_LookupNames3(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5244,14 +5272,14 @@ static bool api_lsa_LookupNames3(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.sids = r->in.sids;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.sids = r->in.sids;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupNames3(p, r);
 
        if (p->rng_fault_state) {
@@ -5264,7 +5292,7 @@ static bool api_lsa_LookupNames3(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupNames3, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5298,7 +5326,7 @@ static bool api_lsa_CREDRGETSESSIONTYPES(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRGETSESSIONTYPES];
 
-       r = talloc(NULL, struct lsa_CREDRGETSESSIONTYPES);
+       r = talloc(talloc_tos(), struct lsa_CREDRGETSESSIONTYPES);
        if (r == NULL) {
                return false;
        }
@@ -5308,7 +5336,7 @@ static bool api_lsa_CREDRGETSESSIONTYPES(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5337,7 +5365,7 @@ static bool api_lsa_CREDRGETSESSIONTYPES(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRGETSESSIONTYPES, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5371,7 +5399,7 @@ static bool api_lsa_LSARREGISTERAUDITEVENT(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARREGISTERAUDITEVENT];
 
-       r = talloc(NULL, struct lsa_LSARREGISTERAUDITEVENT);
+       r = talloc(talloc_tos(), struct lsa_LSARREGISTERAUDITEVENT);
        if (r == NULL) {
                return false;
        }
@@ -5381,7 +5409,7 @@ static bool api_lsa_LSARREGISTERAUDITEVENT(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5410,7 +5438,7 @@ static bool api_lsa_LSARREGISTERAUDITEVENT(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARREGISTERAUDITEVENT, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5444,7 +5472,7 @@ static bool api_lsa_LSARGENAUDITEVENT(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARGENAUDITEVENT];
 
-       r = talloc(NULL, struct lsa_LSARGENAUDITEVENT);
+       r = talloc(talloc_tos(), struct lsa_LSARGENAUDITEVENT);
        if (r == NULL) {
                return false;
        }
@@ -5454,7 +5482,7 @@ static bool api_lsa_LSARGENAUDITEVENT(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5483,7 +5511,7 @@ static bool api_lsa_LSARGENAUDITEVENT(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARGENAUDITEVENT, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5517,7 +5545,7 @@ static bool api_lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARUNREGISTERAUDITEVENT];
 
-       r = talloc(NULL, struct lsa_LSARUNREGISTERAUDITEVENT);
+       r = talloc(talloc_tos(), struct lsa_LSARUNREGISTERAUDITEVENT);
        if (r == NULL) {
                return false;
        }
@@ -5527,7 +5555,7 @@ static bool api_lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5556,7 +5584,7 @@ static bool api_lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARUNREGISTERAUDITEVENT, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5590,7 +5618,7 @@ static bool api_lsa_lsaRQueryForestTrustInformation(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARQUERYFORESTTRUSTINFORMATION];
 
-       r = talloc(NULL, struct lsa_lsaRQueryForestTrustInformation);
+       r = talloc(talloc_tos(), struct lsa_lsaRQueryForestTrustInformation);
        if (r == NULL) {
                return false;
        }
@@ -5600,7 +5628,7 @@ static bool api_lsa_lsaRQueryForestTrustInformation(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5636,7 +5664,7 @@ static bool api_lsa_lsaRQueryForestTrustInformation(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_lsaRQueryForestTrustInformation, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5670,7 +5698,7 @@ static bool api_lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARSETFORESTTRUSTINFORMATION];
 
-       r = talloc(NULL, struct lsa_LSARSETFORESTTRUSTINFORMATION);
+       r = talloc(talloc_tos(), struct lsa_LSARSETFORESTTRUSTINFORMATION);
        if (r == NULL) {
                return false;
        }
@@ -5680,7 +5708,7 @@ static bool api_lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5709,7 +5737,7 @@ static bool api_lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARSETFORESTTRUSTINFORMATION, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5743,7 +5771,7 @@ static bool api_lsa_CREDRRENAME(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_CREDRRENAME];
 
-       r = talloc(NULL, struct lsa_CREDRRENAME);
+       r = talloc(talloc_tos(), struct lsa_CREDRRENAME);
        if (r == NULL) {
                return false;
        }
@@ -5753,7 +5781,7 @@ static bool api_lsa_CREDRRENAME(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5782,7 +5810,7 @@ static bool api_lsa_CREDRRENAME(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_CREDRRENAME, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5816,7 +5844,7 @@ static bool api_lsa_LookupSids3(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPSIDS3];
 
-       r = talloc(NULL, struct lsa_LookupSids3);
+       r = talloc(talloc_tos(), struct lsa_LookupSids3);
        if (r == NULL) {
                return false;
        }
@@ -5826,7 +5854,7 @@ static bool api_lsa_LookupSids3(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5844,14 +5872,14 @@ static bool api_lsa_LookupSids3(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.names = r->in.names;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.names = r->in.names;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupSids3(p, r);
 
        if (p->rng_fault_state) {
@@ -5864,7 +5892,7 @@ static bool api_lsa_LookupSids3(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupSids3, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5898,7 +5926,7 @@ static bool api_lsa_LookupNames4(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LOOKUPNAMES4];
 
-       r = talloc(NULL, struct lsa_LookupNames4);
+       r = talloc(talloc_tos(), struct lsa_LookupNames4);
        if (r == NULL) {
                return false;
        }
@@ -5908,7 +5936,7 @@ static bool api_lsa_LookupNames4(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -5926,14 +5954,14 @@ static bool api_lsa_LookupNames4(pipes_struct *p)
        }
 
        ZERO_STRUCT(r->out);
-       r->out.domains = talloc_zero(r, struct lsa_RefDomainList);
+       r->out.sids = r->in.sids;
+       r->out.count = r->in.count;
+       r->out.domains = talloc_zero(r, struct lsa_RefDomainList *);
        if (r->out.domains == NULL) {
                talloc_free(r);
                return false;
        }
 
-       r->out.sids = r->in.sids;
-       r->out.count = r->in.count;
        r->out.result = _lsa_LookupNames4(p, r);
 
        if (p->rng_fault_state) {
@@ -5946,7 +5974,7 @@ static bool api_lsa_LookupNames4(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LookupNames4, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -5980,7 +6008,7 @@ static bool api_lsa_LSAROPENPOLICYSCE(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSAROPENPOLICYSCE];
 
-       r = talloc(NULL, struct lsa_LSAROPENPOLICYSCE);
+       r = talloc(talloc_tos(), struct lsa_LSAROPENPOLICYSCE);
        if (r == NULL) {
                return false;
        }
@@ -5990,7 +6018,7 @@ static bool api_lsa_LSAROPENPOLICYSCE(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -6019,7 +6047,7 @@ static bool api_lsa_LSAROPENPOLICYSCE(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSAROPENPOLICYSCE, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -6053,7 +6081,7 @@ static bool api_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARADTREGISTERSECURITYEVENTSOURCE];
 
-       r = talloc(NULL, struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE);
+       r = talloc(talloc_tos(), struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE);
        if (r == NULL) {
                return false;
        }
@@ -6063,7 +6091,7 @@ static bool api_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -6092,7 +6120,7 @@ static bool api_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARADTREGISTERSECURITYEVENTSOURCE, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -6126,7 +6154,7 @@ static bool api_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARADTUNREGISTERSECURITYEVENTSOURCE];
 
-       r = talloc(NULL, struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE);
+       r = talloc(talloc_tos(), struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE);
        if (r == NULL) {
                return false;
        }
@@ -6136,7 +6164,7 @@ static bool api_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -6165,7 +6193,7 @@ static bool api_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -6199,7 +6227,7 @@ static bool api_lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p)
 
        call = &ndr_table_lsarpc.calls[NDR_LSA_LSARADTREPORTSECURITYEVENT];
 
-       r = talloc(NULL, struct lsa_LSARADTREPORTSECURITYEVENT);
+       r = talloc(talloc_tos(), struct lsa_LSARADTREPORTSECURITYEVENT);
        if (r == NULL) {
                return false;
        }
@@ -6209,7 +6237,7 @@ static bool api_lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p)
                return false;
        }
 
-       pull = ndr_pull_init_blob(&blob, r);
+       pull = ndr_pull_init_blob(&blob, r, NULL);
        if (pull == NULL) {
                talloc_free(r);
                return false;
@@ -6238,7 +6266,7 @@ static bool api_lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p)
                NDR_PRINT_OUT_DEBUG(lsa_LSARADTREPORTSECURITYEVENT, r);
        }
 
-       push = ndr_push_init_ctx(r);
+       push = ndr_push_init_ctx(r, NULL);
        if (push == NULL) {
                talloc_free(r);
                return false;
@@ -6357,5 +6385,5 @@ void lsarpc_get_pipe_fns(struct api_struct **fns, int *n_fns)
 
 NTSTATUS rpc_lsarpc_init(void)
 {
-       return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsarpc", api_lsarpc_cmds, sizeof(api_lsarpc_cmds) / sizeof(struct api_struct));
+       return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsarpc", &ndr_table_lsarpc.syntax_id, api_lsarpc_cmds, sizeof(api_lsarpc_cmds) / sizeof(struct api_struct));
 }