r23779: Change from v2 or later to v3 or later.
[gd/samba/.git] / source3 / rpc_parse / parse_samr.c
index 529ad319bb806b29dd4c833209a7ca62f56d93ca..2133d2124de50e94782a6137be7158843ba2311f 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,
@@ -3398,7 +3398,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);
                }
@@ -3537,7 +3537,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);
                }
@@ -5067,12 +5067,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++) {
@@ -5096,12 +5097,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++) {
@@ -6132,9 +6134,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;
 
@@ -6170,13 +6189,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;
 }
@@ -6317,7 +6334,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 */
@@ -6571,7 +6588,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);