r4933: List not only the first 10 trusts with rpcclient -c enumtrust.
[tprouty/samba.git] / source / 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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "rpcclient.h"
25
26
27 /* useful function to allow entering a name instead of a SID and
28  * looking it up automatically */
29 static NTSTATUS name_to_sid(struct cli_state *cli, 
30                             TALLOC_CTX *mem_ctx,
31                             DOM_SID *sid, const char *name)
32 {
33         POLICY_HND pol;
34         uint32 *sid_types;
35         NTSTATUS result;
36         DOM_SID *sids;
37
38         /* maybe its a raw SID */
39         if (strncmp(name, "S-", 2) == 0 &&
40             string_to_sid(sid, name)) {
41                 return NT_STATUS_OK;
42         }
43
44         result = cli_lsa_open_policy(cli, mem_ctx, True, 
45                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
46                                      &pol);
47         if (!NT_STATUS_IS_OK(result))
48                 goto done;
49
50         result = cli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, &sids, &sid_types);
51         if (!NT_STATUS_IS_OK(result))
52                 goto done;
53
54         cli_lsa_close(cli, mem_ctx, &pol);
55
56         *sid = sids[0];
57
58 done:
59         return result;
60 }
61
62
63 /* Look up domain related information on a remote host */
64
65 static NTSTATUS cmd_lsa_query_info_policy(struct cli_state *cli, 
66                                           TALLOC_CTX *mem_ctx, int argc, 
67                                           const char **argv) 
68 {
69         POLICY_HND pol;
70         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
71         DOM_SID *dom_sid;
72         struct uuid *dom_guid;
73         fstring sid_str;
74         char *domain_name = NULL;
75         char *dns_name = NULL;
76         char *forest_name = NULL;
77
78         uint32 info_class = 3;
79
80         if (argc > 2) {
81                 printf("Usage: %s [info_class]\n", argv[0]);
82                 return NT_STATUS_OK;
83         }
84
85         if (argc == 2)
86                 info_class = atoi(argv[1]);
87         
88         /* Lookup info policy */
89         switch (info_class) {
90         case 12:
91                 result = cli_lsa_open_policy2(cli, mem_ctx, True, 
92                                              SEC_RIGHTS_MAXIMUM_ALLOWED,
93                                              &pol);
94
95                 if (!NT_STATUS_IS_OK(result))
96                         goto done;
97                 result = cli_lsa_query_info_policy2(cli, mem_ctx, &pol,
98                                                     info_class, &domain_name,
99                                                     &dns_name, &forest_name,
100                                                     &dom_guid, &dom_sid);
101                 break;
102         default:
103                 result = cli_lsa_open_policy(cli, mem_ctx, True, 
104                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
105                                      &pol);
106
107                 if (!NT_STATUS_IS_OK(result))
108                         goto done;
109                 result = cli_lsa_query_info_policy(cli, mem_ctx, &pol, 
110                                                    info_class, &domain_name, 
111                                                    &dom_sid);
112         }
113
114         if (!NT_STATUS_IS_OK(result))
115                 goto done;
116         
117         sid_to_string(sid_str, dom_sid);
118
119         if (domain_name)
120                 printf("domain %s has sid %s\n", domain_name, sid_str);
121         else
122                 printf("could not query info for level %d\n", info_class);
123
124         if (dns_name)
125                 printf("domain dns name is %s\n", dns_name);
126         if (forest_name)
127                 printf("forest name is %s\n", forest_name);
128
129         if (info_class == 12) {
130                 printf("domain GUID is ");
131                 smb_uuid_string_static(*dom_guid);
132         }
133  done:
134         return result;
135 }
136
137 /* Resolve a list of names to a list of sids */
138
139 static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli, 
140                                      TALLOC_CTX *mem_ctx, int argc, 
141                                      const char **argv)
142 {
143         POLICY_HND pol;
144         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
145         DOM_SID *sids;
146         uint32 *types;
147         int i;
148
149         if (argc == 1) {
150                 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
151                 return NT_STATUS_OK;
152         }
153
154         result = cli_lsa_open_policy(cli, mem_ctx, True, 
155                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
156                                      &pol);
157
158         if (!NT_STATUS_IS_OK(result))
159                 goto done;
160
161         result = cli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1, 
162                                       (const char**)(argv + 1), &sids, &types);
163
164         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 
165             NT_STATUS_V(STATUS_SOME_UNMAPPED))
166                 goto done;
167
168         result = NT_STATUS_OK;
169
170         /* Print results */
171
172         for (i = 0; i < (argc - 1); i++) {
173                 fstring sid_str;
174                 sid_to_string(sid_str, &sids[i]);
175                 printf("%s %s (%s: %d)\n", argv[i + 1], sid_str,
176                        sid_type_lookup(types[i]), types[i]);
177         }
178
179  done:
180         return result;
181 }
182
183 /* Resolve a list of SIDs to a list of names */
184
185 static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx,
186                                     int argc, const char **argv)
187 {
188         POLICY_HND pol;
189         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
190         DOM_SID *sids;
191         char **domains;
192         char **names;
193         uint32 *types;
194         int i;
195
196         if (argc == 1) {
197                 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
198                 return NT_STATUS_OK;
199         }
200
201         result = cli_lsa_open_policy(cli, mem_ctx, True, 
202                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
203                                      &pol);
204
205         if (!NT_STATUS_IS_OK(result))
206                 goto done;
207
208         /* Convert arguments to sids */
209
210         sids = TALLOC_ARRAY(mem_ctx, DOM_SID, argc - 1);
211
212         if (!sids) {
213                 printf("could not allocate memory for %d sids\n", argc - 1);
214                 goto done;
215         }
216
217         for (i = 0; i < argc - 1; i++) 
218                 if (!string_to_sid(&sids[i], argv[i + 1])) {
219                         result = NT_STATUS_INVALID_SID;
220                         goto done;
221                 }
222
223         /* Lookup the SIDs */
224
225         result = cli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids, 
226                                      &domains, &names, &types);
227
228         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 
229             NT_STATUS_V(STATUS_SOME_UNMAPPED))
230                 goto done;
231
232         result = NT_STATUS_OK;
233
234         /* Print results */
235
236         for (i = 0; i < (argc - 1); i++) {
237                 fstring sid_str;
238
239                 sid_to_string(sid_str, &sids[i]);
240                 printf("%s %s\\%s (%d)\n", sid_str, 
241                        domains[i] ? domains[i] : "*unknown*", 
242                        names[i] ? names[i] : "*unknown*", types[i]);
243         }
244
245  done:
246         return result;
247 }
248
249 /* Enumerate list of trusted domains */
250
251 static NTSTATUS cmd_lsa_enum_trust_dom(struct cli_state *cli, 
252                                        TALLOC_CTX *mem_ctx, int argc, 
253                                        const char **argv)
254 {
255         POLICY_HND pol;
256         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
257         DOM_SID *domain_sids;
258         char **domain_names;
259
260         /* defaults, but may be changed using params */
261         uint32 enum_ctx = 0;
262         uint32 num_domains = 0;
263         int i;
264
265         if (argc > 2) {
266                 printf("Usage: %s [enum context (0)]\n", argv[0]);
267                 return NT_STATUS_OK;
268         }
269
270         if (argc == 2 && argv[1]) {
271                 enum_ctx = atoi(argv[2]);
272         }       
273
274         result = cli_lsa_open_policy(cli, mem_ctx, True, 
275                                      POLICY_VIEW_LOCAL_INFORMATION,
276                                      &pol);
277
278         if (!NT_STATUS_IS_OK(result))
279                 goto done;
280
281         result = STATUS_MORE_ENTRIES;
282
283         while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
284
285                 /* Lookup list of trusted domains */
286
287                 result = cli_lsa_enum_trust_dom(cli, mem_ctx, &pol, &enum_ctx,
288                                                 &num_domains,
289                                                 &domain_names, &domain_sids);
290                 if (!NT_STATUS_IS_OK(result) &&
291                     !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
292                     !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
293                         goto done;
294
295                 /* Print results: list of names and sids returned in this
296                  * response. */  
297                 for (i = 0; i < num_domains; i++) {
298                         fstring sid_str;
299
300                         sid_to_string(sid_str, &domain_sids[i]);
301                         printf("%s %s\n", domain_names[i] ? domain_names[i] : 
302                                "*unknown*", sid_str);
303                 }
304         }
305
306  done:
307         return result;
308 }
309
310 /* Enumerates privileges */
311
312 static NTSTATUS cmd_lsa_enum_privilege(struct cli_state *cli, 
313                                        TALLOC_CTX *mem_ctx, int argc, 
314                                        const char **argv) 
315 {
316         POLICY_HND pol;
317         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
318
319         uint32 enum_context=0;
320         uint32 pref_max_length=0x1000;
321         uint32 count=0;
322         char   **privs_name;
323         uint32 *privs_high;
324         uint32 *privs_low;
325         int i;
326
327         if (argc > 3) {
328                 printf("Usage: %s [enum context] [max length]\n", argv[0]);
329                 return NT_STATUS_OK;
330         }
331
332         if (argc>=2)
333                 enum_context=atoi(argv[1]);
334
335         if (argc==3)
336                 pref_max_length=atoi(argv[2]);
337
338         result = cli_lsa_open_policy(cli, mem_ctx, True, 
339                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
340                                      &pol);
341
342         if (!NT_STATUS_IS_OK(result))
343                 goto done;
344
345         result = cli_lsa_enum_privilege(cli, mem_ctx, &pol, &enum_context, pref_max_length,
346                                         &count, &privs_name, &privs_high, &privs_low);
347
348         if (!NT_STATUS_IS_OK(result))
349                 goto done;
350
351         /* Print results */
352         printf("found %d privileges\n\n", count);
353
354         for (i = 0; i < count; i++) {
355                 printf("%s \t\t%d:%d (0x%x:0x%x)\n", privs_name[i] ? privs_name[i] : "*unknown*",
356                        privs_high[i], privs_low[i], privs_high[i], privs_low[i]);
357         }
358
359  done:
360         return result;
361 }
362
363 /* Get privilege name */
364
365 static NTSTATUS cmd_lsa_get_dispname(struct cli_state *cli, 
366                                      TALLOC_CTX *mem_ctx, int argc, 
367                                      const char **argv) 
368 {
369         POLICY_HND pol;
370         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
371
372         uint16 lang_id=0;
373         uint16 lang_id_sys=0;
374         uint16 lang_id_desc;
375         fstring description;
376
377         if (argc != 2) {
378                 printf("Usage: %s privilege name\n", argv[0]);
379                 return NT_STATUS_OK;
380         }
381
382         result = cli_lsa_open_policy(cli, mem_ctx, True, 
383                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
384                                      &pol);
385
386         if (!NT_STATUS_IS_OK(result))
387                 goto done;
388
389         result = cli_lsa_get_dispname(cli, mem_ctx, &pol, argv[1], lang_id, lang_id_sys, description, &lang_id_desc);
390
391         if (!NT_STATUS_IS_OK(result))
392                 goto done;
393
394         /* Print results */
395         printf("%s -> %s (language: 0x%x)\n", argv[1], description, lang_id_desc);
396
397  done:
398         return result;
399 }
400
401 /* Enumerate the LSA SIDS */
402
403 static NTSTATUS cmd_lsa_enum_sids(struct cli_state *cli, 
404                                   TALLOC_CTX *mem_ctx, int argc, 
405                                   const char **argv) 
406 {
407         POLICY_HND pol;
408         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
409
410         uint32 enum_context=0;
411         uint32 pref_max_length=0x1000;
412         DOM_SID *sids;
413         uint32 count=0;
414         int i;
415
416         if (argc > 3) {
417                 printf("Usage: %s [enum context] [max length]\n", argv[0]);
418                 return NT_STATUS_OK;
419         }
420
421         if (argc>=2)
422                 enum_context=atoi(argv[1]);
423
424         if (argc==3)
425                 pref_max_length=atoi(argv[2]);
426
427         result = cli_lsa_open_policy(cli, mem_ctx, True, 
428                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
429                                      &pol);
430
431         if (!NT_STATUS_IS_OK(result))
432                 goto done;
433
434         result = cli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length,
435                                         &count, &sids);
436
437         if (!NT_STATUS_IS_OK(result))
438                 goto done;
439
440         /* Print results */
441         printf("found %d SIDs\n\n", count);
442
443         for (i = 0; i < count; i++) {
444                 fstring sid_str;
445
446                 sid_to_string(sid_str, &sids[i]);
447                 printf("%s\n", sid_str);
448         }
449
450  done:
451         return result;
452 }
453
454 /* Create a new account */
455
456 static NTSTATUS cmd_lsa_create_account(struct cli_state *cli, 
457                                            TALLOC_CTX *mem_ctx, int argc, 
458                                            const char **argv) 
459 {
460         POLICY_HND dom_pol;
461         POLICY_HND user_pol;
462         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
463         uint32 des_access = 0x000f000f;
464         
465         DOM_SID sid;
466
467         if (argc != 2 ) {
468                 printf("Usage: %s SID\n", argv[0]);
469                 return NT_STATUS_OK;
470         }
471
472         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
473         if (!NT_STATUS_IS_OK(result))
474                 goto done;      
475
476         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
477                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
478                                      &dom_pol);
479
480         if (!NT_STATUS_IS_OK(result))
481                 goto done;
482
483         result = cli_lsa_create_account(cli, mem_ctx, &dom_pol, &sid, des_access, &user_pol);
484
485         if (!NT_STATUS_IS_OK(result))
486                 goto done;
487
488         printf("Account for SID %s successfully created\n\n", argv[1]);
489         result = NT_STATUS_OK;
490
491  done:
492         return result;
493 }
494
495
496 /* Enumerate the privileges of an SID */
497
498 static NTSTATUS cmd_lsa_enum_privsaccounts(struct cli_state *cli, 
499                                            TALLOC_CTX *mem_ctx, int argc, 
500                                            const char **argv) 
501 {
502         POLICY_HND dom_pol;
503         POLICY_HND user_pol;
504         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
505         uint32 access_desired = 0x000f000f;
506         
507         DOM_SID sid;
508         uint32 count=0;
509         LUID_ATTR *set;
510         int i;
511
512         if (argc != 2 ) {
513                 printf("Usage: %s SID\n", argv[0]);
514                 return NT_STATUS_OK;
515         }
516
517         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
518         if (!NT_STATUS_IS_OK(result))
519                 goto done;      
520
521         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
522                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
523                                      &dom_pol);
524
525         if (!NT_STATUS_IS_OK(result))
526                 goto done;
527
528         result = cli_lsa_open_account(cli, mem_ctx, &dom_pol, &sid, access_desired, &user_pol);
529
530         if (!NT_STATUS_IS_OK(result))
531                 goto done;
532
533         result = cli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set);
534
535         if (!NT_STATUS_IS_OK(result))
536                 goto done;
537
538         /* Print results */
539         printf("found %d privileges for SID %s\n\n", count, argv[1]);
540         printf("high\tlow\tattribute\n");
541
542         for (i = 0; i < count; i++) {
543                 printf("%u\t%u\t%u\n", set[i].luid.high, set[i].luid.low, set[i].attr);
544         }
545
546  done:
547         return result;
548 }
549
550
551 /* Enumerate the privileges of an SID via LsaEnumerateAccountRights */
552
553 static NTSTATUS cmd_lsa_enum_acct_rights(struct cli_state *cli, 
554                                          TALLOC_CTX *mem_ctx, int argc, 
555                                          const char **argv) 
556 {
557         POLICY_HND dom_pol;
558         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
559
560         DOM_SID sid;
561         uint32 count;
562         char **rights;
563
564         int i;
565
566         if (argc != 2 ) {
567                 printf("Usage: %s SID\n", argv[0]);
568                 return NT_STATUS_OK;
569         }
570
571         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
572         if (!NT_STATUS_IS_OK(result))
573                 goto done;      
574
575         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
576                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
577                                      &dom_pol);
578
579         if (!NT_STATUS_IS_OK(result))
580                 goto done;
581
582         result = cli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights);
583
584         if (!NT_STATUS_IS_OK(result))
585                 goto done;
586
587         printf("found %d privileges for SID %s\n", count, sid_string_static(&sid));
588
589         for (i = 0; i < count; i++) {
590                 printf("\t%s\n", rights[i]);
591         }
592
593  done:
594         return result;
595 }
596
597
598 /* add some privileges to a SID via LsaAddAccountRights */
599
600 static NTSTATUS cmd_lsa_add_acct_rights(struct cli_state *cli, 
601                                         TALLOC_CTX *mem_ctx, int argc, 
602                                         const char **argv) 
603 {
604         POLICY_HND dom_pol;
605         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
606
607         DOM_SID sid;
608
609         if (argc < 3 ) {
610                 printf("Usage: %s SID [rights...]\n", argv[0]);
611                 return NT_STATUS_OK;
612         }
613
614         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
615         if (!NT_STATUS_IS_OK(result))
616                 goto done;      
617
618         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
619                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
620                                      &dom_pol);
621
622         if (!NT_STATUS_IS_OK(result))
623                 goto done;
624
625         result = cli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid, 
626                                             argc-2, argv+2);
627
628         if (!NT_STATUS_IS_OK(result))
629                 goto done;
630
631  done:
632         return result;
633 }
634
635
636 /* remove some privileges to a SID via LsaRemoveAccountRights */
637
638 static NTSTATUS cmd_lsa_remove_acct_rights(struct cli_state *cli, 
639                                         TALLOC_CTX *mem_ctx, int argc, 
640                                         const char **argv) 
641 {
642         POLICY_HND dom_pol;
643         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
644
645         DOM_SID sid;
646
647         if (argc < 3 ) {
648                 printf("Usage: %s SID [rights...]\n", argv[0]);
649                 return NT_STATUS_OK;
650         }
651
652         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
653         if (!NT_STATUS_IS_OK(result))
654                 goto done;      
655
656         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
657                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
658                                      &dom_pol);
659
660         if (!NT_STATUS_IS_OK(result))
661                 goto done;
662
663         result = cli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid, 
664                                                False, argc-2, argv+2);
665
666         if (!NT_STATUS_IS_OK(result))
667                 goto done;
668
669  done:
670         return result;
671 }
672
673
674 /* Get a privilege value given its name */
675
676 static NTSTATUS cmd_lsa_lookupprivvalue(struct cli_state *cli, 
677                                         TALLOC_CTX *mem_ctx, int argc, 
678                                         const char **argv) 
679 {
680         POLICY_HND pol;
681         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
682         LUID luid;
683
684         if (argc != 2 ) {
685                 printf("Usage: %s name\n", argv[0]);
686                 return NT_STATUS_OK;
687         }
688
689         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
690                                      SEC_RIGHTS_MAXIMUM_ALLOWED,
691                                      &pol);
692
693         if (!NT_STATUS_IS_OK(result))
694                 goto done;
695
696         result = cli_lsa_lookupprivvalue(cli, mem_ctx, &pol, argv[1], &luid);
697
698         if (!NT_STATUS_IS_OK(result))
699                 goto done;
700
701         /* Print results */
702
703         printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low);
704
705  done:
706         return result;
707 }
708
709 /* Query LSA security object */
710
711 static NTSTATUS cmd_lsa_query_secobj(struct cli_state *cli, 
712                                      TALLOC_CTX *mem_ctx, int argc, 
713                                      const char **argv) 
714 {
715         POLICY_HND pol;
716         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
717         SEC_DESC_BUF *sdb;
718         uint32 sec_info = 0x00000004; /* ??? */
719
720         if (argc != 1 ) {
721                 printf("Usage: %s\n", argv[0]);
722                 return NT_STATUS_OK;
723         }
724
725         result = cli_lsa_open_policy2(cli, mem_ctx, True, 
726                                       SEC_RIGHTS_MAXIMUM_ALLOWED,
727                                       &pol);
728
729         if (!NT_STATUS_IS_OK(result))
730                 goto done;
731
732         result = cli_lsa_query_secobj(cli, mem_ctx, &pol, sec_info, &sdb);
733
734         if (!NT_STATUS_IS_OK(result))
735                 goto done;
736
737         /* Print results */
738
739         display_sec_desc(sdb->sec);
740
741  done:
742         return result;
743 }
744
745
746 /* List of commands exported by this module */
747
748 struct cmd_set lsarpc_commands[] = {
749
750         { "LSARPC" },
751
752         { "lsaquery",            RPC_RTYPE_NTSTATUS, cmd_lsa_query_info_policy,  NULL, PI_LSARPC, "Query info policy",                    "" },
753         { "lookupsids",          RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids,        NULL, PI_LSARPC, "Convert SIDs to names",                "" },
754         { "lookupnames",         RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names,       NULL, PI_LSARPC, "Convert names to SIDs",                "" },
755         { "enumtrust",           RPC_RTYPE_NTSTATUS, cmd_lsa_enum_trust_dom,     NULL, PI_LSARPC, "Enumerate trusted domains",            "Usage: [preferred max number] [enum context (0)]" },
756         { "enumprivs",           RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privilege,     NULL, PI_LSARPC, "Enumerate privileges",                 "" },
757         { "getdispname",         RPC_RTYPE_NTSTATUS, cmd_lsa_get_dispname,       NULL, PI_LSARPC, "Get the privilege name",               "" },
758         { "lsaenumsid",          RPC_RTYPE_NTSTATUS, cmd_lsa_enum_sids,          NULL, PI_LSARPC, "Enumerate the LSA SIDS",               "" },
759         { "lsacreateaccount",    RPC_RTYPE_NTSTATUS, cmd_lsa_create_account,     NULL, PI_LSARPC, "Create a new lsa account",   "" },
760         { "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, PI_LSARPC, "Enumerate the privileges of an SID",   "" },
761         { "lsaenumacctrights",   RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights,   NULL, PI_LSARPC, "Enumerate the rights of an SID",   "" },
762 #if 0
763         { "lsaaddpriv",          RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv,           NULL, PI_LSARPC, "Assign a privilege to a SID", "" },
764         { "lsadelpriv",          RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv,           NULL, PI_LSARPC, "Revoke a privilege from a SID", "" },
765 #endif
766         { "lsaaddacctrights",    RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights,    NULL, PI_LSARPC, "Add rights to an account",   "" },
767         { "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, PI_LSARPC, "Remove rights from an account",   "" },
768         { "lsalookupprivvalue",  RPC_RTYPE_NTSTATUS, cmd_lsa_lookupprivvalue,    NULL, PI_LSARPC, "Get a privilege value given its name", "" },
769         { "lsaquerysecobj",      RPC_RTYPE_NTSTATUS, cmd_lsa_query_secobj,       NULL, PI_LSARPC, "Query LSA security object", "" },
770
771         { NULL }
772 };
773