2 Unix SMB/CIFS implementation.
4 Copyright (C) Tim Potter 2000-2001,
5 Copyright (C) Andrew Tridgell 1992-1997,2000,
6 Copyright (C) Rafal Szczesniak 2002.
7 Copyright (C) Jeremy Allison 2005.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 static void init_lsa_String(struct lsa_String *name, const char *s)
32 NTSTATUS rpccli_samr_query_userinfo(struct rpc_pipe_client *cli,
34 const POLICY_HND *user_pol,
36 SAM_USERINFO_CTR **ctr)
38 prs_struct qbuf, rbuf;
39 SAMR_Q_QUERY_USERINFO q;
40 SAMR_R_QUERY_USERINFO r;
41 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
43 DEBUG(10,("cli_samr_query_userinfo\n"));
48 /* Marshall data and send request */
50 init_samr_q_query_userinfo(&q, user_pol, switch_value);
52 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_USERINFO,
55 samr_io_q_query_userinfo,
56 samr_io_r_query_userinfo,
57 NT_STATUS_UNSUCCESSFUL);
59 /* Return output parameters */
69 NTSTATUS rpccli_samr_set_groupinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
70 POLICY_HND *group_pol, GROUP_INFO_CTR *ctr)
72 prs_struct qbuf, rbuf;
73 SAMR_Q_SET_GROUPINFO q;
74 SAMR_R_SET_GROUPINFO r;
75 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
77 DEBUG(10,("cli_samr_set_groupinfo\n"));
82 /* Marshall data and send request */
84 init_samr_q_set_groupinfo(&q, group_pol, ctr);
86 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_SET_GROUPINFO,
89 samr_io_q_set_groupinfo,
90 samr_io_r_set_groupinfo,
91 NT_STATUS_UNSUCCESSFUL);
93 /* Return output parameters */
100 /* Query group info */
102 NTSTATUS rpccli_samr_query_groupinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
103 POLICY_HND *group_pol, uint32 info_level,
104 GROUP_INFO_CTR **ctr)
106 prs_struct qbuf, rbuf;
107 SAMR_Q_QUERY_GROUPINFO q;
108 SAMR_R_QUERY_GROUPINFO r;
109 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
111 DEBUG(10,("cli_samr_query_groupinfo\n"));
116 /* Marshall data and send request */
118 init_samr_q_query_groupinfo(&q, group_pol, info_level);
120 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_GROUPINFO,
123 samr_io_q_query_groupinfo,
124 samr_io_r_query_groupinfo,
125 NT_STATUS_UNSUCCESSFUL);
129 /* Return output parameters */
136 /* Query user groups */
138 NTSTATUS rpccli_samr_query_usergroups(struct rpc_pipe_client *cli,
140 POLICY_HND *user_pol,
144 prs_struct qbuf, rbuf;
145 SAMR_Q_QUERY_USERGROUPS q;
146 SAMR_R_QUERY_USERGROUPS r;
147 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
149 DEBUG(10,("cli_samr_query_usergroups\n"));
154 /* Marshall data and send request */
156 init_samr_q_query_usergroups(&q, user_pol);
158 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_USERGROUPS,
161 samr_io_q_query_usergroups,
162 samr_io_r_query_usergroups,
163 NT_STATUS_UNSUCCESSFUL);
165 /* Return output parameters */
167 if (NT_STATUS_IS_OK(result = r.status)) {
168 *num_groups = r.num_entries;
176 * Enumerate domain users
178 * @param cli client state structure
179 * @param mem_ctx talloc context
180 * @param pol opened domain policy handle
181 * @param start_idx starting index of enumeration, returns context for
183 * @param acb_mask account control bit mask (to enumerate some particular
185 * @param size max acceptable size of response
186 * @param dom_users returned array of domain user names
187 * @param rids returned array of domain user RIDs
188 * @param num_dom_users numer returned entries
190 * @return NTSTATUS returned in rpc response
193 NTSTATUS rpccli_samr_enum_dom_users(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
194 POLICY_HND *pol, uint32 *start_idx, uint32 acb_mask,
195 uint32 size, char ***dom_users, uint32 **rids,
196 uint32 *num_dom_users)
200 SAMR_Q_ENUM_DOM_USERS q;
201 SAMR_R_ENUM_DOM_USERS r;
202 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
205 DEBUG(10,("cli_samr_enum_dom_users starting at index %u\n", (unsigned int)*start_idx));
210 /* always init this */
213 /* Fill query structure with parameters */
215 init_samr_q_enum_dom_users(&q, pol, *start_idx, acb_mask, size);
217 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ENUM_DOM_USERS,
220 samr_io_q_enum_dom_users,
221 samr_io_r_enum_dom_users,
222 NT_STATUS_UNSUCCESSFUL);
226 if (!NT_STATUS_IS_OK(result) &&
227 NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES))
230 *start_idx = r.next_idx;
231 *num_dom_users = r.num_entries2;
233 if (r.num_entries2) {
234 /* allocate memory needed to return received data */
235 *rids = TALLOC_ARRAY(mem_ctx, uint32, r.num_entries2);
237 DEBUG(0, ("Error in cli_samr_enum_dom_users(): out of memory\n"));
238 return NT_STATUS_NO_MEMORY;
241 *dom_users = TALLOC_ARRAY(mem_ctx, char*, r.num_entries2);
243 DEBUG(0, ("Error in cli_samr_enum_dom_users(): out of memory\n"));
244 return NT_STATUS_NO_MEMORY;
247 /* fill output buffers with rpc response */
248 for (i = 0; i < r.num_entries2; i++) {
251 (*rids)[i] = r.sam[i].rid;
252 unistr2_to_ascii(conv_buf, &(r.uni_acct_name[i]), sizeof(conv_buf));
253 (*dom_users)[i] = talloc_strdup(mem_ctx, conv_buf);
261 /* Enumerate domain groups */
263 NTSTATUS rpccli_samr_enum_dom_groups(struct rpc_pipe_client *cli,
265 POLICY_HND *pol, uint32 *start_idx,
266 uint32 size, struct acct_info **dom_groups,
267 uint32 *num_dom_groups)
269 prs_struct qbuf, rbuf;
270 SAMR_Q_ENUM_DOM_GROUPS q;
271 SAMR_R_ENUM_DOM_GROUPS r;
272 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
275 DEBUG(10,("cli_samr_enum_dom_groups starting at index %u\n", (unsigned int)*start_idx));
280 /* Marshall data and send request */
282 init_samr_q_enum_dom_groups(&q, pol, *start_idx, size);
284 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ENUM_DOM_GROUPS,
287 samr_io_q_enum_dom_groups,
288 samr_io_r_enum_dom_groups,
289 NT_STATUS_UNSUCCESSFUL);
291 /* Return output parameters */
295 if (!NT_STATUS_IS_OK(result) &&
296 NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES))
299 *num_dom_groups = r.num_entries2;
301 if (*num_dom_groups == 0)
304 if (!((*dom_groups) = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_dom_groups))) {
305 result = NT_STATUS_NO_MEMORY;
309 memset(*dom_groups, 0, sizeof(struct acct_info) * (*num_dom_groups));
313 for (i = 0; i < *num_dom_groups; i++) {
315 (*dom_groups)[i].rid = r.sam[i].rid;
317 if (r.sam[i].hdr_name.buffer) {
318 unistr2_to_ascii((*dom_groups)[i].acct_name,
319 &r.uni_grp_name[name_idx],
320 sizeof((*dom_groups)[i].acct_name));
324 *start_idx = r.next_idx;
331 /* Enumerate domain groups */
333 NTSTATUS rpccli_samr_enum_als_groups(struct rpc_pipe_client *cli,
335 POLICY_HND *pol, uint32 *start_idx,
336 uint32 size, struct acct_info **dom_aliases,
337 uint32 *num_dom_aliases)
339 prs_struct qbuf, rbuf;
340 SAMR_Q_ENUM_DOM_ALIASES q;
341 SAMR_R_ENUM_DOM_ALIASES r;
342 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
345 DEBUG(10,("cli_samr_enum_als_groups starting at index %u\n", (unsigned int)*start_idx));
350 /* Marshall data and send request */
352 init_samr_q_enum_dom_aliases(&q, pol, *start_idx, size);
354 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ENUM_DOM_ALIASES,
357 samr_io_q_enum_dom_aliases,
358 samr_io_r_enum_dom_aliases,
359 NT_STATUS_UNSUCCESSFUL);
361 /* Return output parameters */
365 if (!NT_STATUS_IS_OK(result) &&
366 NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
370 *num_dom_aliases = r.num_entries2;
372 if (*num_dom_aliases == 0)
375 if (!((*dom_aliases) = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_dom_aliases))) {
376 result = NT_STATUS_NO_MEMORY;
380 memset(*dom_aliases, 0, sizeof(struct acct_info) * *num_dom_aliases);
384 for (i = 0; i < *num_dom_aliases; i++) {
386 (*dom_aliases)[i].rid = r.sam[i].rid;
388 if (r.sam[i].hdr_name.buffer) {
389 unistr2_to_ascii((*dom_aliases)[i].acct_name,
390 &r.uni_grp_name[name_idx],
391 sizeof((*dom_aliases)[i].acct_name));
395 *start_idx = r.next_idx;
402 /* Query alias info */
404 NTSTATUS rpccli_samr_query_alias_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
405 POLICY_HND *alias_pol, uint16 switch_value,
408 prs_struct qbuf, rbuf;
409 SAMR_Q_QUERY_ALIASINFO q;
410 SAMR_R_QUERY_ALIASINFO r;
411 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
413 DEBUG(10,("cli_samr_query_alias_info\n"));
418 /* Marshall data and send request */
420 init_samr_q_query_aliasinfo(&q, alias_pol, switch_value);
422 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_ALIASINFO,
425 samr_io_q_query_aliasinfo,
426 samr_io_r_query_aliasinfo,
427 NT_STATUS_UNSUCCESSFUL);
429 /* Return output parameters */
431 if (!NT_STATUS_IS_OK(result = r.status)) {
442 /* User change password */
444 NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
446 const char *username,
447 const char *newpassword,
448 const char *oldpassword)
450 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
451 struct samr_CryptPassword new_nt_password;
452 struct samr_CryptPassword new_lm_password;
453 struct samr_Password old_nt_hash_enc;
454 struct samr_Password old_lanman_hash_enc;
456 uchar old_nt_hash[16];
457 uchar old_lanman_hash[16];
458 uchar new_nt_hash[16];
459 uchar new_lanman_hash[16];
460 struct lsa_String server, account;
461 char *srv_name_slash = NULL;
463 DEBUG(10,("rpccli_samr_chgpasswd_user\n"));
465 init_lsa_String(&server, srv_name_slash);
466 init_lsa_String(&account, username);
468 srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
469 if (!srv_name_slash) {
470 return NT_STATUS_NO_MEMORY;
473 /* Calculate the MD4 hash (NT compatible) of the password */
474 E_md4hash(oldpassword, old_nt_hash);
475 E_md4hash(newpassword, new_nt_hash);
477 if (lp_client_lanman_auth() &&
478 E_deshash(newpassword, new_lanman_hash) &&
479 E_deshash(oldpassword, old_lanman_hash)) {
480 /* E_deshash returns false for 'long' passwords (> 14
481 DOS chars). This allows us to match Win2k, which
482 does not store a LM hash for these passwords (which
483 would reduce the effective password length to 14) */
485 encode_pw_buffer(new_lm_password.data, newpassword, STR_UNICODE);
487 SamOEMhash(new_lm_password.data, old_nt_hash, 516);
488 E_old_pw_hash(new_nt_hash, old_lanman_hash, old_lanman_hash_enc.hash);
490 ZERO_STRUCT(new_lm_password);
491 ZERO_STRUCT(old_lanman_hash_enc);
494 encode_pw_buffer(new_nt_password.data, newpassword, STR_UNICODE);
496 SamOEMhash(new_nt_password.data, old_nt_hash, 516);
497 E_old_pw_hash(new_nt_hash, old_nt_hash, old_nt_hash_enc.hash);
499 result = rpccli_samr_ChangePasswordUser2(cli, mem_ctx,
506 &old_lanman_hash_enc);
511 /* User change password given blobs */
513 NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
515 const char *username,
516 DATA_BLOB new_nt_password_blob,
517 DATA_BLOB old_nt_hash_enc_blob,
518 DATA_BLOB new_lm_password_blob,
519 DATA_BLOB old_lm_hash_enc_blob)
521 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
522 struct samr_CryptPassword new_nt_password;
523 struct samr_CryptPassword new_lm_password;
524 struct samr_Password old_nt_hash_enc;
525 struct samr_Password old_lm_hash_enc;
526 struct lsa_String server, account;
527 char *srv_name_slash = NULL;
529 DEBUG(10,("rpccli_samr_chng_pswd_auth_crap\n"));
531 srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
532 if (!srv_name_slash) {
533 return NT_STATUS_NO_MEMORY;
536 init_lsa_String(&server, srv_name_slash);
537 init_lsa_String(&account, username);
539 memcpy(&new_nt_password.data, new_nt_password_blob.data, 516);
540 memcpy(&new_lm_password.data, new_lm_password_blob.data, 516);
541 memcpy(&old_nt_hash_enc.hash, old_nt_hash_enc_blob.data, 16);
542 memcpy(&old_lm_hash_enc.hash, old_lm_hash_enc_blob.data, 16);
544 result = rpccli_samr_ChangePasswordUser2(cli, mem_ctx,
556 /* change password 3 */
558 NTSTATUS rpccli_samr_chgpasswd3(struct rpc_pipe_client *cli,
560 const char *username,
561 const char *newpassword,
562 const char *oldpassword,
563 struct samr_DomInfo1 **dominfo1,
564 struct samr_ChangeReject **reject)
568 struct samr_CryptPassword new_nt_password;
569 struct samr_CryptPassword new_lm_password;
570 struct samr_Password old_nt_hash_enc;
571 struct samr_Password old_lanman_hash_enc;
573 uchar old_nt_hash[16];
574 uchar old_lanman_hash[16];
575 uchar new_nt_hash[16];
576 uchar new_lanman_hash[16];
578 struct lsa_String server, account;
579 char *srv_name_slash = NULL;
581 DEBUG(10,("rpccli_samr_chgpasswd_user3\n"));
583 srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
584 if (!srv_name_slash) {
585 return NT_STATUS_NO_MEMORY;
588 init_lsa_String(&server, srv_name_slash);
589 init_lsa_String(&account, username);
591 /* Calculate the MD4 hash (NT compatible) of the password */
592 E_md4hash(oldpassword, old_nt_hash);
593 E_md4hash(newpassword, new_nt_hash);
595 if (lp_client_lanman_auth() &&
596 E_deshash(newpassword, new_lanman_hash) &&
597 E_deshash(oldpassword, old_lanman_hash)) {
598 /* E_deshash returns false for 'long' passwords (> 14
599 DOS chars). This allows us to match Win2k, which
600 does not store a LM hash for these passwords (which
601 would reduce the effective password length to 14) */
603 encode_pw_buffer(new_lm_password.data, newpassword, STR_UNICODE);
605 SamOEMhash(new_lm_password.data, old_nt_hash, 516);
606 E_old_pw_hash(new_nt_hash, old_lanman_hash, old_lanman_hash_enc.hash);
608 ZERO_STRUCT(new_lm_password);
609 ZERO_STRUCT(old_lanman_hash_enc);
612 encode_pw_buffer(new_nt_password.data, newpassword, STR_UNICODE);
614 SamOEMhash(new_nt_password.data, old_nt_hash, 516);
615 E_old_pw_hash(new_nt_hash, old_nt_hash, old_nt_hash_enc.hash);
617 status = rpccli_samr_ChangePasswordUser3(cli, mem_ctx,
624 &old_lanman_hash_enc,
631 /* This function returns the bizzare set of (max_entries, max_size) required
632 for the QueryDisplayInfo RPC to actually work against a domain controller
633 with large (10k and higher) numbers of users. These values were
634 obtained by inspection using ethereal and NT4 running User Manager. */
636 void get_query_dispinfo_params(int loop_count, uint32 *max_entries,
656 default: /* loop_count >= 4 */
663 /* Query display info */
665 NTSTATUS rpccli_samr_query_dispinfo(struct rpc_pipe_client *cli,
667 POLICY_HND *domain_pol, uint32 *start_idx,
668 uint16 switch_value, uint32 *num_entries,
669 uint32 max_entries, uint32 max_size,
670 SAM_DISPINFO_CTR *ctr)
672 prs_struct qbuf, rbuf;
673 SAMR_Q_QUERY_DISPINFO q;
674 SAMR_R_QUERY_DISPINFO r;
675 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
677 DEBUG(10,("cli_samr_query_dispinfo for start_idx = %u\n", *start_idx));
684 /* Marshall data and send request */
686 init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
687 *start_idx, max_entries, max_size);
691 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO,
694 samr_io_q_query_dispinfo,
695 samr_io_r_query_dispinfo,
696 NT_STATUS_UNSUCCESSFUL);
698 /* Return output parameters */
702 if (!NT_STATUS_IS_OK(result) &&
703 NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
707 *num_entries = r.num_entries;
708 *start_idx += r.num_entries; /* No next_idx in this structure! */
714 /* Lookup rids. Note that NT4 seems to crash if more than ~1000 rids are
715 looked up in one packet. */
717 NTSTATUS rpccli_samr_lookup_rids(struct rpc_pipe_client *cli,
719 POLICY_HND *domain_pol,
720 uint32 num_rids, uint32 *rids,
721 uint32 *num_names, char ***names,
724 prs_struct qbuf, rbuf;
725 SAMR_Q_LOOKUP_RIDS q;
726 SAMR_R_LOOKUP_RIDS r;
727 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
730 DEBUG(10,("cli_samr_lookup_rids\n"));
732 if (num_rids > 1000) {
733 DEBUG(2, ("cli_samr_lookup_rids: warning: NT4 can crash if "
734 "more than ~1000 rids are looked up at once.\n"));
740 /* Marshall data and send request */
742 init_samr_q_lookup_rids(mem_ctx, &q, domain_pol, 1000, num_rids, rids);
744 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_LOOKUP_RIDS,
747 samr_io_q_lookup_rids,
748 samr_io_r_lookup_rids,
749 NT_STATUS_UNSUCCESSFUL);
751 /* Return output parameters */
755 if (!NT_STATUS_IS_OK(result) &&
756 !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
759 if (r.num_names1 == 0) {
765 *num_names = r.num_names1;
766 *names = TALLOC_ARRAY(mem_ctx, char *, r.num_names1);
767 *name_types = TALLOC_ARRAY(mem_ctx, uint32, r.num_names1);
769 if ((*names == NULL) || (*name_types == NULL)) {
771 TALLOC_FREE(*name_types);
772 return NT_STATUS_NO_MEMORY;
775 for (i = 0; i < r.num_names1; i++) {
778 unistr2_to_ascii(tmp, &r.uni_name[i], sizeof(tmp));
779 (*names)[i] = talloc_strdup(mem_ctx, tmp);
780 (*name_types)[i] = r.type[i];
790 NTSTATUS rpccli_samr_lookup_names(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
791 POLICY_HND *domain_pol, uint32 flags,
792 uint32 num_names, const char **names,
793 uint32 *num_rids, uint32 **rids,
796 prs_struct qbuf, rbuf;
797 SAMR_Q_LOOKUP_NAMES q;
798 SAMR_R_LOOKUP_NAMES r;
799 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
802 DEBUG(10,("cli_samr_lookup_names\n"));
807 /* Marshall data and send request */
809 init_samr_q_lookup_names(mem_ctx, &q, domain_pol, flags,
812 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_LOOKUP_NAMES,
815 samr_io_q_lookup_names,
816 samr_io_r_lookup_names,
817 NT_STATUS_UNSUCCESSFUL);
819 /* Return output parameters */
821 if (!NT_STATUS_IS_OK(result = r.status)) {
825 if (r.num_rids1 == 0) {
830 *num_rids = r.num_rids1;
831 *rids = TALLOC_ARRAY(mem_ctx, uint32, r.num_rids1);
832 *rid_types = TALLOC_ARRAY(mem_ctx, uint32, r.num_rids1);
834 if ((*rids == NULL) || (*rid_types == NULL)) {
836 TALLOC_FREE(*rid_types);
837 return NT_STATUS_NO_MEMORY;
840 for (i = 0; i < r.num_rids1; i++) {
841 (*rids)[i] = r.rids[i];
842 (*rid_types)[i] = r.types[i];
852 NTSTATUS rpccli_samr_set_userinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
853 const POLICY_HND *user_pol, uint16 switch_value,
854 DATA_BLOB *sess_key, SAM_USERINFO_CTR *ctr)
856 prs_struct qbuf, rbuf;
857 SAMR_Q_SET_USERINFO q;
858 SAMR_R_SET_USERINFO r;
859 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
861 DEBUG(10,("cli_samr_set_userinfo\n"));
866 if (!sess_key->length) {
867 DEBUG(1, ("No user session key\n"));
868 return NT_STATUS_NO_USER_SESSION_KEY;
871 /* Initialise parse structures */
873 prs_init(&qbuf, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
874 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
876 /* Marshall data and send request */
880 init_samr_q_set_userinfo(&q, user_pol, sess_key, switch_value,
883 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_SET_USERINFO,
886 samr_io_q_set_userinfo,
887 samr_io_r_set_userinfo,
888 NT_STATUS_UNSUCCESSFUL);
890 /* Return output parameters */
892 if (!NT_STATUS_IS_OK(result = r.status)) {
903 NTSTATUS rpccli_samr_set_userinfo2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
904 const POLICY_HND *user_pol, uint16 switch_value,
905 DATA_BLOB *sess_key, SAM_USERINFO_CTR *ctr)
907 prs_struct qbuf, rbuf;
908 SAMR_Q_SET_USERINFO2 q;
909 SAMR_R_SET_USERINFO2 r;
910 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
912 DEBUG(10,("cli_samr_set_userinfo2\n"));
914 if (!sess_key->length) {
915 DEBUG(1, ("No user session key\n"));
916 return NT_STATUS_NO_USER_SESSION_KEY;
922 /* Marshall data and send request */
924 init_samr_q_set_userinfo2(&q, user_pol, sess_key, switch_value, ctr);
926 CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_SET_USERINFO2,
929 samr_io_q_set_userinfo2,
930 samr_io_r_set_userinfo2,
931 NT_STATUS_UNSUCCESSFUL);
933 /* Return output parameters */
935 if (!NT_STATUS_IS_OK(result = r.status)) {