2 Unix SMB/Netbios implementation.
5 Copyright (C) Tim Potter 2000-2001,
6 Copyright (C) Andrew Tridgell 1992-1997,2000,
7 Copyright (C) Luke Kenneth Casson Leighton 1996-1997,2000,
8 Copyright (C) Paul Ashton 1997,2000,
9 Copyright (C) Elrond 2000.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 /* Opens a SMB connection to the SAMR pipe */
30 struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name,
31 struct ntuser_creds *creds)
33 return cli_pipe_initialise(cli, system_name, PIPE_SAMR, creds);
36 /* Connect to SAMR database */
38 NTSTATUS cli_samr_connect(struct cli_state *cli, TALLOC_CTX *mem_ctx,
39 uint32 access_mask, POLICY_HND *connect_pol)
41 prs_struct qbuf, rbuf;
44 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
49 /* Initialise parse structures */
51 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
52 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
54 /* Marshall data and send request */
56 init_samr_q_connect(&q, cli->desthost, access_mask);
58 if (!samr_io_q_connect("", &q, &qbuf, 0) ||
59 !rpc_api_pipe_req(cli, SAMR_CONNECT, &qbuf, &rbuf)) {
63 /* Unmarshall response */
65 if (!samr_io_r_connect("", &r, &rbuf, 0)) {
69 /* Return output parameters */
71 if ((result = r.status) == NT_STATUS_OK) {
72 *connect_pol = r.connect_pol;
82 /* Close SAMR handle */
84 NTSTATUS cli_samr_close(struct cli_state *cli, TALLOC_CTX *mem_ctx,
85 POLICY_HND *connect_pol)
87 prs_struct qbuf, rbuf;
90 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
95 /* Initialise parse structures */
97 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
98 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
100 /* Marshall data and send request */
102 init_samr_q_close_hnd(&q, connect_pol);
104 if (!samr_io_q_close_hnd("", &q, &qbuf, 0) ||
105 !rpc_api_pipe_req(cli, SAMR_CLOSE_HND, &qbuf, &rbuf)) {
109 /* Unmarshall response */
111 if (!samr_io_r_close_hnd("", &r, &rbuf, 0)) {
115 /* Return output parameters */
117 if ((result = r.status) == NT_STATUS_OK) {
118 *connect_pol = r.pol;
128 /* Open handle on a domain */
130 NTSTATUS cli_samr_open_domain(struct cli_state *cli, TALLOC_CTX *mem_ctx,
131 POLICY_HND *connect_pol, uint32 access_mask,
132 DOM_SID *domain_sid, POLICY_HND *domain_pol)
134 prs_struct qbuf, rbuf;
135 SAMR_Q_OPEN_DOMAIN q;
136 SAMR_R_OPEN_DOMAIN r;
137 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
142 /* Initialise parse structures */
144 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
145 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
147 /* Marshall data and send request */
149 init_samr_q_open_domain(&q, connect_pol, access_mask, domain_sid);
151 if (!samr_io_q_open_domain("", &q, &qbuf, 0) ||
152 !rpc_api_pipe_req(cli, SAMR_OPEN_DOMAIN, &qbuf, &rbuf)) {
156 /* Unmarshall response */
158 if (!samr_io_r_open_domain("", &r, &rbuf, 0)) {
162 /* Return output parameters */
164 if ((result = r.status) == NT_STATUS_OK) {
165 *domain_pol = r.domain_pol;
175 /* Open handle on a user */
177 NTSTATUS cli_samr_open_user(struct cli_state *cli, TALLOC_CTX *mem_ctx,
178 POLICY_HND *domain_pol, uint32 access_mask,
179 uint32 user_rid, POLICY_HND *user_pol)
181 prs_struct qbuf, rbuf;
184 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
189 /* Initialise parse structures */
191 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
192 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
194 /* Marshall data and send request */
196 init_samr_q_open_user(&q, domain_pol, access_mask, user_rid);
198 if (!samr_io_q_open_user("", &q, &qbuf, 0) ||
199 !rpc_api_pipe_req(cli, SAMR_OPEN_USER, &qbuf, &rbuf)) {
203 /* Unmarshall response */
205 if (!samr_io_r_open_user("", &r, &rbuf, 0)) {
209 /* Return output parameters */
211 if ((result = r.status) == NT_STATUS_OK) {
212 *user_pol = r.user_pol;
222 /* Open handle on a group */
224 NTSTATUS cli_samr_open_group(struct cli_state *cli, TALLOC_CTX *mem_ctx,
225 POLICY_HND *domain_pol, uint32 access_mask,
226 uint32 group_rid, POLICY_HND *group_pol)
228 prs_struct qbuf, rbuf;
231 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
236 /* Initialise parse structures */
238 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
239 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
241 /* Marshall data and send request */
243 init_samr_q_open_group(&q, domain_pol, access_mask, group_rid);
245 if (!samr_io_q_open_group("", &q, &qbuf, 0) ||
246 !rpc_api_pipe_req(cli, SAMR_OPEN_GROUP, &qbuf, &rbuf)) {
250 /* Unmarshall response */
252 if (!samr_io_r_open_group("", &r, &rbuf, 0)) {
256 /* Return output parameters */
258 if ((result = r.status) == NT_STATUS_OK) {
269 /* Query user info */
271 NTSTATUS cli_samr_query_userinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx,
272 POLICY_HND *user_pol, uint16 switch_value,
273 SAM_USERINFO_CTR **ctr)
275 prs_struct qbuf, rbuf;
276 SAMR_Q_QUERY_USERINFO q;
277 SAMR_R_QUERY_USERINFO r;
278 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
283 /* Initialise parse structures */
285 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
286 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
288 /* Marshall data and send request */
290 init_samr_q_query_userinfo(&q, user_pol, switch_value);
292 if (!samr_io_q_query_userinfo("", &q, &qbuf, 0) ||
293 !rpc_api_pipe_req(cli, SAMR_QUERY_USERINFO, &qbuf, &rbuf)) {
297 /* Unmarshall response */
299 if (!samr_io_r_query_userinfo("", &r, &rbuf, 0)) {
303 /* Return output parameters */
315 /* Query group info */
317 NTSTATUS cli_samr_query_groupinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx,
318 POLICY_HND *group_pol, uint32 info_level,
321 prs_struct qbuf, rbuf;
322 SAMR_Q_QUERY_GROUPINFO q;
323 SAMR_R_QUERY_GROUPINFO r;
324 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
329 /* Initialise parse structures */
331 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
332 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
334 /* Marshall data and send request */
336 init_samr_q_query_groupinfo(&q, group_pol, info_level);
338 if (!samr_io_q_query_groupinfo("", &q, &qbuf, 0) ||
339 !rpc_api_pipe_req(cli, SAMR_QUERY_GROUPINFO, &qbuf, &rbuf)) {
343 /* Unmarshall response */
347 if (!samr_io_r_query_groupinfo("", &r, &rbuf, 0)) {
351 /* Return output parameters */
362 /* Query user groups */
364 NTSTATUS cli_samr_query_usergroups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
365 POLICY_HND *user_pol, uint32 *num_groups,
368 prs_struct qbuf, rbuf;
369 SAMR_Q_QUERY_USERGROUPS q;
370 SAMR_R_QUERY_USERGROUPS r;
371 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
376 /* Initialise parse structures */
378 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
379 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
381 /* Marshall data and send request */
383 init_samr_q_query_usergroups(&q, user_pol);
385 if (!samr_io_q_query_usergroups("", &q, &qbuf, 0) ||
386 !rpc_api_pipe_req(cli, SAMR_QUERY_USERGROUPS, &qbuf, &rbuf)) {
390 /* Unmarshall response */
392 if (!samr_io_r_query_usergroups("", &r, &rbuf, 0)) {
396 /* Return output parameters */
398 if ((result = r.status) == NT_STATUS_OK) {
399 *num_groups = r.num_entries;
410 /* Query user groups */
412 NTSTATUS cli_samr_query_groupmem(struct cli_state *cli, TALLOC_CTX *mem_ctx,
413 POLICY_HND *group_pol, uint32 *num_mem,
414 uint32 **rid, uint32 **attr)
416 prs_struct qbuf, rbuf;
417 SAMR_Q_QUERY_GROUPMEM q;
418 SAMR_R_QUERY_GROUPMEM r;
419 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
424 /* Initialise parse structures */
426 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
427 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
429 /* Marshall data and send request */
431 init_samr_q_query_groupmem(&q, group_pol);
433 if (!samr_io_q_query_groupmem("", &q, &qbuf, 0) ||
434 !rpc_api_pipe_req(cli, SAMR_QUERY_GROUPMEM, &qbuf, &rbuf)) {
438 /* Unmarshall response */
440 if (!samr_io_r_query_groupmem("", &r, &rbuf, 0)) {
444 /* Return output parameters */
446 if ((result = r.status) == NT_STATUS_OK) {
447 *num_mem = r.num_entries;
459 /* Enumerate domain groups */
461 NTSTATUS cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
462 POLICY_HND *pol, uint32 *start_idx,
463 uint32 size, struct acct_info **dom_groups,
464 uint32 *num_dom_groups)
466 prs_struct qbuf, rbuf;
467 SAMR_Q_ENUM_DOM_GROUPS q;
468 SAMR_R_ENUM_DOM_GROUPS r;
469 NTSTATUS result = NT_STATUS_UNSUCCESSFUL, name_idx, i;
474 /* Initialise parse structures */
476 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
477 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
479 /* Marshall data and send request */
481 init_samr_q_enum_dom_groups(&q, pol, *start_idx, size);
483 if (!samr_io_q_enum_dom_groups("", &q, &qbuf, 0) ||
484 !rpc_api_pipe_req(cli, SAMR_ENUM_DOM_GROUPS, &qbuf, &rbuf)) {
488 /* Unmarshall response */
490 if (!samr_io_r_enum_dom_groups("", &r, &rbuf, 0)) {
494 /* Return output parameters */
498 if (result != NT_STATUS_OK &&
499 result != STATUS_MORE_ENTRIES) {
503 *num_dom_groups = r.num_entries2;
505 if (!((*dom_groups) = (struct acct_info *)
506 talloc(mem_ctx, sizeof(struct acct_info) * *num_dom_groups))) {
507 result = NT_STATUS_UNSUCCESSFUL;
511 memset(*dom_groups, 0, sizeof(struct acct_info) * *num_dom_groups);
515 for (i = 0; i < *num_dom_groups; i++) {
517 (*dom_groups)[i].rid = r.sam[i].rid;
519 if (r.sam[i].hdr_name.buffer) {
520 unistr2_to_ascii((*dom_groups)[i].acct_name,
521 &r.uni_grp_name[name_idx],
522 sizeof(fstring) - 1);
526 *start_idx = r.next_idx;
536 /* Query alias members */
538 NTSTATUS cli_samr_query_aliasmem(struct cli_state *cli, TALLOC_CTX *mem_ctx,
539 POLICY_HND *alias_pol, uint32 *num_mem,
542 prs_struct qbuf, rbuf;
543 SAMR_Q_QUERY_ALIASMEM q;
544 SAMR_R_QUERY_ALIASMEM r;
545 NTSTATUS result = NT_STATUS_UNSUCCESSFUL, i;
550 /* Initialise parse structures */
552 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
553 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
555 /* Marshall data and send request */
557 init_samr_q_query_aliasmem(&q, alias_pol);
559 if (!samr_io_q_query_aliasmem("", &q, &qbuf, 0) ||
560 !rpc_api_pipe_req(cli, SAMR_QUERY_ALIASMEM, &qbuf, &rbuf)) {
564 /* Unmarshall response */
566 if (!samr_io_r_query_aliasmem("", &r, &rbuf, 0)) {
570 /* Return output parameters */
572 if ((result = r.status) != NT_STATUS_OK) {
576 *num_mem = r.num_sids;
578 if (!(*sids = talloc(mem_ctx, sizeof(DOM_SID) * *num_mem))) {
579 result = NT_STATUS_UNSUCCESSFUL;
583 for (i = 0; i < *num_mem; i++) {
584 (*sids)[i] = r.sid[i].sid;
594 /* Open handle on an alias */
596 NTSTATUS cli_samr_open_alias(struct cli_state *cli, TALLOC_CTX *mem_ctx,
597 POLICY_HND *domain_pol, uint32 access_mask,
598 uint32 alias_rid, POLICY_HND *alias_pol)
600 prs_struct qbuf, rbuf;
608 /* Initialise parse structures */
610 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
611 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
613 /* Marshall data and send request */
615 init_samr_q_open_alias(&q, domain_pol, access_mask, alias_rid);
617 if (!samr_io_q_open_alias("", &q, &qbuf, 0) ||
618 !rpc_api_pipe_req(cli, SAMR_OPEN_ALIAS, &qbuf, &rbuf)) {
619 result = NT_STATUS_UNSUCCESSFUL;
623 /* Unmarshall response */
625 if (!samr_io_r_open_alias("", &r, &rbuf, 0)) {
626 result = NT_STATUS_UNSUCCESSFUL;
630 /* Return output parameters */
632 if ((result = r.status) == NT_STATUS_OK) {
643 /* Query domain info */
645 NTSTATUS cli_samr_query_dom_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
646 POLICY_HND *domain_pol, uint16 switch_value,
649 prs_struct qbuf, rbuf;
650 SAMR_Q_QUERY_DOMAIN_INFO q;
651 SAMR_R_QUERY_DOMAIN_INFO r;
652 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
657 /* Initialise parse structures */
659 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
660 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
662 /* Marshall data and send request */
664 init_samr_q_query_dom_info(&q, domain_pol, switch_value);
666 if (!samr_io_q_query_dom_info("", &q, &qbuf, 0) ||
667 !rpc_api_pipe_req(cli, SAMR_QUERY_DOMAIN_INFO, &qbuf, &rbuf)) {
671 /* Unmarshall response */
675 if (!samr_io_r_query_dom_info("", &r, &rbuf, 0)) {
679 /* Return output parameters */
681 if ((result = r.status) != NT_STATUS_OK) {
692 /* Query display info */
694 NTSTATUS cli_samr_query_dispinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx,
695 POLICY_HND *domain_pol, uint32 *start_idx,
696 uint16 switch_value, uint32 *num_entries,
697 uint32 max_entries, SAM_DISPINFO_CTR *ctr)
699 prs_struct qbuf, rbuf;
700 SAMR_Q_QUERY_DISPINFO q;
701 SAMR_R_QUERY_DISPINFO r;
702 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
707 /* Initialise parse structures */
709 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
710 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
712 /* Marshall data and send request */
714 init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
715 *start_idx, max_entries);
717 if (!samr_io_q_query_dispinfo("", &q, &qbuf, 0) ||
718 !rpc_api_pipe_req(cli, SAMR_QUERY_DISPINFO, &qbuf, &rbuf)) {
722 /* Unmarshall response */
726 if (!samr_io_r_query_dispinfo("", &r, &rbuf, 0)) {
730 /* Return output parameters */
734 if (result != NT_STATUS_OK &&
735 result != STATUS_MORE_ENTRIES) {
739 *num_entries = r.num_entries;
740 *start_idx += r.num_entries; /* No next_idx in this structure! */
749 /* Lookup rids. Note that NT4 seems to crash if more than ~1000 rids are
750 looked up in one packet. */
752 NTSTATUS cli_samr_lookup_rids(struct cli_state *cli, TALLOC_CTX *mem_ctx,
753 POLICY_HND *domain_pol, uint32 flags,
754 uint32 num_rids, uint32 *rids,
755 uint32 *num_names, char ***names,
758 prs_struct qbuf, rbuf;
759 SAMR_Q_LOOKUP_RIDS q;
760 SAMR_R_LOOKUP_RIDS r;
761 NTSTATUS result = NT_STATUS_UNSUCCESSFUL, i;
763 if (num_rids > 1000) {
764 DEBUG(2, ("cli_samr_lookup_rids: warning: NT4 can crash if "
765 "more than ~1000 rids are looked up at once.\n"));
771 /* Initialise parse structures */
773 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
774 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
776 /* Marshall data and send request */
778 init_samr_q_lookup_rids(mem_ctx, &q, domain_pol, flags,
781 if (!samr_io_q_lookup_rids("", &q, &qbuf, 0) ||
782 !rpc_api_pipe_req(cli, SAMR_LOOKUP_RIDS, &qbuf, &rbuf)) {
786 /* Unmarshall response */
788 if (!samr_io_r_lookup_rids("", &r, &rbuf, 0)) {
792 /* Return output parameters */
794 if ((result = r.status) != NT_STATUS_OK) {
798 if (r.num_names1 == 0) {
804 *num_names = r.num_names1;
805 *names = talloc(mem_ctx, sizeof(char *) * r.num_names1);
806 *name_types = talloc(mem_ctx, sizeof(uint32) * r.num_names1);
808 for (i = 0; i < r.num_names1; i++) {
811 unistr2_to_ascii(tmp, &r.uni_name[i], sizeof(tmp) - 1);
812 (*names)[i] = talloc_strdup(mem_ctx, tmp);
813 (*name_types)[i] = r.type[i];
825 NTSTATUS cli_samr_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx,
826 POLICY_HND *domain_pol, uint32 flags,
827 uint32 num_names, char **names,
828 uint32 *num_rids, uint32 **rids,
831 prs_struct qbuf, rbuf;
832 SAMR_Q_LOOKUP_NAMES q;
833 SAMR_R_LOOKUP_NAMES r;
834 NTSTATUS result = NT_STATUS_UNSUCCESSFUL, i;
839 /* Initialise parse structures */
841 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
842 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
844 /* Marshall data and send request */
846 init_samr_q_lookup_names(mem_ctx, &q, domain_pol, flags,
849 if (!samr_io_q_lookup_names("", &q, &qbuf, 0) ||
850 !rpc_api_pipe_req(cli, SAMR_LOOKUP_NAMES, &qbuf, &rbuf)) {
854 /* Unmarshall response */
856 if (!samr_io_r_lookup_names("", &r, &rbuf, 0)) {
860 /* Return output parameters */
862 if ((result = r.status) != NT_STATUS_OK) {
866 if (r.num_rids1 == 0) {
871 *num_rids = r.num_rids1;
872 *rids = talloc(mem_ctx, sizeof(uint32) * r.num_rids1);
873 *rid_types = talloc(mem_ctx, sizeof(uint32) * r.num_rids1);
875 for (i = 0; i < r.num_rids1; i++) {
876 (*rids)[i] = r.rids[i];
877 (*rid_types)[i] = r.types[i];
887 /* Create a domain user */
889 NTSTATUS cli_samr_create_dom_user(struct cli_state *cli, TALLOC_CTX *mem_ctx,
890 POLICY_HND *domain_pol, char *acct_name,
891 uint32 acb_info, uint32 unknown,
892 POLICY_HND *user_pol, uint32 *rid)
894 prs_struct qbuf, rbuf;
895 SAMR_Q_CREATE_USER q;
896 SAMR_R_CREATE_USER r;
897 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
902 /* Initialise parse structures */
904 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
905 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
907 /* Marshall data and send request */
909 init_samr_q_create_user(&q, domain_pol, acct_name, acb_info, unknown);
911 if (!samr_io_q_create_user("", &q, &qbuf, 0) ||
912 !rpc_api_pipe_req(cli, SAMR_CREATE_USER, &qbuf, &rbuf)) {
916 /* Unmarshall response */
918 if (!samr_io_r_create_user("", &r, &rbuf, 0)) {
922 /* Return output parameters */
924 if ((result = r.status) != NT_STATUS_OK) {
929 *user_pol = r.user_pol;
943 NTSTATUS cli_samr_set_userinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx,
944 POLICY_HND *user_pol, uint16 switch_value,
945 uchar sess_key[16], SAM_USERINFO_CTR *ctr)
947 prs_struct qbuf, rbuf;
948 SAMR_Q_SET_USERINFO q;
949 SAMR_R_SET_USERINFO r;
950 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
955 /* Initialise parse structures */
957 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
958 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
960 /* Marshall data and send request */
964 init_samr_q_set_userinfo(&q, user_pol, sess_key, switch_value,
967 if (!samr_io_q_set_userinfo("", &q, &qbuf, 0) ||
968 !rpc_api_pipe_req(cli, SAMR_SET_USERINFO, &qbuf, &rbuf)) {
972 /* Unmarshall response */
974 if (!samr_io_r_set_userinfo("", &r, &rbuf, 0)) {
978 /* Return output parameters */
980 if ((result = r.status) != NT_STATUS_OK) {
993 NTSTATUS cli_samr_set_userinfo2(struct cli_state *cli, TALLOC_CTX *mem_ctx,
994 POLICY_HND *user_pol, uint16 switch_value,
995 uchar sess_key[16], SAM_USERINFO_CTR *ctr)
997 prs_struct qbuf, rbuf;
998 SAMR_Q_SET_USERINFO2 q;
999 SAMR_R_SET_USERINFO2 r;
1000 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1005 /* Initialise parse structures */
1007 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
1008 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
1010 /* Marshall data and send request */
1012 init_samr_q_set_userinfo2(&q, user_pol, sess_key, switch_value, ctr);
1014 if (!samr_io_q_set_userinfo2("", &q, &qbuf, 0) ||
1015 !rpc_api_pipe_req(cli, SAMR_SET_USERINFO2, &qbuf, &rbuf)) {
1019 /* Unmarshall response */
1021 if (!samr_io_r_set_userinfo2("", &r, &rbuf, 0)) {
1025 /* Return output parameters */
1027 if ((result = r.status) != NT_STATUS_OK) {
1032 prs_mem_free(&qbuf);
1033 prs_mem_free(&rbuf);
1038 /* Delete domain user */
1040 NTSTATUS cli_samr_delete_dom_user(struct cli_state *cli, TALLOC_CTX *mem_ctx,
1041 POLICY_HND *user_pol)
1043 prs_struct qbuf, rbuf;
1044 SAMR_Q_DELETE_DOM_USER q;
1045 SAMR_R_DELETE_DOM_USER r;
1046 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1051 /* Initialise parse structures */
1053 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
1054 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
1056 /* Marshall data and send request */
1058 init_samr_q_delete_dom_user(&q, user_pol);
1060 if (!samr_io_q_delete_dom_user("", &q, &qbuf, 0) ||
1061 !rpc_api_pipe_req(cli, SAMR_DELETE_DOM_USER, &qbuf, &rbuf)) {
1065 /* Unmarshall response */
1067 if (!samr_io_r_delete_dom_user("", &r, &rbuf, 0)) {
1071 /* Return output parameters */
1076 prs_mem_free(&qbuf);
1077 prs_mem_free(&rbuf);