]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Allow smbpasswd to join a W2K hosted AD domain.
authorJeremy Allison <jra@samba.org>
Thu, 2 Aug 2001 23:48:51 +0000 (23:48 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 2 Aug 2001 23:48:51 +0000 (23:48 +0000)
Jeremy.

source/include/rpc_samr.h
source/rpc_parse/parse_samr.c
source/utils/smbpasswd.c

index f31beaaf84b2065f0397e5f614131e0e6074df34..1cf3248b81048713c5fd3d2a643f89216cf6f531 100644 (file)
@@ -217,6 +217,7 @@ typedef struct sam_user_info_23
 typedef struct sam_user_info_24
 {
        uint8 pass[516];
+       uint16 pw_len;
 } SAM_USER_INFO_24;
 
 /*
index 7b86b15e87b5f635315addde9776345ff38d4a8f..c3417eee6cff9e9fffe944c4393016c53c1bab1e 100644 (file)
@@ -5187,10 +5187,11 @@ static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
 
  *************************************************************************/
 
-void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516])
+void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
 {
        DEBUG(10, ("init_sam_user_info24:\n"));
        memcpy(usr->pass, newpass, sizeof(usr->pass));
+       usr->pw_len = pw_len;
 }
 
 /*******************************************************************
@@ -6474,6 +6475,10 @@ BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
        if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
                return False;
 
+       if (MARSHALLING(ps) && (usr->pw_len != 0)) {
+               if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
+                       return False;
+       }
        if(!prs_align(ps))
                return False;
        if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
index aa369e61b435e1574cba0f17fcfa5eaeaadce0be..27a00e2e2bffe0970bdefb97d1392aedba6b7fcc 100644 (file)
@@ -290,7 +290,12 @@ static int join_domain_byuser(char *domain, char *remote_machine,
                                                  acct_name, ACB_WSTRUST,
                                                  unknown, &user_pol, 
                                                  &user_rid);
-       }
+
+               /* We *must* do this.... don't ask... */
+
+               CHECK_RPC_ERR_DEBUG(cli_samr_close(&cli, mem_ctx, &user_pol), ("error closing user policy"));
+               result = NT_STATUS_USER_EXISTS;
+       }       
 
        if (result == NT_STATUS_USER_EXISTS) {
                uint32 num_rids, *name_types, *user_rids;
@@ -356,7 +361,7 @@ static int join_domain_byuser(char *domain, char *remote_machine,
        ZERO_STRUCT(ctr);
        ZERO_STRUCT(p24);
 
-       init_sam_user_info24(&p24, pwbuf);
+       init_sam_user_info24(&p24, pwbuf,24);
 
        ctr.switch_value = 24;
        ctr.info.id24 = &p24;
@@ -380,6 +385,7 @@ static int join_domain_byuser(char *domain, char *remote_machine,
           seems to cope with either value so don't bomb out if the set
           userinfo2 level 0x10 fails.  -tpot */
 
+       ZERO_STRUCT(ctr);
        ctr.switch_value = 0x10;
        ctr.info.id10 = &p10;
 
@@ -549,7 +555,7 @@ static int process_root(int argc, char *argv[])
        char *old_passwd = NULL;
        char *remote_machine = NULL;
 
-       while ((ch = getopt(argc, argv, "ax:d:e:mnj:r:sR:D:U:L")) != EOF) {
+       while ((ch = getopt(argc, argv, "ax:d:e:hmnj:r:sR:D:U:L")) != EOF) {
                switch(ch) {
                case 'L':
                        local_mode = True;
@@ -613,6 +619,7 @@ static int process_root(int argc, char *argv[])
 
                        break;
                }
+               case 'h':
                default:
                        usage();
                }