r5580: Fix "net rpc trustdom add". Much closer to what windows does. Also stop
authorJim McDonough <jmcd@samba.org>
Sat, 26 Feb 2005 15:26:55 +0000 (15:26 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:55:48 +0000 (10:55 -0500)
referencing unknown_6 from sam, because it's just fixed at 1260, the max
len of LOGON_HRS.  Need to go in and mark it as "remove me" from passdb.
(This used to be commit ffac752875938d510446ebbeba6fc983f65cda1e)

source3/include/rpc_samr.h
source3/rpc_parse/parse_samr.c
source3/rpc_server/srv_samr_util.c
source3/utils/net_rpc.c

index e041ee26f0b885b91b182532e8b6887e3eb18dfa..6559127df11fe26acb102c7f0a59fe81337e8e36 100644 (file)
@@ -148,6 +148,8 @@ SamrTestPrivateFunctionsUser
 
 typedef struct logon_hours_info
 {
+       uint32 max_len; /* normally 1260 bytes */
+       uint32 offset;
        uint32 len; /* normally 21 bytes */
        uint8 hours[32];
 
@@ -212,9 +214,6 @@ typedef struct sam_user_info_23
        UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
        UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel no */
 
-       uint32 unknown_6; /* 0x0000 04ec */
-       uint32 padding4;
-
        LOGON_HRS logon_hrs;
 
 } SAM_USER_INFO_23;
@@ -336,9 +335,6 @@ typedef struct sam_user_info_21
        UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
        UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
 
-       uint32 unknown_6; /* 0x0000 04ec */
-       uint32 padding4;
-
        LOGON_HRS logon_hrs;
 
 } SAM_USER_INFO_21;
index 27570ae8213cb576520da0fcf5004cc46f307f55..14d4bb9fdf7914bd7299fcf7b9698bad00f260de 100644 (file)
@@ -5148,6 +5148,12 @@ static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
        if(!prs_align(ps))
                return False;
 
+       if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
+               return False;
+
+       if(!prs_uint32("offset", ps, depth, &hrs->offset))
+               return False;
+
        if(!prs_uint32("len  ", ps, depth, &hrs->len))
                return False;
 
@@ -5471,7 +5477,7 @@ void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time,   /* all z
                        LOGON_HRS * hrs,
                        uint16 bad_password_count,
                        uint16 logon_count,
-                       char newpass[516], uint32 unknown_6)
+                       char newpass[516])
 {
        usr->logon_time = *logon_time;  /* all zeros */
        usr->logoff_time = *logoff_time;        /* all zeros */
@@ -5535,9 +5541,6 @@ void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time,   /* all z
        copy_unistr2(&usr->uni_munged_dial, mung_dial);
        init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
 
-       usr->unknown_6 = unknown_6;     /* 0x0000 04ec */
-       usr->padding4 = 0;
-
        memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
 }
 
@@ -5562,7 +5565,7 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time,   /* all z
                           uint32 group_rid, uint32 acb_info,
                           uint32 fields_present, uint16 logon_divs,
                           LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
-                          char newpass[516], uint32 unknown_6)
+                          char newpass[516])
 {
        DATA_BLOB blob = base64_decode_data_blob(mung_dial);
        
@@ -5630,9 +5633,6 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time,   /* all z
 
        data_blob_free(&blob);
        
-       usr->unknown_6 = unknown_6;     /* 0x0000 04ec */
-       usr->padding4 = 0;
-
        memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
 }
 
@@ -5757,16 +5757,9 @@ static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
 
        /* ok, this is only guess-work (as usual) */
        if (usr->ptr_logon_hrs) {
-               if(!prs_uint32("unknown_6     ", ps, depth, &usr->unknown_6))
-                       return False;
-               if(!prs_uint32("padding4      ", ps, depth, &usr->padding4))
-                       return False;
                if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
                        return False;
-       } else if (UNMARSHALLING(ps)) {
-               usr->unknown_6 = 0;
-               usr->padding4 = 0;
-       }
+       } 
 
        return True;
 }
@@ -5876,16 +5869,9 @@ static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_str
 #if 0 /* JRA - unknown... */
        /* ok, this is only guess-work (as usual) */
        if (usr->ptr_logon_hrs) {
-               if(!prs_uint32("unknown_6     ", ps, depth, &usr->unknown_6))
-                       return False;
-               if(!prs_uint32("padding4      ", ps, depth, &usr->padding4))
-                       return False;
                if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
                        return False;
-       } else if (UNMARSHALLING(ps)) {
-               usr->unknown_6 = 0;
-               usr->padding4 = 0;
-       }
+       } 
 #endif
 
        return True;
@@ -5925,8 +5911,7 @@ void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
                           uint16 logon_divs,
                           LOGON_HRS * hrs,
                           uint16 bad_password_count,
