Remove more redundant lsa parsing functions.
[bbaumbach/samba-autobuild/.git] / source / rpc_parse / parse_samr.c
index 18d1a66e71b907278d90a04c238f7008f383a3fe..614a80dd6fe29ef7a47ca98cdefc47bcc48862a1 100644 (file)
@@ -11,7 +11,7 @@
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -20,8 +20,7 @@
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "includes.h"
@@ -44,7 +43,7 @@ void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
+bool samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
                         prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -63,7 +62,7 @@ BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
+bool samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
                         prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -102,7 +101,7 @@ void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
-BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
+bool samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
                             prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -147,7 +146,7 @@ void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
+bool samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
                             prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -191,7 +190,7 @@ void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
+bool samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
                          prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -219,7 +218,7 @@ BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOR
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
+bool samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
                          prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -256,7 +255,7 @@ void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
+bool samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
                           prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -284,7 +283,7 @@ BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
+bool samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
                           prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -321,7 +320,7 @@ void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
+bool samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
                                 prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -363,7 +362,7 @@ void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS statu
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
+bool samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
                                 prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -393,7 +392,7 @@ BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
+bool samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
                             prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -436,7 +435,7 @@ void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
+bool samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
                             prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -474,7 +473,7 @@ void init_samr_q_query_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
+bool samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
                                 prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -522,7 +521,7 @@ void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
