Add lsaaddpriv and lsadelpriv commands to rpcclient.
[samba.git] / source3 / rpcclient / cmd_lsarpc.c
1 /*
2    Unix SMB/CIFS implementation.
3    RPC pipe client
4
5    Copyright (C) Tim Potter              2000
6    Copyright (C) Rafal Szczesniak        2002
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "rpcclient.h"
24
25 /* useful function to allow entering a name instead of a SID and
26  * looking it up automatically */
27 static NTSTATUS name_to_sid(struct rpc_pipe_client *cli, 
28                             TALLOC_CTX *mem_ctx,
29                             DOM_SID *sid, const char *name)
30 {
31         POLICY_HND pol;
32         enum lsa_SidType *sid_types;
33         NTSTATUS result;
34         DOM_SID *sids;
35
36         /* maybe its a raw SID */
37         if (strncmp(name, "S-", 2) == 0 &&
38             string_to_sid(sid, name)) {
39                 return NT_STATUS_OK;
40         }
41
42         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
43                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
44                                      &pol);
45         if (!NT_STATUS_IS_OK(result))
46                 goto done;
47
48         result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);
49         if (!NT_STATUS_IS_OK(result))
50                 goto done;
51
52         rpccli_lsa_Close(cli, mem_ctx, &pol);
53
54         *sid = sids[0];
55
56 done:
57         return result;
58 }
59
60 static void display_query_info_1(struct lsa_AuditLogInfo *r)
61 {
62         d_printf("percent_full:\t%d\n", r->percent_full);
63         d_printf("log_size:\t%d\n", r->log_size);
64         d_printf("retention_time:\t%lld\n", (long long)r->retention_time);
65         d_printf("shutdown_in_progress:\t%d\n", r->shutdown_in_progress);
66         d_printf("time_to_shutdown:\t%lld\n", (long long)r->time_to_shutdown);
67         d_printf("next_audit_record:\t%d\n", r->next_audit_record);
68         d_printf("unknown:\t%d\n", r->unknown);
69 }
70
71 static void display_query_info_2(struct lsa_AuditEventsInfo *r)
72 {
73         int i;
74         d_printf("Auditing enabled:\t%d\n", r->auditing_mode);
75         d_printf("Auditing categories:\t%d\n", r->count);
76         d_printf("Auditsettings:\n");
77         for (i=0; i<r->count; i++) {
78                 const char *val = audit_policy_str(talloc_tos(), r->settings[i]);
79                 const char *policy = audit_description_str(i);
80                 d_printf("%s:\t%s\n", policy, val);
81         }
82 }
83
84 static void display_query_info_3(struct lsa_DomainInfo *r)
85 {
86         d_printf("Domain Name: %s\n", r->name.string);
87         d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
88 }
89
90 static void display_query_info_5(struct lsa_DomainInfo *r)
91 {
92         d_printf("Domain Name: %s\n", r->name.string);
93         d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
94 }
95
96 static void display_query_info_10(struct lsa_AuditFullSetInfo *r)
97 {
98         d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
99 }
100
101 static void display_query_info_11(struct lsa_AuditFullQueryInfo *r)
102 {
103         d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
104         d_printf("Log is full: %d\n", r->log_is_full);
105         d_printf("Unknown: %d\n", r->unknown);
106 }
107
108 static void display_query_info_12(struct lsa_DnsDomainInfo *r)
109 {
110         d_printf("Domain NetBios Name: %s\n", r->name.string);
111         d_printf("Domain DNS Name: %s\n", r->dns_domain.string);
112         d_printf("Domain Forest Name: %s\n", r->dns_forest.string);
113         d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
114         d_printf("Domain GUID: %s\n", smb_uuid_string(talloc_tos(),
115                                                       r->domain_guid));
116 }
117
118 static void display_lsa_query_info(union lsa_PolicyInformation *info,
119                                    enum lsa_PolicyInfo level)
120 {
121         switch (level) {
122                 case 1:
123                         display_query_info_1(&info->audit_log);
124                         break;
125                 case 2:
126                         display_query_info_2(&info->audit_events);
127                         break;
128                 case 3:
129                         display_query_info_3(&info->domain);
130                         break;
131                 case 5:
132                         display_query_info_5(&info->account_domain);
133                         break;
134                 case 10:
135                         display_query_info_10(&info->auditfullset);
136                         break;
137                 case 11:
138                         display_query_info_11(&info->auditfullquery);
139                         break;
140                 case 12:
141                         display_query_info_12(&info->dns);
142                         break;
143                 default:
144                         printf("can't display info level: %d\n", level);
145                         break;
146         }
147 }
148
149 static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli, 
150                                           TALLOC_CTX *mem_ctx, int argc, 
151                                           const char **argv) 
152 {
153         POLICY_HND pol;
154         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
155         union lsa_PolicyInformation *info = NULL;
156
157         uint32 info_class = 3;
158
159         if (argc > 2) {
160                 printf("Usage: %s [info_class]\n", argv[0]);
161                 return NT_STATUS_OK;
162         }
163
164         if (argc == 2)
165                 info_class = atoi(argv[1]);
166
167         switch (info_class) {
168         case 12:
169                 result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
170                                                  SEC_RIGHTS_MAXIMUM_ALLOWED,
171                                                  &pol);
172
173                 if (!NT_STATUS_IS_OK(result))
174                         goto done;
175                         
176                 result = rpccli_lsa_QueryInfoPolicy2(cli, mem_ctx,
177                                                      &pol,
178                                                      info_class,
179                                                      &info);
180                 break;
181         default:
182                 result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
183                                                 SEC_RIGHTS_MAXIMUM_ALLOWED,
184                                                 &pol);
185
186                 if (!NT_STATUS_IS_OK(result))
187                         goto done;
188                 
189                 result = rpccli_lsa_QueryInfoPolicy(cli, mem_ctx,
190                                                     &pol,
191                                                     info_class,
192                                                     &info);
193         }
194
195         if (NT_STATUS_IS_OK(result)) {
196                 display_lsa_query_info(info, info_class);
197         }
198
199         rpccli_lsa_Close(cli, mem_ctx, &pol);
200
201  done:
202         return result;
203 }
204
205 /* Resolve a list of names to a list of sids */
206
207 static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli, 
208                                      TALLOC_CTX *mem_ctx, int argc, 
209                                      const char **argv)
210 {
211         POLICY_HND pol;
212         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
213         DOM_SID *sids;
214         enum lsa_SidType *types;
215         int i;
216
217         if (argc == 1) {
218                 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
219                 return NT_STATUS_OK;
220         }
221
222         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
223                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
224                                      &pol);
225
226         if (!NT_STATUS_IS_OK(result))
227                 goto done;
228
229         result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1, 
230                                       (const char**)(argv + 1), NULL, 1, &sids, &types);
231
232         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 
233             NT_STATUS_V(STATUS_SOME_UNMAPPED))
234                 goto done;
235
236         result = NT_STATUS_OK;
237
238         /* Print results */
239
240         for (i = 0; i < (argc - 1); i++) {
241                 fstring sid_str;
242                 sid_to_fstring(sid_str, &sids[i]);
243                 printf("%s %s (%s: %d)\n", argv[i + 1], sid_str,
244                        sid_type_lookup(types[i]), types[i]);
245         }
246
247         rpccli_lsa_Close(cli, mem_ctx, &pol);
248
249  done:
250         return result;
251 }
252
253 /* Resolve a list of names to a list of sids */
254
255 static NTSTATUS cmd_lsa_lookup_names_level(struct rpc_pipe_client *cli, 
256                                            TALLOC_CTX *mem_ctx, int argc, 
257                                            const char **argv)
258 {
259         POLICY_HND pol;
260         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
261         DOM_SID *sids;
262         enum lsa_SidType *types;
263         int i, level;
264
265         if (argc < 3) {
266                 printf("Usage: %s [level] [name1 [name2 [...]]]\n", argv[0]);
267                 return NT_STATUS_OK;
268         }
269
270         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
271                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
272                                      &pol);
273
274         if (!NT_STATUS_IS_OK(result))
275                 goto done;
276
277         level = atoi(argv[1]);
278
279         result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2, 
280                                       (const char**)(argv + 2), NULL, level, &sids, &types);
281
282         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 
283             NT_STATUS_V(STATUS_SOME_UNMAPPED))
284                 goto done;
285
286         result = NT_STATUS_OK;
287
288         /* Print results */
289
290         for (i = 0; i < (argc - 2); i++) {
291                 fstring sid_str;
292                 sid_to_fstring(sid_str, &sids[i]);
293                 printf("%s %s (%s: %d)\n", argv[i + 2], sid_str,
294                        sid_type_lookup(types[i]), types[i]);
295         }
296
297         rpccli_lsa_Close(cli, mem_ctx, &pol);
298
299  done:
300         return result;
301 }
302
303
304 /* Resolve a list of SIDs to a list of names */
305
306 static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
307                                     int argc, const char **argv)
308 {
309         POLICY_HND pol;
310         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
311         DOM_SID *sids;
312         char **domains;
313         char **names;
314         enum lsa_SidType *types;
315         int i;
316
317         if (argc == 1) {
318                 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
319                 return NT_STATUS_OK;
320         }
321
322         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
323                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
324                                      &pol);
325
326         if (!NT_STATUS_IS_OK(result))
327                 goto done;
328
329         /* Convert arguments to sids */
330
331         sids = TALLOC_ARRAY(mem_ctx, DOM_SID, argc - 1);
332
333         if (!sids) {
334                 printf("could not allocate memory for %d sids\n", argc - 1);
335                 goto done;
336         }
337
338         for (i = 0; i < argc - 1; i++) 
339                 if (!string_to_sid(&sids[i], argv[i + 1])) {
340                         result = NT_STATUS_INVALID_SID;
341                         goto done;
342                 }
343
344         /* Lookup the SIDs */
345
346         result = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids, 
347                                      &domains, &names, &types);
348
349         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 
350             NT_STATUS_V(STATUS_SOME_UNMAPPED))
351                 goto done;
352
353         result = NT_STATUS_OK;
354
355         /* Print results */
356
357         for (i = 0; i < (argc - 1); i++) {
358                 fstring sid_str;
359
360                 sid_to_fstring(sid_str, &sids[i]);
361                 printf("%s %s\\%s (%d)\n", sid_str, 
362                        domains[i] ? domains[i] : "*unknown*", 
363                        names[i] ? names[i] : "*unknown*", types[i]);
364         }
365
366         rpccli_lsa_Close(cli, mem_ctx, &pol);
367
368  done:
369         return result;
370 }
371
372 /* Enumerate list of trusted domains */
373
374 static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, 
375                                        TALLOC_CTX *mem_ctx, int argc, 
376                                        const char **argv)
377 {
378         POLICY_HND pol;
379         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
380         struct lsa_DomainList domain_list;
381
382         /* defaults, but may be changed using params */
383         uint32 enum_ctx = 0;
384         int i;
385         uint32_t max_size = (uint32_t)-1;
386
387         if (argc > 2) {
388                 printf("Usage: %s [enum context (0)]\n", argv[0]);
389                 return NT_STATUS_OK;
390         }
391
392         if (argc == 2 && argv[1]) {
393                 enum_ctx = atoi(argv[2]);
394         }       
395
396         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
397                                      POLICY_VIEW_LOCAL_INFORMATION,
398                                      &pol);
399
400         if (!NT_STATUS_IS_OK(result))
401                 goto done;
402
403         result = STATUS_MORE_ENTRIES;
404
405         while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
406
407                 /* Lookup list of trusted domains */
408
409                 result = rpccli_lsa_EnumTrustDom(cli, mem_ctx,
410                                                  &pol,
411                                                  &enum_ctx,
412                                                  &domain_list,
413                                                  max_size);
414                 if (!NT_STATUS_IS_OK(result) &&
415                     !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
416                     !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
417                         goto done;
418
419                 /* Print results: list of names and sids returned in this
420                  * response. */  
421                 for (i = 0; i < domain_list.count; i++) {
422                         fstring sid_str;
423
424                         sid_to_fstring(sid_str, domain_list.domains[i].sid);
425                         printf("%s %s\n",
426                                 domain_list.domains[i].name.string ?
427                                 domain_list.domains[i].name.string : "*unknown*",
428                                 sid_str);
429                 }
430         }
431
432         rpccli_lsa_Close(cli, mem_ctx, &pol);
433  done:
434         return result;
435 }
436
437 /* Enumerates privileges */
438
439 static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli, 
440                                        TALLOC_CTX *mem_ctx, int argc, 
441                                        const char **argv) 
442 {
443         POLICY_HND pol;
444         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
445         struct lsa_PrivArray priv_array;
446
447         uint32 enum_context=0;
448         uint32 pref_max_length=0x1000;
449         int i;
450
451         if (argc > 3) {
452                 printf("Usage: %s [enum context] [max length]\n", argv[0]);
453                 return NT_STATUS_OK;
454         }
455
456         if (argc>=2)
457                 enum_context=atoi(argv[1]);
458
459         if (argc==3)
460                 pref_max_length=atoi(argv[2]);
461
462         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
463                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
464                                      &pol);
465
466         if (!NT_STATUS_IS_OK(result))
467                 goto done;
468
469         result = rpccli_lsa_EnumPrivs(cli, mem_ctx,
470                                       &pol,
471                                       &enum_context,
472                                       &priv_array,
473                                       pref_max_length);
474         if (!NT_STATUS_IS_OK(result))
475                 goto done;
476
477         /* Print results */
478         printf("found %d privileges\n\n", priv_array.count);
479
480         for (i = 0; i < priv_array.count; i++) {
481                 printf("%s \t\t%d:%d (0x%x:0x%x)\n",
482                        priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*",
483                        priv_array.privs[i].luid.high,
484                        priv_array.privs[i].luid.low,
485                        priv_array.privs[i].luid.high,
486                        priv_array.privs[i].luid.low);
487         }
488
489         rpccli_lsa_Close(cli, mem_ctx, &pol);
490  done:
491         return result;
492 }
493
494 /* Get privilege name */
495
496 static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli, 
497                                      TALLOC_CTX *mem_ctx, int argc, 
498                                      const char **argv) 
499 {
500         POLICY_HND pol;
501         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
502
503         uint16 lang_id=0;
504         uint16 lang_id_sys=0;
505         uint16 lang_id_desc;
506         struct lsa_String lsa_name;
507         struct lsa_StringLarge *description = NULL;
508
509         if (argc != 2) {
510                 printf("Usage: %s privilege name\n", argv[0]);
511                 return NT_STATUS_OK;
512         }
513
514         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
515                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
516                                      &pol);
517
518         if (!NT_STATUS_IS_OK(result))
519                 goto done;
520
521         init_lsa_String(&lsa_name, argv[1]);
522
523         result = rpccli_lsa_LookupPrivDisplayName(cli, mem_ctx,
524                                                   &pol,
525                                                   &lsa_name,
526                                                   lang_id,
527                                                   lang_id_sys,
528                                                   &description,
529                                                   &lang_id_desc);
530
531         if (!NT_STATUS_IS_OK(result))
532                 goto done;
533
534         /* Print results */
535         printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
536
537         rpccli_lsa_Close(cli, mem_ctx, &pol);
538  done:
539         return result;
540 }
541
542 /* Enumerate the LSA SIDS */
543
544 static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, 
545                                   TALLOC_CTX *mem_ctx, int argc, 
546                                   const char **argv) 
547 {
548         POLICY_HND pol;
549         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
550
551         uint32 enum_context=0;
552         uint32 pref_max_length=0x1000;
553         struct lsa_SidArray sid_array;
554         int i;
555
556         if (argc > 3) {
557                 printf("Usage: %s [enum context] [max length]\n", argv[0]);
558                 return NT_STATUS_OK;
559         }
560
561         if (argc>=2)
562                 enum_context=atoi(argv[1]);
563
564         if (argc==3)
565                 pref_max_length=atoi(argv[2]);
566
567         result = rpccli_lsa_open_policy(cli, mem_ctx, True, 
568                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
569                                      &pol);
570
571         if (!NT_STATUS_IS_OK(result))
572                 goto done;
573
574         result = rpccli_lsa_EnumAccounts(cli, mem_ctx,
575                                          &pol,
576                                          &enum_context,
577                                          &sid_array,
578                                          pref_max_length);
579
580         if (!NT_STATUS_IS_OK(result))
581                 goto done;
582
583         /* Print results */
584         printf("found %d SIDs\n\n", sid_array.num_sids);
585
586         for (i = 0; i < sid_array.num_sids; i++) {
587                 fstring sid_str;
588
589                 sid_to_fstring(sid_str, sid_array.sids[i].sid);
590                 printf("%s\n", sid_str);
591         }
592
593         rpccli_lsa_Close(cli, mem_ctx, &pol);
594  done:
595         return result;
596 }
597
598 /* Create a new account */
599
600 static NTSTATUS cmd_lsa_create_account(struct rpc_pipe_client *cli, 
601                                            TALLOC_CTX *mem_ctx, int argc, 
602                                            const char **argv) 
603 {
604         POLICY_HND dom_pol;
605         POLICY_HND user_pol;
606         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
607         uint32 des_access = 0x000f000f;
608         
609         DOM_SID sid;
610
611         if (argc != 2 ) {
612                 printf("Usage: %s SID\n", argv[0]);
613                 return NT_STATUS_OK;
614         }
615
616         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
617         if (!NT_STATUS_IS_OK(result))
618                 goto done;      
619
620         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
621                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
622                                      &dom_pol);
623
624         if (!NT_STATUS_IS_OK(result))
625                 goto done;
626
627         result = rpccli_lsa_CreateAccount(cli, mem_ctx,
628                                           &dom_pol,
629                                           &sid,
630                                           des_access,
631                                           &user_pol);
632
633         if (!NT_STATUS_IS_OK(result))
634                 goto done;
635
636         printf("Account for SID %s successfully created\n\n", argv[1]);
637         result = NT_STATUS_OK;
638
639         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
640  done:
641         return result;
642 }
643
644
645 /* Enumerate the privileges of an SID */
646
647 static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, 
648                                            TALLOC_CTX *mem_ctx, int argc, 
649                                            const char **argv) 
650 {
651         POLICY_HND dom_pol;
652         POLICY_HND user_pol;
653         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
654         uint32 access_desired = 0x000f000f;
655         DOM_SID sid;
656         struct lsa_PrivilegeSet *privs = NULL;
657         int i;
658
659         if (argc != 2 ) {
660                 printf("Usage: %s SID\n", argv[0]);
661                 return NT_STATUS_OK;
662         }
663
664         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
665         if (!NT_STATUS_IS_OK(result))
666                 goto done;      
667
668         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
669                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
670                                      &dom_pol);
671
672         if (!NT_STATUS_IS_OK(result))
673                 goto done;
674
675         result = rpccli_lsa_OpenAccount(cli, mem_ctx,
676                                         &dom_pol,
677                                         &sid,
678                                         access_desired,
679                                         &user_pol);
680
681         if (!NT_STATUS_IS_OK(result))
682                 goto done;
683
684         result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx,
685                                              &user_pol,
686                                              &privs);
687
688         if (!NT_STATUS_IS_OK(result))
689                 goto done;
690
691         /* Print results */
692         printf("found %d privileges for SID %s\n\n", privs->count, argv[1]);
693         printf("high\tlow\tattribute\n");
694
695         for (i = 0; i < privs->count; i++) {
696                 printf("%u\t%u\t%u\n",
697                         privs->set[i].luid.high,
698                         privs->set[i].luid.low,
699                         privs->set[i].attribute);
700         }
701
702         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
703  done:
704         return result;
705 }
706
707
708 /* Enumerate the privileges of an SID via LsaEnumerateAccountRights */
709
710 static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli, 
711                                          TALLOC_CTX *mem_ctx, int argc, 
712                                          const char **argv) 
713 {
714         POLICY_HND dom_pol;
715         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
716
717         DOM_SID sid;
718         uint32 count;
719         char **rights;
720
721         int i;
722
723         if (argc != 2 ) {
724                 printf("Usage: %s SID\n", argv[0]);
725                 return NT_STATUS_OK;
726         }
727
728         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
729         if (!NT_STATUS_IS_OK(result))
730                 goto done;      
731
732         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
733                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
734                                      &dom_pol);
735
736         if (!NT_STATUS_IS_OK(result))
737                 goto done;
738
739         result = rpccli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights);
740
741         if (!NT_STATUS_IS_OK(result))
742                 goto done;
743
744         printf("found %d privileges for SID %s\n", count,
745                sid_string_tos(&sid));
746
747         for (i = 0; i < count; i++) {
748                 printf("\t%s\n", rights[i]);
749         }
750
751         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
752  done:
753         return result;
754 }
755
756
757 /* add some privileges to a SID via LsaAddAccountRights */
758
759 static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli, 
760                                         TALLOC_CTX *mem_ctx, int argc, 
761                                         const char **argv) 
762 {
763         POLICY_HND dom_pol;
764         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
765
766         DOM_SID sid;
767
768         if (argc < 3 ) {
769                 printf("Usage: %s SID [rights...]\n", argv[0]);
770                 return NT_STATUS_OK;
771         }
772
773         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
774         if (!NT_STATUS_IS_OK(result))
775                 goto done;      
776
777         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
778                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
779                                      &dom_pol);
780
781         if (!NT_STATUS_IS_OK(result))
782                 goto done;
783
784         result = rpccli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid, 
785                                             argc-2, argv+2);
786
787         if (!NT_STATUS_IS_OK(result))
788                 goto done;
789
790         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
791  done:
792         return result;
793 }
794
795
796 /* remove some privileges to a SID via LsaRemoveAccountRights */
797
798 static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli, 
799                                         TALLOC_CTX *mem_ctx, int argc, 
800                                         const char **argv) 
801 {
802         POLICY_HND dom_pol;
803         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
804
805         DOM_SID sid;
806
807         if (argc < 3 ) {
808                 printf("Usage: %s SID [rights...]\n", argv[0]);
809                 return NT_STATUS_OK;
810         }
811
812         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
813         if (!NT_STATUS_IS_OK(result))
814                 goto done;      
815
816         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
817                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
818                                      &dom_pol);
819
820         if (!NT_STATUS_IS_OK(result))
821                 goto done;
822
823         result = rpccli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid, 
824                                                False, argc-2, argv+2);
825
826         if (!NT_STATUS_IS_OK(result))
827                 goto done;
828
829         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
830
831  done:
832         return result;
833 }
834
835
836 /* Get a privilege value given its name */
837
838 static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli, 
839                                         TALLOC_CTX *mem_ctx, int argc, 
840                                         const char **argv) 
841 {
842         POLICY_HND pol;
843         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
844         struct lsa_LUID luid;
845         struct lsa_String name;
846
847         if (argc != 2 ) {
848                 printf("Usage: %s name\n", argv[0]);
849                 return NT_STATUS_OK;
850         }
851
852         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
853                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
854                                      &pol);
855
856         if (!NT_STATUS_IS_OK(result))
857                 goto done;
858
859         init_lsa_String(&name, argv[1]);
860
861         result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
862                                             &pol,
863                                             &name,
864                                             &luid);
865
866         if (!NT_STATUS_IS_OK(result))
867                 goto done;
868
869         /* Print results */
870
871         printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low);
872
873         rpccli_lsa_Close(cli, mem_ctx, &pol);
874  done:
875         return result;
876 }
877
878 /* Query LSA security object */
879
880 static NTSTATUS cmd_lsa_query_secobj(struct rpc_pipe_client *cli, 
881                                      TALLOC_CTX *mem_ctx, int argc, 
882                                      const char **argv) 
883 {
884         POLICY_HND pol;
885         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
886         SEC_DESC_BUF *sdb;
887         uint32 sec_info = DACL_SECURITY_INFORMATION;
888
889         if (argc < 1 || argc > 2) {
890                 printf("Usage: %s [sec_info]\n", argv[0]);
891                 return NT_STATUS_OK;
892         }
893
894         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, 
895                                       SEC_RIGHTS_MAXIMUM_ALLOWED,
896                                       &pol);
897
898         if (argc == 2) 
899                 sscanf(argv[1], "%x", &sec_info);
900
901         if (!NT_STATUS_IS_OK(result))
902                 goto done;
903
904         result = rpccli_lsa_QuerySecurity(cli, mem_ctx,
905                                           &pol,
906                                           sec_info,
907                                           &sdb);
908         if (!NT_STATUS_IS_OK(result))
909                 goto done;
910
911         /* Print results */
912
913         display_sec_desc(sdb->sd);
914
915         rpccli_lsa_Close(cli, mem_ctx, &pol);
916  done:
917         return result;
918 }
919
920 static void display_trust_dom_info_4(struct lsa_TrustDomainInfoPassword *p, const char *password)
921 {
922         char *pwd, *pwd_old;
923         
924         DATA_BLOB data     = data_blob(NULL, p->password->length);
925         DATA_BLOB data_old = data_blob(NULL, p->old_password->length);
926
927         memcpy(data.data, p->password->data, p->password->length);
928         memcpy(data_old.data, p->old_password->data, p->old_password->length);
929         
930         pwd     = decrypt_trustdom_secret(password, &data);
931         pwd_old = decrypt_trustdom_secret(password, &data_old);
932         
933         d_printf("Password:\t%s\n", pwd);
934         d_printf("Old Password:\t%s\n", pwd_old);
935
936         SAFE_FREE(pwd);
937         SAFE_FREE(pwd_old);
938         
939         data_blob_free(&data);
940         data_blob_free(&data_old);
941 }
942
943 static void display_trust_dom_info(TALLOC_CTX *mem_ctx,
944                                    union lsa_TrustedDomainInfo *info,
945                                    enum lsa_TrustDomInfoEnum info_class,
946                                    const char *pass)
947 {
948         switch (info_class) {
949                 case LSA_TRUSTED_DOMAIN_INFO_PASSWORD:
950                         display_trust_dom_info_4(&info->password, pass);
951                         break;
952                 default: {
953                         const char *str = NULL;
954                         str = NDR_PRINT_UNION_STRING(mem_ctx,
955                                                      lsa_TrustedDomainInfo,
956                                                      info_class, info);
957                         if (str) {
958                                 d_printf("%s\n", str);
959                         }
960                         break;
961                 }
962         }
963 }
964
965 static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
966                                                 TALLOC_CTX *mem_ctx, int argc, 
967                                                 const char **argv) 
968 {
969         POLICY_HND pol;
970         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
971         DOM_SID dom_sid;
972         uint32 access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
973         union lsa_TrustedDomainInfo info;
974         enum lsa_TrustDomInfoEnum info_class = 1;
975
976         if (argc > 3 || argc < 2) {
977                 printf("Usage: %s [sid] [info_class]\n", argv[0]);
978                 return NT_STATUS_OK;
979         }
980
981         if (!string_to_sid(&dom_sid, argv[1]))
982                 return NT_STATUS_NO_MEMORY;
983
984         if (argc == 3)
985                 info_class = atoi(argv[2]);
986
987         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
988
989         if (!NT_STATUS_IS_OK(result))
990                 goto done;
991
992         result = rpccli_lsa_QueryTrustedDomainInfoBySid(cli, mem_ctx,
993                                                         &pol,
994                                                         &dom_sid,
995                                                         info_class,
996                                                         &info);
997         if (!NT_STATUS_IS_OK(result))
998                 goto done;
999
1000         display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
1001
1002  done:
1003         rpccli_lsa_Close(cli, mem_ctx, &pol);
1004
1005         return result;
1006 }
1007
1008 static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
1009                                                  TALLOC_CTX *mem_ctx, int argc,
1010                                                  const char **argv) 
1011 {
1012         POLICY_HND pol;
1013         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1014         uint32 access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
1015         union lsa_TrustedDomainInfo info;
1016         enum lsa_TrustDomInfoEnum info_class = 1;
1017         struct lsa_String trusted_domain;
1018
1019         if (argc > 3 || argc < 2) {
1020                 printf("Usage: %s [name] [info_class]\n", argv[0]);
1021                 return NT_STATUS_OK;
1022         }
1023
1024         if (argc == 3)
1025                 info_class = atoi(argv[2]);
1026
1027         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1028
1029         if (!NT_STATUS_IS_OK(result))
1030                 goto done;
1031
1032         init_lsa_String(&trusted_domain, argv[1]);
1033
1034         result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx,
1035                                                          &pol,
1036                                                          &trusted_domain,
1037                                                          info_class,
1038                                                          &info);
1039         if (!NT_STATUS_IS_OK(result))
1040                 goto done;
1041
1042         display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
1043
1044  done:
1045         rpccli_lsa_Close(cli, mem_ctx, &pol);
1046
1047         return result;
1048 }
1049
1050 static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli,
1051                                            TALLOC_CTX *mem_ctx, int argc,
1052                                            const char **argv) 
1053 {
1054         POLICY_HND pol, trustdom_pol;
1055         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1056         uint32 access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
1057         union lsa_TrustedDomainInfo info;
1058         DOM_SID dom_sid;
1059         enum lsa_TrustDomInfoEnum info_class = 1;
1060
1061         if (argc > 3 || argc < 2) {
1062                 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1063                 return NT_STATUS_OK;
1064         }
1065
1066         if (!string_to_sid(&dom_sid, argv[1]))
1067                 return NT_STATUS_NO_MEMORY;
1068
1069
1070         if (argc == 3)
1071                 info_class = atoi(argv[2]);
1072
1073         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1074
1075         if (!NT_STATUS_IS_OK(result))
1076                 goto done;
1077
1078         result = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,
1079                                               &pol,
1080                                               &dom_sid,
1081                                               access_mask,
1082                                               &trustdom_pol);
1083
1084         if (!NT_STATUS_IS_OK(result))
1085                 goto done;
1086
1087         result = rpccli_lsa_QueryTrustedDomainInfo(cli, mem_ctx,
1088                                                    &trustdom_pol,
1089                                                    info_class,
1090                                                    &info);
1091
1092         if (!NT_STATUS_IS_OK(result))
1093                 goto done;
1094
1095         display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
1096
1097  done:
1098         rpccli_lsa_Close(cli, mem_ctx, &pol);
1099
1100         return result;
1101 }
1102
1103 static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli,
1104                                      TALLOC_CTX *mem_ctx, int argc,
1105                                      const char **argv)
1106 {
1107         POLICY_HND pol;
1108         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1109         const char *servername = cli->cli->desthost;
1110         struct lsa_String *account_name = NULL;
1111         struct lsa_String *authority_name = NULL;
1112
1113         if (argc > 2) {
1114                 printf("Usage: %s servername\n", argv[0]);
1115                 return NT_STATUS_OK;
1116         }
1117
1118         result = rpccli_lsa_open_policy(cli, mem_ctx, true,
1119                                         SEC_RIGHTS_MAXIMUM_ALLOWED,
1120                                         &pol);
1121
1122         if (!NT_STATUS_IS_OK(result)) {
1123                 goto done;
1124         }
1125
1126         result = rpccli_lsa_GetUserName(cli, mem_ctx,
1127                                         servername,
1128                                         &account_name,
1129                                         &authority_name);
1130         if (!NT_STATUS_IS_OK(result)) {
1131                 goto done;
1132         }
1133
1134         /* Print results */
1135
1136         printf("Account Name: %s, Authority Name: %s\n",
1137                 account_name->string, authority_name->string);
1138
1139         rpccli_lsa_Close(cli, mem_ctx, &pol);
1140  done:
1141         return result;
1142 }
1143
1144 static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli,
1145                                  TALLOC_CTX *mem_ctx, int argc,
1146                                  const char **argv)
1147 {
1148         POLICY_HND dom_pol, user_pol;
1149         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1150         struct lsa_PrivilegeSet privs;
1151         struct lsa_LUIDAttribute *set = NULL;
1152         DOM_SID sid;
1153         int i;
1154
1155         ZERO_STRUCT(privs);
1156
1157         if (argc < 3 ) {
1158                 printf("Usage: %s SID [rights...]\n", argv[0]);
1159                 return NT_STATUS_OK;
1160         }
1161
1162         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1163         if (!NT_STATUS_IS_OK(result)) {
1164                 goto done;
1165         }
1166
1167         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1168                                          SEC_RIGHTS_MAXIMUM_ALLOWED,
1169                                          &dom_pol);
1170
1171         if (!NT_STATUS_IS_OK(result)) {
1172                 goto done;
1173         }
1174
1175         result = rpccli_lsa_OpenAccount(cli, mem_ctx,
1176                                         &dom_pol,
1177                                         &sid,
1178                                         SEC_RIGHTS_MAXIMUM_ALLOWED,
1179                                         &user_pol);
1180
1181         if (!NT_STATUS_IS_OK(result)) {
1182                 goto done;
1183         }
1184
1185         for (i=2; i<argc; i++) {
1186
1187                 struct lsa_String priv_name;
1188                 struct lsa_LUID luid;
1189
1190                 init_lsa_String(&priv_name, argv[i]);
1191
1192                 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
1193                                                     &dom_pol,
1194                                                     &priv_name,
1195                                                     &luid);
1196                 if (!NT_STATUS_IS_OK(result)) {
1197                         continue;
1198                 }
1199
1200                 privs.count++;
1201                 set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
1202                                            struct lsa_LUIDAttribute,
1203                                            privs.count);
1204                 if (!set) {
1205                         return NT_STATUS_NO_MEMORY;
1206                 }
1207
1208                 set[privs.count-1].luid = luid;
1209                 set[privs.count-1].attribute = 0;
1210         }
1211
1212         privs.set = set;
1213
1214         result = rpccli_lsa_AddPrivilegesToAccount(cli, mem_ctx,
1215                                                    &user_pol,
1216                                                    &privs);
1217
1218         if (!NT_STATUS_IS_OK(result)) {
1219                 goto done;
1220         }
1221
1222         rpccli_lsa_Close(cli, mem_ctx, &user_pol);
1223         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
1224  done:
1225         return result;
1226 }
1227
1228 static NTSTATUS cmd_lsa_del_priv(struct rpc_pipe_client *cli,
1229                                  TALLOC_CTX *mem_ctx, int argc,
1230                                  const char **argv)
1231 {
1232         POLICY_HND dom_pol, user_pol;
1233         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1234         struct lsa_PrivilegeSet privs;
1235         struct lsa_LUIDAttribute *set = NULL;
1236         DOM_SID sid;
1237         int i;
1238
1239         ZERO_STRUCT(privs);
1240
1241         if (argc < 3 ) {
1242                 printf("Usage: %s SID [rights...]\n", argv[0]);
1243                 return NT_STATUS_OK;
1244         }
1245
1246         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1247         if (!NT_STATUS_IS_OK(result)) {
1248                 goto done;
1249         }
1250
1251         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1252                                          SEC_RIGHTS_MAXIMUM_ALLOWED,
1253                                          &dom_pol);
1254
1255         if (!NT_STATUS_IS_OK(result)) {
1256                 goto done;
1257         }
1258
1259         result = rpccli_lsa_OpenAccount(cli, mem_ctx,
1260                                         &dom_pol,
1261                                         &sid,
1262                                         SEC_RIGHTS_MAXIMUM_ALLOWED,
1263                                         &user_pol);
1264
1265         if (!NT_STATUS_IS_OK(result)) {
1266                 goto done;
1267         }
1268
1269         for (i=2; i<argc; i++) {
1270
1271                 struct lsa_String priv_name;
1272                 struct lsa_LUID luid;
1273
1274                 init_lsa_String(&priv_name, argv[i]);
1275
1276                 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
1277                                                     &dom_pol,
1278                                                     &priv_name,
1279                                                     &luid);
1280                 if (!NT_STATUS_IS_OK(result)) {
1281                         continue;
1282                 }
1283
1284                 privs.count++;
1285                 set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
1286                                            struct lsa_LUIDAttribute,
1287                                            privs.count);
1288                 if (!set) {
1289                         return NT_STATUS_NO_MEMORY;
1290                 }
1291
1292                 set[privs.count-1].luid = luid;
1293                 set[privs.count-1].attribute = 0;
1294         }
1295
1296         privs.set = set;
1297
1298
1299         result = rpccli_lsa_RemovePrivilegesFromAccount(cli, mem_ctx,
1300                                                         &user_pol,
1301                                                         false,
1302                                                         &privs);
1303
1304         if (!NT_STATUS_IS_OK(result)) {
1305                 goto done;
1306         }
1307
1308         rpccli_lsa_Close(cli, mem_ctx, &user_pol);
1309         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
1310  done:
1311         return result;
1312 }
1313
1314
1315 /* List of commands exported by this module */
1316
1317 struct cmd_set lsarpc_commands[] = {
1318
1319         { "LSARPC" },
1320
1321         { "lsaquery",            RPC_RTYPE_NTSTATUS, cmd_lsa_query_info_policy,  NULL, PI_LSARPC, NULL, "Query info policy",                    "" },
1322         { "lookupsids",          RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids,        NULL, PI_LSARPC, NULL, "Convert SIDs to names",                "" },
1323         { "lookupnames",         RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names,       NULL, PI_LSARPC, NULL, "Convert names to SIDs",                "" },
1324         { "lookupnames_level",   RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names_level, NULL, PI_LSARPC, NULL, "Convert names to SIDs",                "" },
1325         { "enumtrust",           RPC_RTYPE_NTSTATUS, cmd_lsa_enum_trust_dom,     NULL, PI_LSARPC, NULL, "Enumerate trusted domains",            "Usage: [preferred max number] [enum context (0)]" },
1326         { "enumprivs",           RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privilege,     NULL, PI_LSARPC, NULL, "Enumerate privileges",                 "" },
1327         { "getdispname",         RPC_RTYPE_NTSTATUS, cmd_lsa_get_dispname,       NULL, PI_LSARPC, NULL, "Get the privilege name",               "" },
1328         { "lsaenumsid",          RPC_RTYPE_NTSTATUS, cmd_lsa_enum_sids,          NULL, PI_LSARPC, NULL, "Enumerate the LSA SIDS",               "" },
1329         { "lsacreateaccount",    RPC_RTYPE_NTSTATUS, cmd_lsa_create_account,     NULL, PI_LSARPC, NULL, "Create a new lsa account",   "" },
1330         { "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, PI_LSARPC, NULL, "Enumerate the privileges of an SID",   "" },
1331         { "lsaenumacctrights",   RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights,   NULL, PI_LSARPC, NULL, "Enumerate the rights of an SID",   "" },
1332         { "lsaaddpriv",          RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv,           NULL, PI_LSARPC, NULL, "Assign a privilege to a SID", "" },
1333         { "lsadelpriv",          RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv,           NULL, PI_LSARPC, NULL, "Revoke a privilege from a SID", "" },
1334         { "lsaaddacctrights",    RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights,    NULL, PI_LSARPC, NULL, "Add rights to an account",   "" },
1335         { "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, PI_LSARPC, NULL, "Remove rights from an account",   "" },
1336         { "lsalookupprivvalue",  RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_priv_value,  NULL, PI_LSARPC, NULL, "Get a privilege value given its name", "" },
1337         { "lsaquerysecobj",      RPC_RTYPE_NTSTATUS, cmd_lsa_query_secobj,       NULL, PI_LSARPC, NULL, "Query LSA security object", "" },
1338         { "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" },
1339         { "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" },
1340         { "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" },
1341         { "getusername",          RPC_RTYPE_NTSTATUS, cmd_lsa_get_username, NULL, PI_LSARPC, NULL, "Get username", "" },
1342
1343         { NULL }
1344 };
1345