-                          uint16 logon_count,
-                          uint32 unknown_6)
+                          uint16 logon_count)
 {
        usr->logon_time = *logon_time;
        usr->logoff_time = *logoff_time;
@@ -5987,9 +5972,6 @@ void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
        copy_unistr2(&usr->uni_munged_dial, mung_dial);
        init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
 
-       usr->unknown_6 = unknown_6;     /* 0x0000 04ec */
-       usr->padding4 = 0;
-
        memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
 }
 
@@ -6136,14 +6118,17 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *
        init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
        data_blob_free(&munged_dial_blob);
 
-       usr->unknown_6 = pdb_get_unknown_6(pw);
-       usr->padding4 = 0;
-
        if (pdb_get_hours(pw)) {
+               usr->logon_hrs.max_len = 1260;
+               usr->logon_hrs.offset = 0;
                usr->logon_hrs.len = pdb_get_hours_len(pw);
                memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
-       } else
+       } else {
+               usr->logon_hrs.max_len = 1260;
+               usr->logon_hrs.offset = 0;
+               usr->logon_hrs.len = 0;
                memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
+       }
 
        return NT_STATUS_OK;
 }
@@ -6256,17 +6241,8 @@ static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
 
        /* ok, this is only guess-work (as usual) */
        if (usr->ptr_logon_hrs) {
-               if(!prs_align(ps))
-                       return False;
-               if(!prs_uint32("unknown_6     ", ps, depth, &usr->unknown_6))
-                       return False;
-               if(!prs_uint32("padding4      ", ps, depth, &usr->padding4))
-                       return False;
                if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
                        return False;
-       } else if (UNMARSHALLING(ps)) {
-               usr->unknown_6 = 0;
-               usr->padding4 = 0;
        }
 
        return True;
index dd12a438caeeade3399fc372f162a551407db17e..6797730be97abb50f32e4c3ddbc75306b6d3c911 100644 (file)
@@ -268,12 +268,6 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
                if (!strequal(old, new)) {
                        pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
                }
-
-               /* This is max logon hours */
-               DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6));
-               if (from->unknown_6 != pdb_get_unknown_6(to)) {
-                       pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED);
-               }
        }
 
        if (from->fields_present & ACCT_BAD_PWD_COUNT) {
@@ -296,8 +290,6 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
        }
 
        DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2));
-
-       DEBUG(10,("INFO_21 PADDING_4: %08X\n",from->padding4));
 }
 
 
@@ -499,11 +491,6 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
                /* Fix me: only update if it changes --metze */
                pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
 
-               /* This is max logon hours */
-               DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6));
-               if (from->unknown_6 != pdb_get_unknown_6(to)) {
-                       pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED);
-               }
        }
 
        if (from->fields_present & ACCT_BAD_PWD_COUNT) {
@@ -526,6 +513,4 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
        }
 
        DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2));
-
-       DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4));
 }
index b18d4b0ba5e680930f8c8eeca83dc8ecfeb11be9..13624f75447279c32c2103f84c9f6d25bb3cb8bb 100644 (file)
@@ -4377,7 +4377,7 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid,
        }
 
        /* Create trusting domain's account */
-       acb_info = ACB_DOMTRUST;
+       acb_info = ACB_NORMAL; 
        unknown = 0xe00500b0; /* No idea what this is - a permission mask?
                                 mimir: yes, most probably it is */
 
@@ -4390,20 +4390,34 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid,
 
        {
                SAM_USERINFO_CTR ctr;
-               SAM_USER_INFO_24 p24;
+               SAM_USER_INFO_23 p23;
+               NTTIME notime;
+               char nostr[] = "";
+               LOGON_HRS hrs;
                uchar pwbuf[516];
 
                encode_pw_buffer((char *)pwbuf, argv[1], STR_UNICODE);
 
                ZERO_STRUCT(ctr);
-               ZERO_STRUCT(p24);
-
-               init_sam_user_info24(&p24, (char *)pwbuf, 24);
-
-               ctr.switch_value = 24;
-               ctr.info.id24 = &p24;
-
-               result = cli_samr_set_userinfo(cli, mem_ctx, &user_pol, 24,
+               ZERO_STRUCT(p23);
+               ZERO_STRUCT(notime);
+               hrs.max_len = 1260;
+               hrs.offset = 0;
+               hrs.len = 21;
+               memset(hrs.hours, 0xFF, sizeof(hrs.hours));
+               acb_info = ACB_DOMTRUST;
+
+               init_sam_user_info23A(&p23, &notime, &notime, &notime,
+                                     &notime, &notime, &notime,
+                                     nostr, nostr, nostr, nostr, nostr,
+                                     nostr, nostr, nostr, nostr, nostr,
+                                     0, 0, acb_info, ACCT_FLAGS, 168, &hrs, 
+                                     0, 0, (char *)pwbuf);
+               ctr.switch_value = 23;
+               ctr.info.id23 = &p23;
+               p23.passmustchange = 0;
+
+               result = cli_samr_set_userinfo(cli, mem_ctx, &user_pol, 23,
                                               &cli->user_session_key, &ctr);
 
                if (!NT_STATUS_IS_OK(result)) {