+static bool sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
                             prs_struct *ps, int depth)
 {
        if (u_1 == NULL)
@@ -557,7 +556,7 @@ void init_unk_info2(SAM_UNK_INFO_2 * u_2,
 
        u_2->seq_num = seq_num;
 
-
+       
        u_2->unknown_4 = 0x00000001;
        u_2->server_role = server_role;
        u_2->unknown_6 = 0x00000001;
@@ -577,7 +576,7 @@ void init_unk_info2(SAM_UNK_INFO_2 * u_2,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
+static bool sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
                             prs_struct *ps, int depth)
 {
        if (u_2 == NULL)
@@ -638,7 +637,7 @@ void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
+static bool sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
                             prs_struct *ps, int depth)
 {
        if (u_3 == NULL)
@@ -667,7 +666,7 @@ void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
+static bool sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
                             prs_struct *ps, int depth)
 {
        if (u_4 == NULL)
@@ -699,7 +698,7 @@ void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
+static bool sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
                             prs_struct *ps, int depth)
 {
        if (u_5 == NULL)
@@ -731,7 +730,7 @@ void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
+static bool sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
                             prs_struct *ps, int depth)
 {
        if (u_6 == NULL)
@@ -762,7 +761,7 @@ void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
+static bool sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
                             prs_struct *ps, int depth)
 {
        if (u_7 == NULL)
@@ -791,7 +790,7 @@ void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
+static bool sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
                             prs_struct *ps, int depth)
 {
        if (u_8 == NULL)
@@ -822,7 +821,7 @@ void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
+static bool sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
                             prs_struct *ps, int depth)
 {
        if (u_9 == NULL)
@@ -853,7 +852,7 @@ void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
+static bool sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
                              prs_struct *ps, int depth)
 {
        if (u_12 == NULL)
@@ -888,7 +887,7 @@ void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
+static bool sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
                             prs_struct *ps, int depth)
 {
        if (u_13 == NULL)
@@ -936,7 +935,7 @@ void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
+bool samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
                                 prs_struct *ps, int depth)
 {
         if (r_u == NULL)
@@ -1038,7 +1037,7 @@ void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
 reads or writes a SAMR_R_SET_SEC_OBJ structure.
 ********************************************************************/
 
-BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
+bool samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
                             prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -1060,7 +1059,7 @@ BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
+bool samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
                             prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -1089,7 +1088,7 @@ BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
 reads or writes a SAM_STR1 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
+static bool sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
                            uint32 name_buf, uint32 desc_buf,
                            prs_struct *ps, int depth)
 {
@@ -1139,7 +1138,7 @@ static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
 reads or writes a SAM_ENTRY1 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
+static bool sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
                              prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1173,7 +1172,7 @@ static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
 reads or writes a SAM_STR2 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
+static bool sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
                            uint32 desc_buf, prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1214,7 +1213,7 @@ static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
 reads or writes a SAM_ENTRY2 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
+static bool sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
                              prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1246,7 +1245,7 @@ static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
 reads or writes a SAM_STR3 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
+static bool sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
                            uint32 desc_buf, prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1288,7 +1287,7 @@ static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
 reads or writes a SAM_ENTRY3 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
+static bool sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
                              prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1333,7 +1332,7 @@ static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
 reads or writes a SAM_ENTRY4 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
+static bool sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
                              prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1371,7 +1370,7 @@ static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
 reads or writes a SAM_ENTRY5 structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
+static bool sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
                              prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1407,7 +1406,7 @@ void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
 reads or writes a SAM_ENTRY structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
+static bool sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
                             prs_struct *ps, int depth)
 {
        if (sam == NULL)
@@ -1447,7 +1446,7 @@ void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
+bool samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
                              prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -1503,7 +1502,7 @@ void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
+bool samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
                              prs_struct *ps, int depth)
 {
        uint32 i;
@@ -1588,7 +1587,7 @@ void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
+bool samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
                              prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -1667,7 +1666,7 @@ NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
+static bool sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
                                  uint32 num_entries,
                                  prs_struct *ps, int depth)
 {
@@ -1754,7 +1753,7 @@ NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
+static bool sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
                                  uint32 num_entries,
                                  prs_struct *ps, int depth)
 {
@@ -1843,7 +1842,7 @@ NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
+static bool sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
                                  uint32 num_entries,
                                  prs_struct *ps, int depth)
 {
@@ -1933,7 +1932,7 @@ NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
+static bool sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
                                  uint32 num_entries,
                                  prs_struct *ps, int depth)
 {
@@ -2018,7 +2017,7 @@ NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
+static bool sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
                                  uint32 num_entries,
                                  prs_struct *ps, int depth)
 {
@@ -2093,7 +2092,7 @@ void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
+bool samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
                              prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2172,76 +2171,6 @@ BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
        return True;
 }
 
-/*******************************************************************
-inits a SAMR_Q_GET_DISPENUM_INDEX structure.
-********************************************************************/
-
-void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
-                                   uint16 switch_level, const char *name)
-{
-       DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
-
-       q_e->domain_pol = *pol;
-
-       q_e->switch_level = switch_level;
-
-       init_lsa_string(&q_e->name, name);
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
-                                 prs_struct *ps, int depth)
-{
-       if (q_e == NULL)
-               return False;
-
-       prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
-       depth++;
-
-       if(!prs_align(ps))
-               return False;
-
-       if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
-               return False;
-
-       if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
-               return False;
-
-       if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
-               return False;
-
-       return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
-                                 prs_struct *ps, int depth)
-{
-       if (r_u == NULL)
-               return False;
-
-       prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
-       depth++;
-
-       if(!prs_align(ps))
-               return False;
-
-       if(!prs_uint32("idx", ps, depth, &r_u->idx))
-               return False;
-       
-       if(!prs_ntstatus("status", ps, depth, &r_u->status))
-               return False;
-
-       return True;
-}
-
-
 /*******************************************************************
 inits a SAMR_Q_OPEN_GROUP structure.
 ********************************************************************/
@@ -2261,7 +2190,7 @@ void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
+bool samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
                          prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -2288,7 +2217,7 @@ BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
+bool samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
                          prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2332,7 +2261,7 @@ void init_samr_group_info1(GROUP_INFO1 * gr1,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
+bool samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
                         prs_struct *ps, int depth)
 {
        uint16 dummy = 1;
@@ -2388,7 +2317,7 @@ void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
+bool samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
 {
        if (gr2 == NULL)
                return False;
@@ -2423,7 +2352,7 @@ void init_samr_group_info3(GROUP_INFO3 *gr3)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
+bool samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
 {
        if (gr3 == NULL)
                return False;
@@ -2457,7 +2386,7 @@ void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
+bool samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
                         prs_struct *ps, int depth)
 {
        if (gr4 == NULL)
@@ -2500,7 +2429,7 @@ void init_samr_group_info5(GROUP_INFO5 * gr5,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
+bool samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
                         prs_struct *ps, int depth)
 {
        uint16 dummy = 1;
@@ -2544,7 +2473,7 @@ BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
+static bool samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
                                prs_struct *ps, int depth)
 {
        if (UNMARSHALLING(ps))
@@ -2610,7 +2539,7 @@ void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
+bool samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
                                prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -2643,7 +2572,7 @@ BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
+bool samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
                                prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2682,7 +2611,7 @@ void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
+bool samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
                                prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -2704,7 +2633,7 @@ BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
+bool samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
                                prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2742,7 +2671,7 @@ void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
+bool samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
                            prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -2779,7 +2708,7 @@ void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
+bool samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2815,7 +2744,7 @@ void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
+bool samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
                            prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -2854,7 +2783,7 @@ void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
+bool samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2889,7 +2818,7 @@ void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
+bool samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
                             prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -2925,7 +2854,7 @@ void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
+bool samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
                             prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -2961,7 +2890,7 @@ void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
+bool samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
                               prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -3000,7 +2929,7 @@ void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
+bool samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
                               prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -3043,7 +2972,7 @@ void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
+bool samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -3095,7 +3024,7 @@ void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
+bool samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
                              prs_struct *ps, int depth)
 {
        uint32 i;
@@ -3177,7 +3106,7 @@ void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
+bool samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
                                prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -3226,7 +3155,7 @@ void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
+bool samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
                  prs_struct *ps, int depth)
 {
        uint32 i;
@@ -3264,7 +3193,7 @@ BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
+bool samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
                                prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -3319,7 +3248,7 @@ void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
+bool samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
                            prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -3371,7 +3300,7 @@ void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
+bool samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
                            prs_struct *ps, int depth)
 {
        uint32 i;
@@ -3398,7 +3327,7 @@ BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
                if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
                        return False;
 
-               if (UNMARSHALLING(ps)) {
+               if (UNMARSHALLING(ps) && r_u->num_entries2) {
                        r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
                        r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
                }
@@ -3458,7 +3387,7 @@ void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
+bool samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
                               prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -3510,7 +3439,7 @@ void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
+bool samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
                               prs_struct *ps, int depth)
 {
        uint32 i;
@@ -3537,7 +3466,7 @@ BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
                if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
                        return False;
 
-               if (UNMARSHALLING(ps)) {
+               if (UNMARSHALLING(ps) && r_u->num_entries2) {
                        r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
                        r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
                }
@@ -3593,7 +3522,7 @@ void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
+bool samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
                                prs_struct *ps, int depth)
 {
        if (q_e == NULL)
@@ -3644,7 +3573,7 @@ void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
+bool samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
                                prs_struct *ps, int depth)
 {
        uint32 i;
@@ -3724,7 +3653,7 @@ void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
+bool samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
                         prs_struct *ps, int depth)
 {
        if (al1 == NULL)
@@ -3770,7 +3699,7 @@ void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
+bool samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
                         prs_struct *ps, int depth)
 {
        if (al3 == NULL)
@@ -3792,7 +3721,7 @@ BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
+bool samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
                         prs_struct *ps, int depth)
 {
        if (al2 == NULL)
@@ -3814,7 +3743,7 @@ BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
+bool samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
 {
        if ( !ctr )
                return False;
@@ -3865,7 +3794,7 @@ void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
+bool samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
                               prs_struct *ps, int depth)
 {
        if ( !in )
@@ -3903,7 +3832,7 @@ void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
+bool samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
                               prs_struct *ps, int depth)
 {
        if ( !out )
@@ -3943,7 +3872,7 @@ void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
+bool samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
                             prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -3967,7 +3896,7 @@ BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
+bool samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
                             prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4009,7 +3938,7 @@ void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
+bool samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
                                 prs_struct *ps, int depth)
 {
        fstring tmp;
@@ -4094,7 +4023,7 @@ void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
+bool samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
                  prs_struct *ps, int depth)
 {
        fstring tmp;
@@ -4133,7 +4062,7 @@ BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
+bool samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
                                 prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4181,7 +4110,7 @@ void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
+bool samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
                          prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4208,7 +4137,7 @@ BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
+bool samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
                          prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4245,7 +4174,11 @@ void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
        q_u->flags = flags;
        q_u->ptr = 0;
        q_u->num_rids2 = num_rids;
-       q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
+       if (num_rids) {
+               q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
+       } else {
+               q_u->rid = NULL;
+       }
        if (q_u->rid == NULL) {
                q_u->num_rids1 = 0;
                q_u->num_rids2 = 0;
@@ -4258,7 +4191,7 @@ void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
+bool samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
                           prs_struct *ps, int depth)
 {
        uint32 i;
@@ -4344,7 +4277,7 @@ void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
+bool samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
                           prs_struct *ps, int depth)
 {
        uint32 i;
@@ -4438,7 +4371,7 @@ void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
+bool samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
                            prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4460,7 +4393,7 @@ BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
+bool samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4501,7 +4434,7 @@ void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
+bool samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
                                prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4534,7 +4467,7 @@ BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
+bool samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
                                prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4575,7 +4508,7 @@ void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
+bool samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
                            prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4599,7 +4532,7 @@ BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
+bool samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4634,7 +4567,7 @@ void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
+bool samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
                            prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4658,7 +4591,7 @@ BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
+bool samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4692,7 +4625,7 @@ void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
+bool samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
                                prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4726,7 +4659,7 @@ void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
+bool samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
                                prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -4763,7 +4696,7 @@ void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
+bool samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -4809,7 +4742,7 @@ void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
+bool samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
                              prs_struct *ps, int depth)
 {
        uint32 i;
@@ -4834,9 +4767,14 @@ BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
                if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
                        return False;
 
-               ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
-               if (!ptr_sid) {
-                       return False;
+               /* We must always use talloc here even when marshalling. */
+               if (r_u->num_sids1) {
+                       ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
+                       if (!ptr_sid) {
+                               return False;
+                       }
+               } else {
+                       ptr_sid = NULL;
                }
                
                for (i = 0; i < r_u->num_sids1; i++) {
@@ -4846,7 +4784,14 @@ BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
                }
                
                if (UNMARSHALLING(ps)) {
-                       r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
+                       if (r_u->num_sids1) {
+                               r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
+                               if (!r_u->sid) {
+                                       return False;
+                               }
+                       } else {
+                               r_u->sid = NULL;
+                       }
                }
                
                for (i = 0; i < r_u->num_sids1; i++) {
@@ -4884,11 +4829,16 @@ NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
        q_u->ptr = 0;
        q_u->num_names2 = num_names;
 
-       if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
-               return NT_STATUS_NO_MEMORY;
+       if (num_names) {
+               if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
+                       return NT_STATUS_NO_MEMORY;
 
-       if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
-               return NT_STATUS_NO_MEMORY;
+               if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
+                       return NT_STATUS_NO_MEMORY;
+       } else {
+               q_u->hdr_name = NULL;
+               q_u->uni_name = NULL;
+       }
 
        for (i = 0; i < num_names; i++) {
                init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE);       /* unicode string for machine account */
@@ -4902,7 +4852,7 @@ NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
+bool samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
                            prs_struct *ps, int depth)
 {
        uint32 i;
@@ -4978,16 +4928,12 @@ NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
                if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
                        return NT_STATUS_NO_MEMORY;
 
-               if (!r_u->rids || !r_u->types)
-                       goto empty;
-
                for (i = 0; i < num_rids; i++) {
                        r_u->rids[i] = rid[i];
                        r_u->types[i] = type[i];
                }
        } else {
 
-  empty:
                r_u->num_types1 = 0;
                r_u->ptr_types = 0;
                r_u->num_types2 = 0;
@@ -5009,7 +4955,7 @@ NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
+bool samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
                            prs_struct *ps, int depth)
 {
        uint32 i;
@@ -5041,12 +4987,13 @@ BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
                        return False;
                }
 
-               if (UNMARSHALLING(ps))
+               if (UNMARSHALLING(ps) && r_u->num_rids2) {
                        r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
 
-               if (!r_u->rids) {
-                       DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
-                       return False;
+                       if (!r_u->rids) {
+                               DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
+                               return False;
+                       }
                }
 
                for (i = 0; i < r_u->num_rids2; i++) {
@@ -5070,12 +5017,13 @@ BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
                        return False;
                }
 
-               if (UNMARSHALLING(ps))
+               if (UNMARSHALLING(ps) && r_u->num_types2) {
                        r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
 
-               if (!r_u->types) {
-                       DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
-                       return False;
+                       if (!r_u->types) {
+                               DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
+                               return False;
+                       }
                }
 
                for (i = 0; i < r_u->num_types2; i++) {
@@ -5107,7 +5055,7 @@ void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
+bool samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
                               prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -5129,7 +5077,7 @@ BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
+bool samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
                               prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -5168,7 +5116,7 @@ void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
+bool samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
                         prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -5195,7 +5143,7 @@ BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
+bool samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
                         prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -5241,7 +5189,7 @@ void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
+bool samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
                           prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -5275,7 +5223,7 @@ BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
+bool samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
                           prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -5317,7 +5265,7 @@ void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
+bool samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -5342,7 +5290,7 @@ BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
 reads or writes a LOGON_HRS structure.
 ********************************************************************/
 
-static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
+static bool sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
                             prs_struct *ps, int depth)
 {
        if (hrs == NULL)
@@ -5393,7 +5341,7 @@ void init_sam_user_info18(SAM_USER_INFO_18 * usr,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
+static bool sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
                        prs_struct *ps, int depth)
 {
        if (u == NULL)
@@ -5435,7 +5383,7 @@ void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
+static bool sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
                        prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -5471,7 +5419,7 @@ void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
+static bool sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
                        prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -5504,7 +5452,7 @@ void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
+static bool sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
                        prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -5568,7 +5516,7 @@ void init_sam_user_info17(SAM_USER_INFO_17 * usr,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
+static bool sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
                        prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -5660,7 +5608,7 @@ void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
+static bool sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
                               prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -5691,7 +5639,7 @@ static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
+static bool sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
                               prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -5912,11 +5860,30 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
        }
 }
 
+
+/*************************************************************************
+ init_samr_user_info25P
+ fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
+*************************************************************************/
+
+void init_sam_user_info25P(SAM_USER_INFO_25 * usr,
+                          uint32 fields_present, uint32 acb_info,
+                          char newpass[532])
+{
+       usr->fields_present = fields_present;
+       ZERO_STRUCT(usr->padding1);
+       ZERO_STRUCT(usr->padding2);
+
+       usr->acb_info = acb_info;
+       memcpy(usr->pass, newpass, sizeof(usr->pass));
+}
+
+
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
+static bool sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
                               prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -6047,7 +6014,7 @@ static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
  way than normal... And there are definately other problems. JRA.
 ********************************************************************/
 
-static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
+static bool sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
 {
        if (usr == NULL)
                return False;
@@ -6106,9 +6073,26 @@ static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_str
        if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
                return False;
 
-       if(!prs_uint32s(False, "unknown_5      ", ps, depth, usr->unknown_5, 5))
+       if(!prs_uint16("logon_divs    ", ps, depth, &usr->logon_divs))  /* logon divisions per week */
+               return False;
+       if(!prs_align(ps))
+               return False;
+       if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
                return False;
 
+       if(!prs_uint16("bad_password_count     ", ps, depth, &usr->bad_password_count))
+               return False;
+       if(!prs_uint16("logon_count     ", ps, depth, &usr->logon_count))
+               return False;
+
+       if(!prs_uint8s(False, "padding1      ", ps, depth, usr->padding1, sizeof(usr->padding1)))
+               return False;
+       if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
+               return False;
+       if(!prs_uint8("padding2       ", ps, depth, &usr->padding2))
+               return False;
+
+
        if(!prs_uint8s(False, "password      ", ps, depth, usr->pass, sizeof(usr->pass)))
                return False;
 
@@ -6144,13 +6128,11 @@ static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_str
        if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
                return False;
 
-#if 0 /* JRA - unknown... */
        /* ok, this is only guess-work (as usual) */
        if (usr->ptr_logon_hrs) {
                if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
                        return False;
        } 
-#endif
 
        return True;
 }
@@ -6291,7 +6273,7 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *
        if (munged_dial) {
                munged_dial_blob = base64_decode_data_blob(munged_dial);
        } else {
-               munged_dial_blob = data_blob(NULL, 0);
+               munged_dial_blob = data_blob_null;
        }
 
        /* Create NTTIME structs */
@@ -6320,13 +6302,10 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *
        user_sid = pdb_get_user_sid(pw);
        
        if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
-               fstring user_sid_string;
-               fstring domain_sid_string;
                DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
                          "the domain sid %s.  Failing operation.\n", 
-                         user_name, 
-                         sid_to_string(user_sid_string, user_sid),
-                         sid_to_string(domain_sid_string, domain_sid)));
+                         user_name, sid_string_dbg(user_sid),
+                         sid_string_dbg(domain_sid)));
                data_blob_free(&munged_dial_blob);
                return NT_STATUS_UNSUCCESSFUL;
        }
@@ -6336,13 +6315,10 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *
        unbecome_root();
 
        if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
-               fstring group_sid_string;
-               fstring domain_sid_string;
                DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
                          "which conflicts with the domain sid %s.  Failing operation.\n", 
-                         user_name, 
-                         sid_to_string(group_sid_string, group_sid),
-                         sid_to_string(domain_sid_string, domain_sid)));
+                         user_name, sid_string_dbg(group_sid),
+                         sid_string_dbg(domain_sid)));
                data_blob_free(&munged_dial_blob);
                return NT_STATUS_UNSUCCESSFUL;
        }
@@ -6426,7 +6402,7 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
+static bool sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
                        prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -6545,7 +6521,7 @@ void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
        if (munged_dial) {
                blob = base64_decode_data_blob(munged_dial);
        } else {
-               blob = data_blob(NULL, 0);
+               blob = data_blob_null;
        }
 
        init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
@@ -6557,7 +6533,7 @@ void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
+static bool sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
                        prs_struct *ps, int depth)
 {
        if (usr == NULL)
@@ -6680,10 +6656,10 @@ static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
 reads or writes a structure.
 ********************************************************************/
 
-static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
+static bool samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
                                 prs_struct *ps, int depth)
 {
-       BOOL ret;
+       bool ret;
        SAM_USERINFO_CTR *ctr;
 
        prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
@@ -6848,7 +6824,7 @@ void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
+bool samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
                              prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -6895,7 +6871,7 @@ void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
+bool samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
                            prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -6932,7 +6908,7 @@ void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
+bool samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -6981,7 +6957,7 @@ void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
+bool samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
                             prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7019,7 +6995,7 @@ void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
+bool samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
                             prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7058,7 +7034,7 @@ void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
+bool samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
                       prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7087,7 +7063,7 @@ BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
+bool samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
                       prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7132,7 +7108,7 @@ void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
+bool samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
                        prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7163,7 +7139,7 @@ BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
+bool samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
                        prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7225,7 +7201,7 @@ void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS statu
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
+bool samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
                        prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7264,7 +7240,7 @@ BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
+bool samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
                        prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7311,7 +7287,7 @@ void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
+bool samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
                            prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7341,7 +7317,7 @@ BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
+bool samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
                            prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7380,7 +7356,7 @@ void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
+bool samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7408,7 +7384,7 @@ BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
+bool samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
                              prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7453,7 +7429,7 @@ void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
 reads or writes a SAMR_ENC_PASSWD structure.
 ********************************************************************/
 
-BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
+bool samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
                        prs_struct *ps, int depth)
 {
        if (pwd == NULL)
@@ -7496,7 +7472,7 @@ void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
 reads or writes a SAMR_ENC_HASH structure.
 ********************************************************************/
 
-BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
+bool samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
                      prs_struct *ps, int depth)
 {
        if (hsh == NULL)
@@ -7551,7 +7527,7 @@ void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
+bool samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7609,7 +7585,7 @@ void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
+bool samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
                              prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7662,7 +7638,7 @@ void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
+bool samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
                               prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7737,7 +7713,7 @@ void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
  Reads or writes an SAMR_CHANGE_REJECT structure.
 ********************************************************************/
 
-BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
+bool samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
 {
        if (reject == NULL)
                return False;
@@ -7767,7 +7743,7 @@ BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_str
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
+bool samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
                               prs_struct *ps, int depth)
 {
        if (r_u == NULL)
@@ -7788,7 +7764,7 @@ BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
        if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
                r_u->status = NT_STATUS_NOT_SUPPORTED;
                return True;
-       }       
+       }
 
        if (r_u->ptr_info && r_u->info != NULL) {
                /* SAM_UNK_INFO_1 */
@@ -7828,7 +7804,7 @@ void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
+bool samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -7874,7 +7850,7 @@ void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
+bool samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
                                  prs_struct *ps, int depth)
 {
         if (r_u == NULL)
@@ -7979,7 +7955,7 @@ void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
+bool samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
                              prs_struct *ps, int depth)
 {
        if (q_u == NULL)
@@ -8062,7 +8038,7 @@ void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
 reads or writes a structure.
 ********************************************************************/
 
-BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
+bool samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
                              prs_struct *ps, int depth)
 {
         if (r_u == NULL)