svn commit: samba r16344 - branches/SAMBA_3_0/source/utils
trunk/source/utils
gd at samba.org
gd at samba.org
Mon Jun 19 09:54:01 GMT 2006
Author: gd
Date: 2006-06-19 09:54:00 +0000 (Mon, 19 Jun 2006)
New Revision: 16344
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16344
Log:
Allow to set passwords directly when creating users via "net rpc user
add" (as the documentation says, and currently onle "net ads user add"
did). Fixes #3843.
Guenther
Modified:
branches/SAMBA_3_0/source/utils/net_help.c
branches/SAMBA_3_0/source/utils/net_rpc.c
trunk/source/utils/net_help.c
trunk/source/utils/net_rpc.c
Changeset:
Modified: branches/SAMBA_3_0/source/utils/net_help.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_help.c 2006-06-19 07:46:35 UTC (rev 16343)
+++ branches/SAMBA_3_0/source/utils/net_help.c 2006-06-19 09:54:00 UTC (rev 16344)
@@ -73,7 +73,7 @@
"\n\tDelete specified user\n");
d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
"\n\tList the domain groups of the specified user\n");
- d_printf("\nnet [<method>] user ADD <name> [-c container] "\
+ d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
"[-F user flags] [misc. options]"\
" [targets]\n\tAdd specified user\n");
d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\
Modified: branches/SAMBA_3_0/source/utils/net_rpc.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_rpc.c 2006-06-19 07:46:35 UTC (rev 16343)
+++ branches/SAMBA_3_0/source/utils/net_rpc.c 2006-06-19 09:54:00 UTC (rev 16344)
@@ -583,7 +583,7 @@
uint32 acb_info;
uint32 unknown, user_rid;
- if (argc != 1) {
+ if (argc < 1) {
d_printf("User must be specified\n");
rpc_user_usage(argc, argv);
return NT_STATUS_OK;
@@ -620,6 +620,60 @@
goto done;
}
+ if (argc == 2) {
+
+ uint32 *user_rids, num_rids, *name_types;
+ uint32 flags = 0x000003e8; /* Unknown */
+ SAM_USERINFO_CTR ctr;
+ SAM_USER_INFO_24 p24;
+ uchar pwbuf[516];
+
+ result = rpccli_samr_lookup_names(pipe_hnd, mem_ctx, &domain_pol,
+ flags, 1, &acct_name,
+ &num_rids, &user_rids,
+ &name_types);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rids[0], &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Set password on account */
+
+ ZERO_STRUCT(ctr);
+ ZERO_STRUCT(p24);
+
+ encode_pw_buffer(pwbuf, argv[1], STR_UNICODE);
+
+ init_sam_user_info24(&p24, (char *)pwbuf,24);
+
+ ctr.switch_value = 24;
+ ctr.info.id24 = &p24;
+
+ result = rpccli_samr_set_userinfo(pipe_hnd, mem_ctx, &user_pol, 24,
+ &cli->user_session_key, &ctr);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ d_fprintf(stderr, "Failed to set password for user %s - %s\n",
+ acct_name, nt_errstr(result));
+
+ result = rpccli_samr_delete_dom_user(pipe_hnd, mem_ctx, &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ d_fprintf(stderr, "Failed to delete user %s - %s\n",
+ acct_name, nt_errstr(result));
+ return result;
+ }
+ }
+
+ }
done:
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Failed to add user %s - %s\n", acct_name,
Modified: trunk/source/utils/net_help.c
===================================================================
--- trunk/source/utils/net_help.c 2006-06-19 07:46:35 UTC (rev 16343)
+++ trunk/source/utils/net_help.c 2006-06-19 09:54:00 UTC (rev 16344)
@@ -73,7 +73,7 @@
"\n\tDelete specified user\n");
d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
"\n\tList the domain groups of the specified user\n");
- d_printf("\nnet [<method>] user ADD <name> [-c container] "\
+ d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
"[-F user flags] [misc. options]"\
" [targets]\n\tAdd specified user\n");
d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\
Modified: trunk/source/utils/net_rpc.c
===================================================================
--- trunk/source/utils/net_rpc.c 2006-06-19 07:46:35 UTC (rev 16343)
+++ trunk/source/utils/net_rpc.c 2006-06-19 09:54:00 UTC (rev 16344)
@@ -583,7 +583,7 @@
uint32 acb_info;
uint32 unknown, user_rid;
- if (argc != 1) {
+ if (argc < 1) {
d_printf("User must be specified\n");
rpc_user_usage(argc, argv);
return NT_STATUS_OK;
@@ -620,6 +620,60 @@
goto done;
}
+ if (argc == 2) {
+
+ uint32 *user_rids, num_rids, *name_types;
+ uint32 flags = 0x000003e8; /* Unknown */
+ SAM_USERINFO_CTR ctr;
+ SAM_USER_INFO_24 p24;
+ uchar pwbuf[516];
+
+ result = rpccli_samr_lookup_names(pipe_hnd, mem_ctx, &domain_pol,
+ flags, 1, &acct_name,
+ &num_rids, &user_rids,
+ &name_types);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rids[0], &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Set password on account */
+
+ ZERO_STRUCT(ctr);
+ ZERO_STRUCT(p24);
+
+ encode_pw_buffer(pwbuf, argv[1], STR_UNICODE);
+
+ init_sam_user_info24(&p24, (char *)pwbuf,24);
+
+ ctr.switch_value = 24;
+ ctr.info.id24 = &p24;
+
+ result = rpccli_samr_set_userinfo(pipe_hnd, mem_ctx, &user_pol, 24,
+ &cli->user_session_key, &ctr);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ d_fprintf(stderr, "Failed to set password for user %s - %s\n",
+ acct_name, nt_errstr(result));
+
+ result = rpccli_samr_delete_dom_user(pipe_hnd, mem_ctx, &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ d_fprintf(stderr, "Failed to delete user %s - %s\n",
+ acct_name, nt_errstr(result));
+ return result;
+ }
+ }
+
+ }
done:
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Failed to add user %s - %s\n", acct_name,
More information about the samba-cvs
mailing list