source: branches/samba-3.2.x/source/include/libmsrpc.h@ 286

Last change on this file since 286 was 133, checked in by Paul Smedley, 17 years ago

Update trunk to 3.2.0pre3

File size: 92.6 KB
Line 
1/*
2 * Unix SMB/CIFS implementation.
3 * MS-RPC client library API definitions/prototypes
4 *
5 * Copyright (C) Chris Nicholls 2005.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef LIBMSRPC_H
22#define LIBMSRPC_H
23
24
25#include "includes.h"
26#include "libsmbclient.h"
27#include "libsmb_internal.h"
28
29/*server capability levels*/
30#define SRV_WIN_NT4 1
31#define SRV_WIN_2K 2
32#define SRV_WIN_2K_SP3 3
33#define SRV_WIN_2K3 4
34
35/**@defgroup handle Server Handle*/
36/**@defgroup Library_Functions Library/Utility Functions*/
37/**@defgroup lsa_defs LSA Definitions*/
38/**@defgroup LSA_Functions LSA Functions*/
39/**@defgroup reg_defs Registry Definitions*/
40/**@defgroup Reg_Functions Registry Functions*/
41/**@defgroup sam_defs SAM Definitions*/
42/**@defgroup SAM_Functions SAM Functions*/
43/**@defgroup svc_defs Service Control Definitions*/
44/**@defgroup SCM_Functions Service Control Functions*/
45
46/**Operation was unsuccessful*/
47#define CAC_FAILURE 0
48/**Operation was successful*/
49#define CAC_SUCCESS 1
50/**Operation was only partially successful
51 * an example of this is if you try to lookup a list of accounts to SIDs and not all accounts can be resolved*/
52#define CAC_PARTIAL_SUCCESS 2
53
54/**@ingroup CAC_errors Use this to see if the last operation failed - useful for enumeration functions that use multiple calls*/
55#define CAC_OP_FAILED(status) !NT_STATUS_IS_OK(status) && \
56 NT_STATUS_V(status) != NT_STATUS_V(STATUS_SOME_UNMAPPED) && \
57 NT_STATUS_V(status) != NT_STATUS_V(STATUS_NO_MORE_FILES) && \
58 NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_NO_MORE_ENTRIES) && \
59 NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_NONE_MAPPED) && \
60 NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_GUIDS_EXHAUSTED)
61
62
63/**Privilege string constants*/
64#define CAC_SE_CREATE_TOKEN "SeCreateTokenPrivilege"
65#define CAC_SE_ASSIGN_PRIMARY_TOKEN "SeAssignPrimaryTokenPrivilege"
66#define CAC_SE_LOCK_MEMORY "SeLockMemoryPrivilege"
67#define CAC_SE_INCREASE_QUOTA "SeIncreaseQuotaPrivilege"
68#define CAC_SE_MACHINE_ACCOUNT "SeMachineAccountPrivilege"
69#define CAC_SE_TCB "SeTcbPrivilege"
70#define CAC_SE_SECURITY "SeSecurityPrivilege"
71#define CAC_SE_TAKE_OWNERSHIP "SeTakeOwnershipPrivilege"
72#define CAC_SE_LOAD_DRIVER "SeLoadDriverPrivilege"
73#define CAC_SE_SYSTEM_PROFILE "SeSystemProfilePrivilege"
74#define CAC_SE_SYSTEM_TIME "SeSystemtimePrivilege"
75#define CAC_SE_PROFILE_SINGLE_PROC "SeProfileSingleProcessPrivilege"
76#define CAC_SE_INCREASE_BASE_PRIORITY "SeIncreaseBasePriorityPrivilege"
77#define CAC_SE_CREATE_PAGEFILE "SeCreatePagefilePrivilege"
78#define CAC_SE_CREATE_PERMANENT "SeCreatePermanentPrivilege"
79#define CAC_SE_BACKUP "SeBackupPrivilege"
80#define CAC_SE_RESTORE "SeRestorePrivilege"
81#define CAC_SE_SHUTDOWN "SeShutdownPrivilege"
82#define CAC_SE_DEBUG "SeDebugPrivilege"
83#define CAC_SE_AUDIT "SeAuditPrivilege"
84#define CAC_SE_SYSTEM_ENV "SeSystemEnvironmentPrivilege"
85#define CAC_SE_CHANGE_NOTIFY "SeChangeNotifyPrivilege"
86#define CAC_SE_REMOTE_SHUTDOWN "SeRemoteShutdownPrivilege"
87#define CAC_SE_UNDOCK "SeUndockPrivilege"
88#define CAC_SE_SYNC_AGENT "SeSyncAgentPrivilege"
89#define CAC_SE_ENABLE_DELEGATION "SeEnableDelegationPrivilege"
90#define CAC_SE_MANAGE_VOLUME "SeManageVolumePrivilege"
91#define CAC_SE_IMPERSONATE "SeImpersonatePrivilege"
92#define CAC_SE_CREATE_GLOBAL "SeCreateGlobalPrivilege"
93#define CAC_SE_PRINT_OPERATOR "SePrintOperatorPrivilege"
94#define CAC_SE_NETWORK_LOGON "SeNetworkLogonRight"
95#define CAC_SE_INTERACTIVE_LOGON "SeInteractiveLogonRight"
96#define CAC_SE_BATCH_LOGON "SeBatchLogonRight"
97#define CAC_SE_SERVICE_LOGON "SeServiceLogonRight"
98#define CAC_SE_ADD_USERS "SeAddUsersPrivilege"
99#define CAC_SE_DISK_OPERATOR "SeDiskOperatorPrivilege"
100
101/**
102 * @addtogroup lsa_defs
103 * @{
104 */
105/**used to specify what data to retrieve using cac_LsaQueryTrustedDomainInformation*/
106#define CAC_INFO_TRUSTED_DOMAIN_NAME 0x1
107#define CAC_INFO_TRUSTED_DOMAIN_POSIX_OFFSET 0x3
108#define CAC_INFO_TRUSTED_DOMAIN_PASSWORD 0x4
109
110/**Used when requesting machine domain information*/
111#define CAC_DOMAIN_INFO 0x0003
112
113/**Used when requesting machine local information*/
114#define CAC_LOCAL_INFO 0x0005
115
116/**Stores information about a SID*/
117typedef struct _CACSIDINFO {
118 /**The actual SID*/
119 DOM_SID sid;
120
121 /**The name of the object which maps to this SID*/
122 char *name;
123
124 /**The domain the SID belongs to*/
125 char *domain;
126} CacSidInfo;
127/* @} */
128
129/**
130 * @addtogroup reg_defs
131 * @{
132 */
133/**Null terminated string*/
134typedef char* REG_SZ_DATA;
135
136/**Null terminated string with windows environment variables that should be expanded*/
137typedef char* REG_EXPAND_SZ_DATA;
138
139/**Binary data of some kind*/
140typedef struct _REGBINARYDATA {
141 uint32 data_length;
142 uint8 * data;
143} REG_BINARY_DATA;
144
145/**32-bit (little endian) number*/
146typedef uint32 REG_DWORD_DATA;
147
148/**32-bit big endian number*/
149typedef uint32 REG_DWORD_BE_DATA;
150
151/**array of strings*/
152typedef struct _REGMULTISZDATA {
153 uint32 num_strings;
154
155 char **strings;
156} REG_MULTI_SZ_DATA;
157
158typedef union _REGVALUEDATA {
159 REG_SZ_DATA reg_sz;
160 REG_EXPAND_SZ_DATA reg_expand_sz;
161 REG_BINARY_DATA reg_binary;
162 REG_DWORD_DATA reg_dword;
163 REG_DWORD_BE_DATA reg_dword_be;
164 REG_MULTI_SZ_DATA reg_multi_sz;
165} REG_VALUE_DATA;
166/**@}*/
167
168/**
169 * @addtogroup sam_defs
170 * @{
171 */
172
173#define CAC_USER_RID 0x1
174#define CAC_GROUP_RID 0x2
175
176typedef struct _CACLOOKUPRIDSRECORD {
177 char *name;
178 uint32 rid;
179
180 /**If found, this will be one of:
181 * - CAC_USER_RID
182 * - CAC_GROUP_RID
183 */
184 uint32 type;
185
186 /*if the name or RID was looked up, then found = True*/
187 bool found;
188} CacLookupRidsRecord;
189
190typedef struct _CACUSERINFO {
191 /**Last logon time*/
192 time_t logon_time;
193
194 /**Last logoff time*/
195 time_t logoff_time;
196
197 /**Last kickoff time*/
198 time_t kickoff_time;
199
200 /**Last password set time*/
201 time_t pass_last_set_time;
202
203 /**Time password can change*/
204 time_t pass_can_change_time;
205
206 /**Time password must change*/
207 time_t pass_must_change_time;
208
209 /**LM user password*/
210 uint8 lm_password[8];
211
212 /**NT user password*/
213 uint8 nt_password[8];
214
215 /**User's RID*/
216 uint32 rid;
217
218 /**RID of primary group*/
219 uint32 group_rid;
220
221 /**User's ACB mask*/
222 uint32 acb_mask;
223
224 /**Bad password count*/
225 uint16 bad_passwd_count;
226
227 /**Number of logons*/
228 uint16 logon_count;
229
230 /**Change password at next logon?*/
231 bool pass_must_change;
232
233 /**Username*/
234 char *username;
235
236 /**User's full name*/
237 char *full_name;
238
239 /**User's home directory*/
240 char *home_dir;
241
242 /**Home directory drive*/
243 char *home_drive;
244
245 /**Logon script*/
246 char *logon_script;
247
248 /**Path to profile*/
249 char *profile_path;
250
251 /**Account description*/
252 char *description;
253
254 /**Login from workstations*/
255 char *workstations;
256
257 char *dial;
258
259 /**Possible logon hours*/
260 LOGON_HRS *logon_hours;
261
262} CacUserInfo;
263
264typedef struct _CACGROUPINFO {
265 /**Group name*/
266 char *name;
267
268 /**Description*/
269 char *description;
270
271 /**Number of members*/
272 uint32 num_members;
273} CacGroupInfo, CacAliasInfo;
274
275/**Represents a period (duration) of time*/
276typedef struct _CACTIME {
277 /**Number of days*/
278 uint32 days;
279
280 /**Number of hours*/
281 uint32 hours;
282
283 /**Number of minutes*/
284 uint32 minutes;
285
286 /**number of seconds*/
287 uint32 seconds;
288} CacTime;
289
290
291typedef struct _CACDOMINFO {
292 /**The server role. Should be one of:
293 * ROLE_STANDALONE
294 * ROLE_DOMAIN_MEMBER
295 * ROLE_DOMAIN_BDC
296 * ROLE_DOMAIN_PDC
297 * see include/smb.h
298 */
299 uint32 server_role;
300
301 /**Number of domain users*/
302 uint32 num_users;
303
304 /**Number of domain groups*/
305 uint32 num_domain_groups;
306
307 /**Number of local groups*/
308 uint32 num_local_groups;
309
310 /**Comment*/
311 char *comment;
312
313 /**Domain name*/
314 char *domain_name;
315
316 /**Server name*/
317 char *server_name;
318
319 /**Minimum password length*/
320 uint16 min_pass_length;
321
322 /**How many previous passwords to remember - ie, password cannot be the same as N previous passwords*/
323 uint16 pass_history;
324
325 /**How long (from now) before passwords expire*/
326 CacTime expire;
327
328 /**How long (from now) before passwords can be changed*/
329 CacTime min_pass_age;
330
331 /**How long users are locked out for too many bad password attempts*/
332 CacTime lockout_duration;
333
334 /**How long before lockouts are reset*/
335 CacTime lockout_reset;
336
337 /**How many bad password attempts before lockout occurs*/
338 uint16 num_bad_attempts;
339} CacDomainInfo;
340
341/**@}*/ /*sam_defs*/
342
343/**@addtogroup svc_defs
344 * @{
345 */
346typedef struct _CACSERVICE {
347 /**The service name*/
348 char *service_name;
349
350 /**The display name of the service*/
351 char *display_name;
352
353 /**Current status of the service - see include/rpc_svcctl.h for SERVICE_STATUS definition*/
354 SERVICE_STATUS status;
355} CacService;
356
357typedef struct __CACSERVICECONFIG {
358 /**The service type*/
359 uint32 type;
360
361 /**The start type. Should be one of:
362 * - SVCCTL_BOOT_START
363 * - SVCCTL_SYSTEM_START
364 * - SVCCTL_AUTO_START
365 * - SVCCTL_DEMAND_START
366 */
367 uint32 start_type;
368
369 uint32 error_control;
370
371 /**Path to executable*/
372 char *exe_path;
373
374 /***/
375 char *load_order_group;
376
377 uint32 tag_id;
378
379 /**Any dependencies for the service*/
380 char *dependencies;
381
382 /**Run as...*/
383 char *start_name;
384
385 /**Service display name*/
386 char *display_name;
387
388} CacServiceConfig;
389/**@}*/ /*svc_defs*/
390
391#include "libmsrpc_internal.h"
392
393/**
394 * @addtogroup handle
395 * @{
396 */
397
398/**
399 * Server handle used to keep track of client/server/pipe information. Use cac_NewServerHandle() to allocate.
400 * Initiliaze as many values as possible before calling cac_Connect().
401 *
402 * @note When allocating memory for the fields, use SMB_MALLOC() (or equivalent) instead of talloc() (or equivalent) -
403 * If memory is not allocated for a field, cac_Connect will allocate sizeof(fstring) bytes for it.
404 *
405 * @note It may be wise to allocate large buffers for these fields and strcpy data into them.
406 *
407 * @see cac_NewServerHandle()
408 * @see cac_FreeHandle()
409 */
410typedef struct _CACSERVERHANDLE {
411 /** debug level
412 */
413 int debug;
414
415 /** netbios name used to make connections
416 */
417 char *netbios_name;
418
419 /** domain name used to make connections
420 */
421 char *domain;
422
423 /** username used to make connections
424 */
425 char *username;
426
427 /** user's password plain text string
428 */
429 char *password;
430
431 /** name or IP address of server we are currently working with
432 */
433 char *server;
434
435 /**stores the latest NTSTATUS code
436 */
437 NTSTATUS status;
438
439 /** internal. do not modify!
440 */
441 struct CacServerHandleInternal _internal;
442
443} CacServerHandle;
444
445/*@}*/
446
447/**internal function. do not call this function*/
448SMBCSRV *cac_GetServer(CacServerHandle *hnd);
449
450
451/** @addtogroup Library_Functions
452 * @{
453 */
454/**
455 * Initializes the library - do not need to call this function. Open's smb.conf as well as initializes logging.
456 * @param debug Debug level for library to use
457 */
458
459void cac_Init(int debug);
460
461/**
462 * Creates an un-initialized CacServerHandle
463 * @param allocate_fields If True, the function will allocate sizeof(fstring) bytes for all char * fields in the handle
464 * @return - un-initialized server handle
465 * - NULL if no memory could be allocated
466 */
467CacServerHandle * cac_NewServerHandle(bool allocate_fields);
468
469/**
470 * Specifies the smbc_get_auth_data_fn to use if you do not want to use the default.
471 * @param hnd non-NULL server handle
472 * @param auth_fn auth_data_fn to set in server handle
473 */
474
475void cac_SetAuthDataFn(CacServerHandle *hnd, smbc_get_auth_data_fn auth_fn);
476
477/** Use your own libsmbclient context - not necessary.
478 * @note You must still call cac_Connect() after specifying your own libsmbclient context
479 * @param hnd Initialized, but not connected CacServerHandle
480 * @param ctx The libsmbclient context you would like to use.
481 */
482void cac_SetSmbcContext(CacServerHandle *hnd, SMBCCTX *ctx);
483
484/** Connects to a specified server. If there is already a connection to a different server,
485 * it will be cleaned up before connecting to the new server.
486 * @param hnd Pre-initialized CacServerHandle
487 * @param srv (Optional) Name or IP of the server to connect to. If NULL, server from the CacServerHandle will be used.
488 *
489 * @return CAC_FAILURE if the operation could not be completed successfully (hnd->status will also be set with a NTSTATUS code)
490 * @return CAC_SUCCESS if the operation succeeded
491 */
492int cac_Connect(CacServerHandle *hnd, const char *srv);
493
494
495/**
496 * Cleans up any data used by the CacServerHandle. If the libsmbclient context was set using cac_SetSmbcContext(), it will not be free'd.
497 * @param hnd the CacServerHandle to destroy
498 */
499void cac_FreeHandle(CacServerHandle * hnd);
500
501/**
502 * Initializes a CacTime structure based on an NTTIME structure
503 * If the function fails, then the CacTime structure will be zero'd out
504 */
505void cac_InitCacTime(CacTime *cactime, NTTIME nttime);
506
507/**
508 * Called by cac_NewServerHandle() if allocate_fields = True. You can call this if you want to, allocates sizeof(fstring) char's for every char * field
509 * @param hnd Uninitialized server handle
510 * @return CAC_FAILURE Memory could not be allocated
511 * @return CAC_SUCCESS Memory was allocated
512 */
513int cac_InitHandleMem(CacServerHandle *hnd);
514
515/**
516 * Default smbc_get_auth_data_fn for libmsrpc. This function is called when libmsrpc needs to get more information about the
517 * client (username/password, workgroup).
518 * This function provides simple prompts to the user to enter the information. This description his here so you know how to re-define this function.
519 * @see cac_SetAuthDataFn()
520 * @param pServer Name/IP of the server to connect to.
521 * @param pShare Share name to connect to
522 * @param pWorkgroup libmsrpc passes in the workgroup/domain name from hnd->domain. It can be modified in the function.
523 * @param maxLenWorkgroup The maximum length of a string pWogroup can hold.
524 * @param pUsername libmsrpc passes in the username from hnd->username. It can be modified in the function.
525 * @param maxLenUsername The maximum length of a string pUsername can hold.
526 * @param pPassword libmsrpc pass in the password from hnd->password. It can be modified in the function.
527 * @param maxLenPassword The maximum length of a string pPassword can hold.
528 */
529void cac_GetAuthDataFn(const char * pServer,
530 const char * pShare,
531 char * pWorkgroup,
532 int maxLenWorkgroup,
533 char * pUsername,
534 int maxLenUsername,
535 char * pPassword,
536 int maxLenPassword);
537
538
539/**@}*/
540
541/*****************
542 * LSA Functions *
543 *****************/
544
545/** @addtogroup LSA_Functions
546 * @{
547 */
548
549struct LsaOpenPolicy {
550 /**Inputs*/
551 struct {
552 /**Access Mask. Refer to Security Access Masks in include/rpc_secdes.h*/
553 uint32 access;
554
555 /**Use security quality of service? (True/False)*/
556 bool security_qos;
557 } in;
558
559 /**Outputs*/
560 struct {
561 /**Handle to the open policy (needed for all other operations)*/
562 POLICY_HND *pol;
563 } out;
564};
565
566/**
567 * Opens a policy handle on a remote machine.
568 * @param hnd fully initialized CacServerHandle for remote machine
569 * @param mem_ctx Talloc context for memory allocation
570 * @param op Initialized parameters
571 * @return CAC_FAILURE if the policy could not be opened. hnd->status set with appropriate NTSTATUS
572 * @return CAC_SUCCESS if the policy could be opened, the policy handle can be found
573 */
574int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op);
575
576
577/**
578 * Closes an LSA policy handle (Retrieved using cac_LsaOpenPolicy).
579 * If successful, the handle will be closed on the server, and memory for pol will be freed
580 * @param hnd - An initialized and connected server handle
581 * @param mem_ctx Talloc context for memory allocation
582 * @param pol - the policy handle to close
583 * @return CAC_FAILURE could not close the policy handle, hnd->status is set to the appropriate NTSTATUS error code
584 * @return CAC_SUCCESS the policy handle was closed
585 */
586int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *pol);
587
588
589struct LsaGetNamesFromSids {
590 struct {
591 /**handle to and open LSA policy*/
592 POLICY_HND *pol;
593
594 /**the number of SIDs to lookup*/
595 uint32 num_sids;
596
597 /**array of SIDs to lookup*/
598 DOM_SID *sids;
599 } in;
600
601 struct {
602 /**The number of names returned (in case of CAC_PARTIAL_SUCCESS)*/
603 uint32 num_found;
604
605 /**array of SID info each index is one sid */
606 CacSidInfo *sids;
607
608 /**in case of partial success, an array of SIDs that could not be looked up (NULL if all sids were looked up)*/
609 DOM_SID *unknown;
610 } out;
611};
612
613/**
614 * Looks up the names for a list of SIDS
615 * @param hnd initialized and connected server handle
616 * @param mem_ctx Talloc context for memory allocation
617 * @param op input and output parameters
618 * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code
619 * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output
620 * @return CAC_PARTIAL_SUCCESS not all of the SIDs were translated, as a result the number of returned names is less than the original list of SIDs
621 */
622int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetNamesFromSids *op);
623
624struct LsaGetSidsFromNames {
625 struct {
626 /**handle to an open LSA policy*/
627 POLICY_HND *pol;
628
629 /**number of SIDs to lookup*/
630 uint32 num_names;
631
632 /**array of strings listing the names*/
633 char **names;
634 } in;
635
636 struct {
637 /**The number of SIDs returned (in case of partial success*/
638 uint32 num_found;
639
640 /**array of SID info for the looked up names*/
641 CacSidInfo *sids;
642
643 /**in case of partial success, the names that were not looked up*/
644 char **unknown;
645 } out;
646};
647
648/**
649 * Looks up the SIDs for a list of names
650 * @param hnd initialized and connected server handle
651 * @param mem_ctx Talloc context for memory allocation
652 * @param op input and output parameters
653 * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code
654 * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output
655 * @return CAC_PARTIAL_SUCCESS not all of the SIDs were translated, as a result the number of returned names is less than the original list of SIDs
656 */
657int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSidsFromNames *op);
658
659struct LsaFetchSid {
660 struct {
661 /**handle to an open LSA policy*/
662 POLICY_HND *pol;
663
664 /**can be CAC_LOCAL_INFO, CAC_DOMAIN_INFO, or (CAC_LOCAL_INFO | CAC_DOMAIN_INFO)*/
665 uint16 info_class;
666 } in;
667
668 struct {
669 /**the machine's local SID and domain name (NULL if not asked for)*/
670 CacSidInfo *local_sid;
671
672 /**the machine's domain SID and name (NULL if not asked for)*/
673 CacSidInfo *domain_sid;
674
675 } out;
676};
677
678/**
679 * Looks up the domain or local sid of a machine with an open LSA policy handle
680 * @param hnd initialized and connected server handle
681 * @param mem_ctx Talloc context for memory allocation
682 * @param op input and output parameters
683 * @return CAC_FAILURE if the SID could not be fetched
684 * @return CAC_SUCCESS if the SID was fetched
685 * @return CAC_PARTIAL_SUCCESS if you asked for both local and domain sids but only one was returned
686 */
687int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSid *op);
688
689struct LsaQueryInfoPolicy {
690 struct {
691 /**Open LSA policy handle on remote server*/
692 POLICY_HND *pol;
693 } in;
694
695 struct {
696 /**remote server's domain name*/
697 char *domain_name;
698
699 /**remote server's dns name*/
700 char *dns_name;
701
702 /**remote server's forest name*/
703 char *forest_name;
704
705 /**remote server's domain guid*/
706 struct GUID *domain_guid;
707
708 /**remote server's domain SID*/
709 DOM_SID *domain_sid;
710 } out;
711};
712
713/**
714 * Retrieves information about the LSA machine/domain
715 * @param hnd initialized and connected server handle
716 * @param mem_ctx Talloc context for memory allocation
717 * @param op input and output parameters
718 * Note: for pre-Windows 2000 machines, only op->out.SID and op->out.domain will be set. @see cac_LsaFetchSid
719 * @return - CAC_FAILURE if the operation was not successful. hnd->status will be set with an accurate NT_STATUS code
720 * @return CAC_SUCCESS the operation was successful.
721 */
722int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryInfoPolicy *op);
723
724struct LsaEnumSids {
725 struct {
726 /**Open LSA Policy handle*/
727 POLICY_HND *pol;
728
729 /**The prefered maximum number of SIDs returned per call*/
730 uint32 pref_max_sids;
731 } in;
732
733 struct {
734 /**used to keep track of how many sids have been retrieved over multiple calls
735 * should be set to zero via ZERO_STRUCT() befrore the first call. Use the same struct LsaEnumSids for multiple calls*/
736 uint32 resume_idx;
737
738 /**The number of sids returned this call*/
739 uint32 num_sids;
740
741 /**Array of sids returned*/
742 DOM_SID *sids;
743
744 } out;
745};
746
747/**
748 * Enumerates the SIDs in the LSA. Can be enumerated in blocks by calling the function multiple times.
749 * Example: while(cac_LsaEnumSids(hnd, mem_ctx, op) { ... }
750 * @param hnd - An initialized and connected server handle
751 * @param mem_ctx Talloc context for memory allocation
752 * @param op Initialized parameters
753 * @return CAC_FAILURE there was an error during operations OR there are no more results
754 * @return CAC_SUCCESS the operation completed and results were returned
755 */
756int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSids *op);
757
758struct LsaEnumAccountRights {
759 struct {
760 /**Open LSA Policy handle*/
761 POLICY_HND *pol;
762
763 /**(Optional) SID of the account - must supply either sid or name*/
764 DOM_SID *sid;
765
766 /**(Optional) name of the account - must supply either sid or name*/
767 char *name;
768 } in;
769
770 struct {
771 /**Count of rights for this account*/
772 uint32 num_privs;
773
774 /**array of privilege names*/
775 char **priv_names;
776 } out;
777};
778
779/**
780 * Enumerates rights assigned to a given account. Takes a SID instead of account handle as input
781 * @param hnd Initialized and connected server handle
782 * @param mem_ctx Context for memory allocation
783 * @param op Initialized Parameters
784 * @return CAC_FAILURE the rights could not be retrieved. hnd->status is set with NT_STATUS code
785 * @return CAC_SUCCESS the operation was successful.
786 */
787
788int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumAccountRights *op);
789
790struct LsaEnumTrustedDomains {
791 struct {
792 /**Open LSA policy handle*/
793 POLICY_HND *pol;
794 } in;
795
796 struct {
797 /**used to keep track of how many domains have been retrieved over multiple calls
798 * should be set to zero via ZERO_STRUCT() before the first call. Use the same struct LsaEnumSids for multiple calls*/
799 uint32 resume_idx;
800
801 /**The number of domains returned by the remote server this call*/
802 uint32 num_domains;
803
804 /**array of trusted domain names returned by the remote server*/
805 char **domain_names;
806
807 /**array of trusted domain sids returned by the remote server*/
808 DOM_SID *domain_sids;
809 } out;
810};
811
812/**
813 * Enumerates the trusted domains in the LSA.
814 * @param hnd - An initialized and connected server handle
815 * @param mem_ctx Talloc context for memory allocation
816 * @param op - initialized parameters
817 * @return CAC_FAILURE there was an error during operations OR there are no more results
818 * @return CAC_SUCCESS the operation completed and results were returned
819 */
820int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumTrustedDomains *op);
821
822struct LsaOpenTrustedDomain {
823 struct {
824 /**an open LSA policy handle*/
825 POLICY_HND *pol;
826
827 /**SID of the trusted domain to open*/
828 DOM_SID *domain_sid;
829
830 /**Desired access on the open domain*/
831 uint32 access;
832 } in;
833
834 struct {
835 /**A handle to the policy that is opened*/
836 POLICY_HND *domain_pol;
837 } out;
838};
839
840/**
841 * Opens a trusted domain by SID.
842 * @param hnd An initialized and connected server handle
843 * @param mem_ctx Talloc context for memory allocation
844 * @param op initialized I/O parameters
845 * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code
846 * @return CAC_SUCCESS the domain was opened successfully
847 */
848int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenTrustedDomain *op);
849
850struct LsaQueryTrustedDomainInfo {
851 struct {
852 /**Open LSA policy handle*/
853 POLICY_HND *pol;
854
855 /**Info class of returned data*/
856 uint16 info_class;
857
858 /**(Optional)SID of trusted domain to query (must specify either SID or name of trusted domain)*/
859 DOM_SID *domain_sid;
860
861 /**(Optional)Name of trusted domain to query (must specify either SID or name of trusted domain)*/
862 char *domain_name;
863 } in;
864
865 struct {
866 /**information about the trusted domain*/
867 LSA_TRUSTED_DOMAIN_INFO *info;
868 } out;
869};
870
871/**
872 * Retrieves information a trusted domain.
873 * @param hnd An initialized and connected server handle
874 * @param mem_ctx Talloc context for memory allocation
875 * @param op initialized I/O parameters
876 * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code
877 * @return CAC_SUCCESS the domain was opened successfully
878 */
879
880int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryTrustedDomainInfo *op);
881
882struct LsaEnumPrivileges {
883 struct {
884 /**An open LSA policy handle*/
885 POLICY_HND *pol;
886
887 /**The _preferred_ maxinum number of privileges returned per call*/
888 uint32 pref_max_privs;
889 } in;
890
891 struct {
892 /**Used to keep track of how many privileges have been retrieved over multiple calls. Do not modify this value between calls*/
893 uint32 resume_idx;
894
895 /**The number of privileges returned this call*/
896 uint32 num_privs;
897
898 /**Array of privilege names*/
899 char **priv_names;
900
901 /**Array of high bits for privilege LUID*/
902 uint32 *high_bits;
903
904 /**Array of low bits for privilege LUID*/
905 uint32 *low_bits;
906 } out;
907};
908
909/**
910 * Enumerates the Privileges supported by the LSA. Can be enumerated in blocks by calling the function multiple times.
911 * Example: while(cac_LsaEnumPrivileges(hnd, mem_ctx, op) { ... }
912 * @param hnd An initialized and connected server handle
913 * @param mem_ctx Talloc context for memory allocation
914 * @param op Initialized parameters
915 * @return CAC_FAILURE there was an error during operations OR there are no more results
916 * @return CAC_SUCCESS the operation completed and results were returned
917 * @see CAC_OP_FAILED()
918 */
919int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumPrivileges *op);
920
921struct LsaOpenAccount {
922 struct {
923 /**An open LSA policy handle*/
924 POLICY_HND *pol;
925
926 /**(Optional) account SID - must supply either sid or name*/
927 DOM_SID *sid;
928
929 /**(Optional) account name - must supply either sid or name*/
930 char *name;
931
932 /**desired access for the handle*/
933 uint32 access;
934 } in;
935
936 struct {
937 /**A handle to the opened user*/
938 POLICY_HND *user;
939 } out;
940};
941
942/**
943 * Opens a handle to an account in the LSA
944 * @param hnd Initialized and connected server handle
945 * @param mem_ctx Context for memory allocation
946 * @param op Initialized Parameters
947 * @return CAC_FAILURE the account could not be opened. hnd->status has appropriate NT_STATUS code
948 * @return CAC_SUCCESS the account was opened
949 */
950int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenAccount *op);
951
952struct LsaAddPrivileges {
953 struct {
954 /**An open LSA policy handle*/
955 POLICY_HND *pol;
956
957 /**(Optional) The user's SID (must specify at least sid or name)*/
958 DOM_SID *sid;
959
960 /**(Optional) The user's name (must specify at least sid or name)*/
961 char *name;
962
963 /**The privilege names of the privileges to add for the account*/
964 char **priv_names;
965
966 /**The number of privileges in the priv_names array*/
967 uint32 num_privs;
968
969 } in;
970};
971
972/**
973 * Adds Privileges an account.
974 * @param hnd Initialized and connected server handle
975 * @param mem_ctx Context for memory allocation
976 * @param op Initialized Parameters
977 * @return CAC_FAILURE the privileges could not be set. hnd->status has appropriate NT_STATUS code
978 * @return CAC_SUCCESS the privileges were set.
979 */
980int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op);
981
982struct LsaRemovePrivileges {
983 struct {
984 /**An open handle to the LSA*/
985 POLICY_HND *pol;
986
987 /**(Optional) The account SID (must specify at least sid or name)*/
988 DOM_SID *sid;
989
990 /**(Optional) The account name (must specify at least sid or name)*/
991 char *name;
992
993 /**The privilege names of the privileges to remove from the account*/
994 char **priv_names;
995
996 /**The number of privileges in the priv_names array*/
997 uint32 num_privs;
998
999 } in;
1000
1001};
1002
1003/**
1004 * Removes a _specific_ set of privileges from an account
1005 * @param hnd Initialized and connected server handle
1006 * @param mem_ctx Context for memory allocation
1007 * @param op Initialized Parameters
1008 * @return CAC_FAILURE the privileges could not be removed. hnd->status is set with NT_STATUS code
1009 * @return CAC_SUCCESS the privileges were removed
1010 */
1011int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaRemovePrivileges *op);
1012
1013struct LsaClearPrivileges {
1014 struct {
1015 /**An open handle to the LSA*/
1016 POLICY_HND *pol;
1017
1018 /**(Optional) The user's SID (must specify at least sid or name)*/
1019 DOM_SID *sid;
1020
1021 /**(Optional) The user's name (must specify at least sid or name)*/
1022 char *name;
1023 } in;
1024
1025};
1026
1027/**
1028 * Removes ALL privileges from an account
1029 * @param hnd Initialized and connected server handle
1030 * @param mem_ctx Context for memory allocation
1031 * @param op Initialized Parameters
1032 * @return CAC_FAILURE the operation was not successful, hnd->status set with NT_STATUS code
1033 * @return CAC_SUCCESS the opeartion was successful.
1034 */
1035int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaClearPrivileges *op);
1036
1037/**
1038 * Sets an accounts priviliges. Removes all privileges and then adds specified privileges.
1039 * @param hnd Initialized and connected server handle
1040 * @param mem_ctx Context for memory allocation
1041 * @param op Initialized Parameters
1042 * @return CAC_FAILURE The operation could not complete successfully
1043 * @return CAC_SUCCESS The operation completed successfully
1044 */
1045int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op);
1046
1047struct LsaGetSecurityObject {
1048 struct {
1049 /**Open LSA policy handle*/
1050 POLICY_HND *pol;
1051 } in;
1052
1053 struct {
1054 /**Returned security descriptor information*/
1055 SEC_DESC_BUF *sec;
1056 } out;
1057};
1058
1059/**
1060 * Retrieves Security Descriptor information about the LSA
1061 * @param hnd Initialized and connected server handle
1062 * @param mem_ctx Context for memory allocation
1063 * @param op Initialized Parameters
1064 * @return CAC_FAILURE The operation could not complete successfully
1065 * @return CAC_SUCCESS The operation completed successfully
1066 */
1067int cac_LsaGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSecurityObject *op);
1068
1069
1070/**@}*/ /*LSA_Functions*/
1071
1072/**********************
1073 * Registry Functions *
1074 *********************/
1075
1076/**@addtogroup Reg_Functions
1077 * @{
1078 */
1079
1080struct RegConnect {
1081 struct {
1082 /** must be one of :
1083 * HKEY_CLASSES_ROOT,
1084 * HKEY_LOCAL_MACHINE,
1085 * HKEY_USERS,
1086 * HKEY_PERFORMANCE_DATA,
1087 */
1088 int root;
1089
1090 /**desired access on the root key
1091 * combination of:
1092 * REG_KEY_READ,
1093 * REG_KEY_WRITE,
1094 * REG_KEY_EXECUTE,
1095 * REG_KEY_ALL,
1096 * found in include/rpc_secdes.h*/
1097 uint32 access;
1098 } in;
1099
1100 struct {
1101 POLICY_HND *key;
1102 } out;
1103};
1104
1105/**
1106 * Opens a handle to the registry on the server
1107 * @param hnd Initialized and connected server handle
1108 * @param mem_ctx Context for memory allocation
1109 * @param op Initialized Parameters
1110 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1111 * @return CAC_SUCCESS The operation completed successfully
1112 */
1113int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op);
1114
1115/**
1116 * Closes an open registry handle
1117 * @param hnd Initialized and connected server handle
1118 * @param mem_ctx Context for memory allocation
1119 * @param key The Key/Handle to close
1120 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1121 * @return CAC_SUCCESS The operation completed successfully
1122 */
1123int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key);
1124
1125struct RegOpenKey {
1126 struct {
1127 /**(Optional)parent key.
1128 * If this is NULL, then cac_RegOpenKey() will attempt to connect to the registry, name MUST start with something like:<br>
1129 * HKEY_LOCAL_MACHINE\ or an abbreviation like HKCR\
1130 *
1131 * supported root names:
1132 * - HKEY_LOCAL_MACHINE\ or HKLM\
1133 * - HKEY_CLASSES_ROOT\ or HKCR\
1134 * - HKEY_USERS\ or HKU\
1135 * - HKEY_PERFORMANCE_DATA or HKPD\
1136 */
1137 POLICY_HND *parent_key;
1138
1139 /**name/path of key*/
1140 char *name;
1141
1142 /**desired access on this key*/
1143 uint32 access;
1144 } in;
1145
1146 struct {
1147 POLICY_HND *key;
1148 } out;
1149};
1150
1151/**
1152 * Opens a registry key
1153 * @param hnd Initialized and connected server handle
1154 * @param mem_ctx Context for memory allocation
1155 * @param op Initialized parameters
1156 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1157 * @return CAC_SUCCESS The operation completed successfully
1158 */
1159
1160int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey *op);
1161
1162struct RegEnumKeys {
1163 struct {
1164 /**enumerate subkeys of this key*/
1165 POLICY_HND *key;
1166
1167 /**maximum number of keys to enumerate each call*/
1168 uint32 max_keys;
1169 } in;
1170
1171 struct {
1172 /**keeps track of the index to resume enumerating*/
1173 uint32 resume_idx;
1174
1175 /**the number of keys returned this call*/
1176 uint32 num_keys;
1177
1178 /**array of key names*/
1179 char **key_names;
1180
1181 /**class names of the keys*/
1182 char **class_names;
1183
1184 /**last modification time of the key*/
1185 time_t *mod_times;
1186 } out;
1187};
1188
1189/**
1190 * Enumerates Subkeys of a given key. Can be run in a loop. Example: while(cac_RegEnumKeys(hnd, mem_ctx, op)) { ... }
1191 * @param hnd Initialized and connected server handle
1192 * @param mem_ctx Context for memory allocation
1193 * @param op Initialized Parameters
1194 * @see CAC_OP_FAILED()
1195 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1196 * @return CAC_SUCCESS The operation completed successfully
1197 */
1198int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op);
1199
1200
1201struct RegCreateKey {
1202 struct {
1203 /**create a subkey of parent_key*/
1204 POLICY_HND *parent_key;
1205
1206 /**name of the key to create*/
1207 char *key_name;
1208
1209 /**class of the key*/
1210 char *class_name;
1211
1212 /**Access mask to open the key with. See REG_KEY_* in include/rpc_secdes.h*/
1213 uint32 access;
1214 } in;
1215
1216 struct {
1217 /**Open handle to the key*/
1218 POLICY_HND *key;
1219 } out;
1220};
1221
1222/**
1223 * Creates a registry key, if the key already exists, it will be opened __Creating keys is not currently working__.
1224 * @param hnd Initialized and connected server handle
1225 * @param mem_ctx Context for memory allocation
1226 * @param op Initialized Parmeters
1227 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1228 * @return CAC_SUCCESS The operation completed successfully
1229 */
1230int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op);
1231
1232struct RegDeleteKey {
1233 struct {
1234 /**handle to open registry key*/
1235 POLICY_HND *parent_key;
1236
1237 /**name of the key to delete*/
1238 char *name;
1239
1240 /**delete recursively. WARNING: this might not always work as planned*/
1241 bool recursive;
1242 } in;
1243
1244};
1245
1246/**
1247 * Deletes a subkey of an open key. Note: if you run this with op->in.recursive == True, and the operation fails, it may leave the key in an inconsistent state.
1248 * @param hnd Initialized and connected server handle
1249 * @param mem_ctx Context for memory allocation
1250 * @param op Initialized parameters
1251 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1252 * @return CAC_SUCCESS The operation completed successfully
1253 */
1254
1255int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op);
1256
1257struct RegDeleteValue {
1258 struct {
1259 /**handle to open registry key*/
1260 POLICY_HND *parent_key;
1261
1262 /**name of the value to delete*/
1263 char *name;
1264 } in;
1265};
1266
1267/**
1268 * Deletes a registry value.
1269 * @param hnd Initialized and connected server handle
1270 * @param mem_ctx Context for memory allocation
1271 * @param op Initialized Parameters
1272 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1273 * @return CAC_SUCCESS The operation completed successfully
1274 */
1275int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op);
1276
1277struct RegQueryKeyInfo {
1278 struct {
1279 /**Open handle to the key to query*/
1280 POLICY_HND *key;
1281 } in;
1282
1283 struct {
1284 /**name of the key class*/
1285 char *class_name;
1286
1287 /**number of subkeys of the key*/
1288 uint32 num_subkeys;
1289
1290 /**length (in characters) of the longest subkey name*/
1291 uint32 longest_subkey;
1292
1293 /**length (in characters) of the longest class name*/
1294 uint32 longest_class;
1295
1296 /**number of values in this key*/
1297 uint32 num_values;
1298
1299 /**length (in characters) of the longest value name*/
1300 uint32 longest_value_name;
1301
1302 /**length (in bytes) of the biggest value data*/
1303 uint32 longest_value_data;
1304
1305 /**size (in bytes) of the security descriptor*/
1306 uint32 security_desc_size;
1307
1308 /**time of the last write*/
1309 time_t last_write_time;
1310 } out;
1311};
1312
1313/**
1314 * Retrieves information about an open key
1315 * @param hnd Initialized and connected server handle
1316 * @param mem_ctx Context for memory allocation
1317 * @param op Initialized parameters
1318 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1319 * @return CAC_SUCCESS The operation completed successfully
1320 */
1321
1322int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryKeyInfo *op);
1323
1324struct RegSaveKey {
1325 struct {
1326 /**Open key to be saved*/
1327 POLICY_HND *key;
1328
1329 /**The path (on the remote computer) to save the file to*/
1330 char *filename;
1331 } in;
1332};
1333
1334/**
1335 * Saves a key to a file on the remote machine __Not currently working__.
1336 * @param hnd Initialized and connected server handle
1337 * @param mem_ctx Context for memory allocation
1338 * @param op Initialized parameters
1339 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1340 * @return CAC_SUCCESS The operation completed successfully
1341 */
1342
1343int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op);
1344
1345struct RegQueryValue {
1346 struct {
1347 /**handle to open registry key*/
1348 POLICY_HND *key;
1349
1350 /**name of the value to query*/
1351 char *val_name;
1352 } in;
1353
1354 struct {
1355 /**Value type.
1356 * One of:
1357 * - REG_DWORD (equivalent to REG_DWORD_LE)
1358 * - REG_DWORD_BE
1359 * - REG_SZ
1360 * - REG_EXPAND_SZ
1361 * - REG_MULTI_SZ
1362 * - REG_BINARY
1363 */
1364 uint32 type;
1365
1366 /**The value*/
1367 REG_VALUE_DATA *data;
1368 } out;
1369};
1370
1371/**
1372 * Retrieves a value (type and data) _not currently working_.
1373 * @param hnd Initialized and connected server handle
1374 * @param mem_ctx Context for memory allocation
1375 * @param op Initialized parameters
1376 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1377 * @return CAC_SUCCESS The operation completed successfully
1378 */
1379
1380int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op);
1381
1382struct RegEnumValues {
1383 struct {
1384 /**handle to open key*/
1385 POLICY_HND *key;
1386
1387 /**max number of values returned per call*/
1388 uint32 max_values;
1389
1390 } in;
1391
1392 struct {
1393 /**keeps track of the index to resume from - used over multiple calls*/
1394 uint32 resume_idx;
1395
1396 /**the number of values that were returned this call*/
1397 uint32 num_values;
1398
1399 /**Array of value types. A type can be one of:
1400 * - REG_DWORD (equivalent to REG_DWORD_LE)
1401 * - REG_DWORD_BE
1402 * - REG_SZ
1403 * - REG_EXPAND_SZ
1404 * - REG_MULTI_SZ
1405 * - REG_BINARY
1406 */
1407 uint32 *types;
1408
1409 /**array of strings storing the names of the values*/
1410 char **value_names;
1411
1412 /**array of pointers to the value data returned*/
1413 REG_VALUE_DATA **values;
1414 } out;
1415};
1416
1417/**
1418 * Enumerates a number of Registry values in an open registry key.
1419 * Can be run in a loop. Example: while(cac_RegEnumValues(hnd, mem_ctx, op)) { ... }
1420 * @param hnd Initialized and connected server handle
1421 * @param mem_ctx Context for memory allocation
1422 * @param op Initialized Parameters
1423 * @see CAC_OP_FAILED()
1424 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1425 * @return CAC_SUCCESS The operation completed successfully
1426 */
1427int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op);
1428
1429struct RegSetValue {
1430 struct {
1431 /**Handle to open registry key*/
1432 POLICY_HND *key;
1433
1434 /**Name of the value*/
1435 char *val_name;
1436
1437 /**Value type.
1438 * One of:
1439 * - REG_DWORD (equivalent to REG_DWORD_LE)
1440 * - REG_DWORD_BE
1441 * - REG_SZ
1442 * - REG_EXPAND_SZ
1443 * - REG_MULTI_SZ
1444 * - REG_BINARY
1445 */
1446 uint32 type;
1447
1448 /**the value*/
1449 REG_VALUE_DATA value;
1450 } in;
1451};
1452
1453/**
1454 * Sets or creates value (type and data).
1455 * @param hnd Initialized and connected server handle
1456 * @param mem_ctx Context for memory allocation
1457 * @param op Initialized parameters
1458 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1459 * @return CAC_SUCCESS The operation completed successfully
1460 */
1461int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op);
1462
1463struct RegGetVersion {
1464 struct {
1465 /**open registry key*/
1466 POLICY_HND *key;
1467 } in;
1468
1469 struct {
1470 /**version number*/
1471 uint32 version;
1472 } out;
1473};
1474
1475/**
1476 * Retrieves the registry version number
1477 * @param hnd Initialized and connected server handle
1478 * @param mem_ctx Context for memory allocation
1479 * @param op Initialized parameters
1480 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1481 * @return CAC_SUCCESS The operation completed successfully
1482 */
1483int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op);
1484
1485struct RegGetKeySecurity {
1486 struct {
1487 /**Handle to key to query*/
1488 POLICY_HND *key;
1489
1490 /**Info that you want. Should be a combination of (1 or more or'd):
1491 * - OWNER_SECURITY_INFORMATION
1492 * - GROUP_SECURITY_INFORMATION
1493 * - DACL_SECURITY_INFORMATION
1494 * - SACL_SECURITY_INFORMATION
1495 * - UNPROTECTED_SACL_SECURITY_INFORMATION
1496 * - UNPROTECTED_DACL_SECURITY_INFORMATION
1497 * - PROTECTED_SACL_SECURITY_INFORMATION
1498 * - PROTECTED_DACL_SECURITY_INFORMATION
1499 *
1500 * or use:
1501 * - ALL_SECURITY_INFORMATION
1502 *
1503 * all definitions from include/rpc_secdes.h
1504 */
1505 uint32 info_type;
1506 } in;
1507
1508 struct {
1509 /**size of the data returned*/
1510 uint32 size;
1511
1512 /**Security descriptor*/
1513 SEC_DESC *descriptor;
1514 } out;
1515};
1516
1517/**
1518 * Retrieves a key security descriptor.
1519 * @param hnd Initialized and connected server handle
1520 * @param mem_ctx Context for memory allocation
1521 * @param op Initialized parameters
1522 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1523 * @return CAC_SUCCESS The operation completed successfully
1524 */
1525
1526int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op);
1527
1528struct RegSetKeySecurity {
1529 struct {
1530 /**Handle to key to query*/
1531 POLICY_HND *key;
1532
1533 /**Info that you want. Should be a combination of (1 or more or'd):
1534 * - OWNER_SECURITY_INFORMATION
1535 * - GROUP_SECURITY_INFORMATION
1536 * - DACL_SECURITY_INFORMATION
1537 * - SACL_SECURITY_INFORMATION
1538 * - UNPROTECTED_SACL_SECURITY_INFORMATION
1539 * - UNPROTECTED_DACL_SECURITY_INFORMATION
1540 * - PROTECTED_SACL_SECURITY_INFORMATION
1541 * - PROTECTED_DACL_SECURITY_INFORMATION
1542 *
1543 * or use:
1544 * - ALL_SECURITY_INFORMATION
1545 *
1546 * all definitions from include/rpc_secdes.h
1547 */
1548 uint32 info_type;
1549
1550 /**size of the descriptor*/
1551 size_t size;
1552
1553 /**Security descriptor*/
1554 SEC_DESC *descriptor;
1555 } in;
1556};
1557
1558/**
1559 * Sets the key security descriptor.
1560 * @param hnd Initialized and connected server handle
1561 * @param mem_ctx Context for memory allocation
1562 * @param op Initialized parameters
1563 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1564 * @return CAC_SUCCESS The operation completed successfully
1565 */
1566int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op);
1567
1568/**@}*/ /*Reg_Functions*/
1569
1570struct Shutdown {
1571 struct {
1572 /**the message to display (can be NULL)*/
1573 char *message;
1574
1575 /**timeout in seconds*/
1576 uint32 timeout;
1577
1578 /**False = shutdown, True = reboot*/
1579 bool reboot;
1580
1581 /**force the*/
1582 bool force;
1583
1584 /*FIXME: make this useful*/
1585 uint32 reason;
1586 } in;
1587};
1588
1589
1590/**
1591 * Shutdown the server _not currently working_.
1592 * @param hnd Initialized and connected server handle
1593 * @param mem_ctx Context for memory allocation
1594 * @param op Initialized parameters
1595 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1596 * @return CAC_SUCCESS The operation completed successfully
1597 */
1598int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op);
1599
1600/**
1601 * Attempt to abort initiated shutdown on the server _not currently working_.
1602 * @param hnd Initialized and connected server handle
1603 * @param mem_ctx Context for memory allocation
1604 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1605 * @return CAC_SUCCESS The operation completed successfully
1606 */
1607int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx);
1608
1609/*****************
1610 * SAM Functions *
1611 *****************/
1612
1613/**@addtogroup SAM_Functions
1614 * @{
1615 */
1616struct SamConnect {
1617 struct {
1618 /**Access mask to open with
1619 * see generic access masks in include/smb.h*/
1620 uint32 access;
1621 } in;
1622
1623 struct {
1624 POLICY_HND *sam;
1625 } out;
1626};
1627
1628/**
1629 * Connects to the SAM. This can be skipped by just calling cac_SamOpenDomain()
1630 * @param hnd Initialized and connected server handle
1631 * @param mem_ctx Context for memory allocation
1632 * @param op Initialized parameters
1633 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1634 * @return CAC_SUCCESS The operation completed successfully
1635 */
1636
1637int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect *op);
1638
1639
1640/**
1641 * Closes any (SAM, domain, user, group, etc.) SAM handle.
1642 * @param hnd Initialized and connected server handle
1643 * @param mem_ctx Context for memory allocation
1644 * @param sam Handle to close
1645 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1646 * @return CAC_SUCCESS The operation completed successfully
1647 */
1648
1649int cac_SamClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sam);
1650
1651struct SamOpenDomain {
1652 struct {
1653 /**The desired access. See generic access masks - include/smb.h*/
1654 uint32 access;
1655
1656 /**(Optional) An open handle to the SAM. If it is NULL, the function will connect to the SAM with the access mask above*/
1657 POLICY_HND *sam;
1658
1659 /**(Optional) The SID of the domain to open.
1660 * If this this is NULL, the function will attempt to open the domain specified in hnd->domain */
1661 DOM_SID *sid;
1662 } in;
1663
1664 struct {
1665 /**handle to the open domain*/
1666 POLICY_HND *dom_hnd;
1667
1668 /**Handle to the open SAM*/
1669 POLICY_HND *sam;
1670 } out;
1671};
1672
1673/**
1674 * Opens a handle to a domain. This must be called before any other SAM functions
1675 * @param hnd Initialized and connected server handle
1676 * @param mem_ctx Context for memory allocation
1677 * @param op Initialized parameters
1678 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1679 * @return CAC_SUCCESS The operation completed successfully
1680 */
1681int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenDomain *op);
1682
1683struct SamCreateUser {
1684 struct {
1685 /**Open domain handle*/
1686 POLICY_HND *dom_hnd;
1687
1688 /**Username*/
1689 char *name;
1690
1691 /**See Allowable account control bits in include/smb.h*/
1692 uint32 acb_mask;
1693 } in;
1694
1695 struct {
1696 /**handle to the user*/
1697 POLICY_HND *user_hnd;
1698
1699 /**rid of the user*/
1700 uint32 rid;
1701 } out;
1702};
1703
1704/**
1705 * Creates a new domain user, if the account already exists it will _not_ be opened and hnd->status will be NT_STATUS_USER_EXISTS
1706 * @param hnd Initialized and connected server handle
1707 * @param mem_ctx Context for memory allocation
1708 * @param op Initialized parameters
1709 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1710 * @return CAC_SUCCESS The operation completed successfully
1711 */
1712
1713int cac_SamCreateUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateUser *op);
1714
1715struct SamOpenUser {
1716 struct {
1717 /**Handle to open SAM connection*/
1718 POLICY_HND *dom_hnd;
1719
1720 /**desired access - see generic access masks in include/smb.h*/
1721 uint32 access;
1722
1723 /**RID of the user*/
1724 uint32 rid;
1725
1726 /**(Optional) name of the user - must supply either RID or user name*/
1727 char *name;
1728 } in;
1729
1730 struct {
1731 /**Handle to the user*/
1732 POLICY_HND *user_hnd;
1733 } out;
1734};
1735
1736/**
1737 * Opens a domain user.
1738 * @param hnd Initialized and connected server handle
1739 * @param mem_ctx Context for memory allocation
1740 * @param op Initialized parameters
1741 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1742 * @return CAC_SUCCESS The operation completed successfully
1743 */
1744int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUser *op);
1745
1746/**
1747 * Deletes a domain user.
1748 * @param hnd Initialized and connected server handle
1749 * @param mem_ctx Context for memory allocation
1750 * @param user_hnd Open handle to the user
1751 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1752 * @return CAC_SUCCESS The operation completed successfully
1753 */
1754int cac_SamDeleteUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd);
1755
1756
1757struct SamEnumUsers {
1758 struct {
1759 /**Open handle to a domain*/
1760 POLICY_HND *dom_hnd;
1761
1762 /**Enumerate users with specific ACB. If 0, all users will be enumerated*/
1763 uint32 acb_mask;
1764 } in;
1765
1766 struct {
1767 /**where to resume from. Used over multiple calls*/
1768 uint32 resume_idx;
1769
1770 /**the number of users returned this call*/
1771 uint32 num_users;
1772
1773 /**Array storing the rids of the returned users*/
1774 uint32 *rids;
1775
1776 /**Array storing the names of all the users returned*/
1777 char **names;
1778
1779 bool done;
1780 } out;
1781};
1782
1783/**
1784 * Enumerates domain users. Can be used as a loop condition. Example: while(cac_SamEnumUsers(hnd, mem_ctx, op)) { ... }
1785 * @param hnd Initialized and connected server handle
1786 * @param mem_ctx Context for memory allocation
1787 * @param op Initialized parameters
1788 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1789 * @return CAC_SUCCESS The operation completed successfully
1790 */
1791int cac_SamEnumUsers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUsers *op);
1792
1793struct SamGetNamesFromRids {
1794 struct {
1795 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1796 POLICY_HND *dom_hnd;
1797
1798 /**Number of RIDs to resolve*/
1799 uint32 num_rids;
1800
1801 /**Array of RIDs to resolve*/
1802 uint32 *rids;
1803 } in;
1804
1805 struct {
1806 /**the number of names returned - if this is 0, the map is NULL*/
1807 uint32 num_names;
1808
1809 /**array contiaing the Names and RIDs*/
1810 CacLookupRidsRecord *map;
1811 } out;
1812};
1813
1814/**
1815 * Returns a list of names which map to a list of RIDs.
1816 * @param hnd Initialized and connected server handle
1817 * @param mem_ctx Context for memory allocation
1818 * @param op Initialized parameters
1819 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1820 * @return CAC_SUCCESS The operation completed successfully
1821 */
1822int cac_SamGetNamesFromRids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetNamesFromRids *op);
1823
1824struct SamGetRidsFromNames {
1825 struct {
1826 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1827 POLICY_HND *dom_hnd;
1828
1829 /**Number of names to resolve*/
1830 uint32 num_names;
1831
1832 /**Array of names to resolve*/
1833 char **names;
1834 } in;
1835
1836 struct {
1837 /**the number of names returned - if this is 0, then map is NULL*/
1838 uint32 num_rids;
1839
1840 /**array contiaing the Names and RIDs*/
1841 CacLookupRidsRecord *map;
1842 } out;
1843};
1844
1845/**
1846 * Returns a list of RIDs which map to a list of names.
1847 * @param hnd Initialized and connected server handle
1848 * @param mem_ctx Context for memory allocation
1849 * @param op Initialized parameters
1850 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1851 * @return CAC_SUCCESS The operation completed successfully
1852 */
1853int cac_SamGetRidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetRidsFromNames *op);
1854
1855struct SamGetGroupsForUser {
1856 struct {
1857 /**An open handle to the user*/
1858 POLICY_HND *user_hnd;
1859 } in;
1860
1861 struct {
1862 /**The number of groups the user is a member of*/
1863 uint32 num_groups;
1864
1865 /**The RIDs of the groups*/
1866 uint32 *rids;
1867
1868 /**The attributes of the groups*/
1869 uint32 *attributes;
1870 } out;
1871};
1872/**
1873 * Retrieves a list of groups that a user is a member of.
1874 * @param hnd Initialized and connected server handle
1875 * @param mem_ctx Context for memory allocation
1876 * @param op Initialized parameters
1877 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1878 * @return CAC_SUCCESS The operation completed successfully
1879 */
1880int cac_SamGetGroupsForUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupsForUser *op);
1881
1882struct SamOpenGroup {
1883 struct {
1884 /**Open handle to the domain SAM*/
1885 POLICY_HND *dom_hnd;
1886
1887 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
1888 uint32 access;
1889
1890 /**rid of the group*/
1891 uint32 rid;
1892 } in;
1893
1894 struct {
1895 /**Handle to the group*/
1896 POLICY_HND *group_hnd;
1897 } out;
1898};
1899
1900/**
1901 * Opens a domain group.
1902 * @param hnd Initialized and connected server handle
1903 * @param mem_ctx Context for memory allocation
1904 * @param op Initialized parameters
1905 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1906 * @return CAC_SUCCESS The operation completed successfully
1907 */
1908int cac_SamOpenGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGroup *op);
1909
1910struct SamCreateGroup {
1911 struct {
1912 /**Open handle to the domain SAM*/
1913 POLICY_HND *dom_hnd;
1914
1915 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
1916 uint32 access;
1917
1918 /**The name of the group*/
1919 char *name;
1920 } in;
1921
1922 struct {
1923 /**Handle to the group*/
1924 POLICY_HND *group_hnd;
1925 } out;
1926};
1927
1928/**
1929 * Creates a group. If the group already exists it will not be opened.
1930 * @param hnd Initialized and connected server handle
1931 * @param mem_ctx Context for memory allocation
1932 * @param op Initialized parameters
1933 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1934 * @return CAC_SUCCESS The operation completed successfully
1935 */
1936int cac_SamCreateGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateGroup *op);
1937
1938/**
1939 * Deletes a domain group.
1940 * @param hnd Initialized and connected server handle
1941 * @param mem_ctx Context for memory allocation
1942 * @param group_hnd Open handle to the group.
1943 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1944 * @return CAC_SUCCESS The operation completed successfully
1945 */
1946int cac_SamDeleteGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd);
1947
1948struct SamGetGroupMembers {
1949 struct {
1950 /**Open handle to a group*/
1951 POLICY_HND *group_hnd;
1952 } in;
1953
1954 struct {
1955 /**The number of members in the group*/
1956 uint32 num_members;
1957
1958 /**An array storing the RIDs of the users*/
1959 uint32 *rids;
1960
1961 /**The attributes*/
1962 uint32 *attributes;
1963 } out;
1964};
1965
1966/**
1967 * Retrives a list of users in a group.
1968 * @param hnd Initialized and connected server handle
1969 * @param mem_ctx Context for memory allocation
1970 * @param op Initialized parameters
1971 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1972 * @return CAC_SUCCESS The operation completed successfully
1973 */
1974int cac_SamGetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupMembers *op);
1975
1976struct SamAddGroupMember {
1977 struct {
1978 /**Open handle to a group*/
1979 POLICY_HND *group_hnd;
1980
1981 /**RID of new member*/
1982 uint32 rid;
1983 } in;
1984};
1985
1986/**
1987 * Adds a user to a group.
1988 * @param hnd Initialized and connected server handle
1989 * @param mem_ctx Context for memory allocation
1990 * @param op Initialized parameters
1991 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1992 * @return CAC_SUCCESS The operation completed successfully
1993 */
1994int cac_SamAddGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddGroupMember *op);
1995
1996struct SamRemoveGroupMember {
1997 struct {
1998 /**Open handle to a group*/
1999 POLICY_HND *group_hnd;
2000
2001 /**RID of member to remove*/
2002 uint32 rid;
2003 } in;
2004};
2005
2006/**
2007 * Removes a user from a group.
2008 * @param hnd Initialized and connected server handle
2009 * @param mem_ctx Context for memory allocation
2010 * @param op Initialized parameters
2011 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2012 * @return CAC_SUCCESS The operation completed successfully
2013 */
2014int cac_SamRemoveGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveGroupMember *op);
2015
2016/**
2017 * Removes all the members of a group - warning: if this function fails is is possible that some but not all members were removed
2018 * @param hnd Initialized and connected server handle
2019 * @param mem_ctx Context for memory allocation
2020 * @param group_hnd Open handle to the group to clear
2021 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2022 * @return CAC_SUCCESS The operation completed successfully
2023 */
2024int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd);
2025
2026struct SamSetGroupMembers {
2027 struct {
2028 /**Open handle to the group*/
2029 POLICY_HND *group_hnd;
2030
2031 /**Number of members in the group - if this is 0, all members of the group will be removed*/
2032 uint32 num_members;
2033
2034 /**The RIDs of the users to add*/
2035 uint32 *rids;
2036 } in;
2037};
2038
2039/**
2040 * Clears the members of a group and adds a list of members to the group
2041 * @param hnd Initialized and connected server handle
2042 * @param mem_ctx Context for memory allocation
2043 * @param op Initialized parameters
2044 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2045 * @return CAC_SUCCESS The operation completed successfully
2046 */
2047int cac_SamSetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupMembers *op);
2048
2049struct SamEnumGroups {
2050 struct {
2051 /**Open handle to a domain*/
2052 POLICY_HND *dom_hnd;
2053 } in;
2054
2055 struct {
2056 /**Where to resume from _do not_ modify this value. Used over multiple calls.*/
2057 uint32 resume_idx;
2058
2059 /**the number of users returned this call*/
2060 uint32 num_groups;
2061
2062 /**Array storing the rids of the returned groups*/
2063 uint32 *rids;
2064
2065 /**Array storing the names of all the groups returned*/
2066 char **names;
2067
2068 /**Array storing the descriptions of all the groups returned*/
2069 char **descriptions;
2070
2071 bool done;
2072 } out;
2073};
2074
2075/**
2076 * Enumerates domain groups. Can be used as a loop condition. Example: while(cac_SamEnumGroups(hnd, mem_ctx, op)) { ... }
2077 * @param hnd Initialized and connected server handle
2078 * @param mem_ctx Context for memory allocation
2079 * @param op Initialized parameters
2080 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2081 * @return CAC_SUCCESS The operation completed successfully
2082 */
2083int cac_SamEnumGroups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumGroups *op);
2084
2085struct SamEnumAliases {
2086 struct {
2087 /**Open handle to a domain*/
2088 POLICY_HND *dom_hnd;
2089 } in;
2090
2091 struct {
2092 /**where to resume from. Used over multiple calls*/
2093 uint32 resume_idx;
2094
2095 /**the number of users returned this call*/
2096 uint32 num_aliases;
2097
2098 /**Array storing the rids of the returned groups*/
2099 uint32 *rids;
2100
2101 /**Array storing the names of all the groups returned*/
2102 char **names;
2103
2104 /**Array storing the descriptions of all the groups returned*/
2105 char **descriptions;
2106
2107 bool done;
2108 } out;
2109};
2110
2111/**
2112 * Enumerates domain aliases. Can be used as a loop condition. Example: while(cac_SamEnumAliases(hnd, mem_ctx, op)) { ... }
2113 * @param hnd Initialized and connected server handle
2114 * @param mem_ctx Context for memory allocation
2115 * @param op Initialized parameters
2116 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2117 * @return CAC_SUCCESS The operation completed successfully
2118 */
2119int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumAliases *op);
2120
2121struct SamCreateAlias {
2122 struct {
2123 /**Open handle to the domain SAM*/
2124 POLICY_HND *dom_hnd;
2125
2126 /**The name of the alias*/
2127 char *name;
2128 } in;
2129
2130 struct {
2131 /**Handle to the group*/
2132 POLICY_HND *alias_hnd;
2133 } out;
2134};
2135
2136/**
2137 * Creates an alias. If the alias already exists it will not be opened.
2138 * @param hnd Initialized and connected server handle
2139 * @param mem_ctx Context for memory allocation
2140 * @param op Initialized parameters
2141 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2142 * @return CAC_SUCCESS The operation completed successfully
2143 */
2144
2145int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op);
2146
2147struct SamOpenAlias {
2148 struct {
2149 /**Open handle to the domain SAM*/
2150 POLICY_HND *dom_hnd;
2151
2152 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
2153 uint32 access;
2154
2155 /**rid of the alias*/
2156 uint32 rid;
2157 } in;
2158
2159 struct {
2160 /**Handle to the alias*/
2161 POLICY_HND *alias_hnd;
2162 } out;
2163};
2164
2165/**
2166 * Opens a handle to an alias.
2167 * @param hnd Initialized and connected server handle
2168 * @param mem_ctx Context for memory allocation
2169 * @param op Initialized parameters
2170 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2171 * @return CAC_SUCCESS The operation completed successfully
2172 */
2173int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op);
2174
2175/**
2176 * Deletes an alias.
2177 * @param hnd Initialized and connected server handle
2178 * @param mem_ctx Context for memory allocation
2179 * @param alias_hnd Open handle to the alias
2180 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2181 * @return CAC_SUCCESS The operation completed successfully
2182 */
2183int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd);
2184
2185struct SamAddAliasMember {
2186 struct {
2187 /**Open handle to a alias*/
2188 POLICY_HND *alias_hnd;
2189
2190 /**SID of new member*/
2191 DOM_SID *sid;
2192 } in;
2193};
2194
2195/**
2196 * Adds an account to an alias.
2197 * @param hnd Initialized and connected server handle
2198 * @param mem_ctx Context for memory allocation
2199 * @param op Initialized parameters
2200 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2201 * @return CAC_SUCCESS The operation completed successfully
2202 */
2203int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op);
2204
2205struct SamRemoveAliasMember {
2206 struct {
2207 /**Open handle to the alias*/
2208 POLICY_HND *alias_hnd;
2209
2210 /**The SID of the member*/
2211 DOM_SID *sid;
2212 } in;
2213};
2214
2215/**
2216 * Removes an account from an alias.
2217 * @param hnd Initialized and connected server handle
2218 * @param mem_ctx Context for memory allocation
2219 * @param op Initialized parameters
2220 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2221 * @return CAC_SUCCESS The operation completed successfully
2222 */
2223int cac_SamRemoveAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveAliasMember *op);
2224
2225struct SamGetAliasMembers {
2226 struct {
2227 /**Open handle to the alias*/
2228 POLICY_HND *alias_hnd;
2229 } in;
2230
2231 struct {
2232 /**The number of members*/
2233 uint32 num_members;
2234
2235 /**An array storing the SIDs of the accounts*/
2236 DOM_SID *sids;
2237 } out;
2238};
2239
2240/**
2241 * Retrieves a list of all accounts in an alias.
2242 * @param hnd Initialized and connected server handle
2243 * @param mem_ctx Context for memory allocation
2244 * @param op Initialized parameters
2245 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2246 * @return CAC_SUCCESS The operation completed successfully
2247 */
2248int cac_SamGetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasMembers *op);
2249
2250/**
2251 * Removes all the members of an alias - warning: if this function fails is is possible that some but not all members were removed
2252 * @param hnd Initialized and connected server handle
2253 * @param mem_ctx Context for memory allocation
2254 * @param alias_hnd Handle to the alias to clear
2255 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2256 * @return CAC_SUCCESS The operation completed successfully
2257 */
2258
2259int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd);
2260
2261struct SamSetAliasMembers {
2262 struct {
2263 /**Open handle to the group*/
2264 POLICY_HND *alias_hnd;
2265
2266 /**Number of members in the group - if this is 0, all members of the group will be removed*/
2267 uint32 num_members;
2268
2269 /**The SIDs of the accounts to add*/
2270 DOM_SID *sids;
2271 } in;
2272};
2273
2274/**
2275 * Clears the members of an alias and adds a list of members to the alias
2276 * @param hnd Initialized and connected server handle
2277 * @param mem_ctx Context for memory allocation
2278 * @param op Initialized parameters
2279 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2280 * @return CAC_SUCCESS The operation completed successfully
2281 */
2282int cac_SamSetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasMembers *op);
2283
2284
2285struct SamUserChangePasswd {
2286 struct {
2287 /**The username*/
2288 char *username;
2289
2290 /**The current password*/
2291 char *password;
2292
2293 /**The new password*/
2294 char *new_password;
2295 } in;
2296};
2297/**Used by a user to change their password*/
2298int cac_SamUserChangePasswd(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamUserChangePasswd *op);
2299
2300/**
2301 * Enables a user
2302 * @param hnd Initialized and connected server handle
2303 * @param mem_ctx Context for memory allocation
2304 * @param user_hnd Open handle to the user to enable
2305 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2306 * @return CAC_SUCCESS The operation completed successfully
2307 */
2308int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd);
2309
2310/**
2311 * Disables a user
2312 * @param hnd Initialized and connected server handle
2313 * @param mem_ctx Context for memory allocation
2314 * @param user_hnd Open handle to the user to disables
2315 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2316 * @return CAC_SUCCESS The operation completed successfully
2317 */
2318int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd);
2319
2320struct SamSetPassword {
2321 struct {
2322 /**Open handle to a user*/
2323 POLICY_HND *user_hnd;
2324
2325 /**The new password*/
2326 char *password;
2327 } in;
2328};
2329
2330/**
2331 * Sets a user's password
2332 * @param hnd Initialized and connected server handle
2333 * @param mem_ctx Context for memory allocation
2334 * @param op Initialized parameters
2335 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2336 * @return CAC_SUCCESS The operation completed successfully
2337 */
2338
2339int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetPassword *op);
2340
2341struct SamGetUserInfo {
2342 struct {
2343 /**Open Handle to a user*/
2344 POLICY_HND *user_hnd;
2345 } in;
2346
2347 struct {
2348 CacUserInfo *info;
2349 } out;
2350};
2351
2352/**
2353 * Retrieves user information using a CacUserInfo structure. If you would like to use a SAM_USERINFO_CTR directly, use cac_SamGetUserInfoCtr()
2354 * @param hnd Initialized and connected server handle
2355 * @param mem_ctx Context for memory allocation
2356 * @param op Initialized parameters
2357 * @see cac_SamGetUserInfoCtr()
2358 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2359 * @return CAC_SUCCESS The operation completed successfully
2360 */
2361int cac_SamGetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfo *op);
2362
2363struct SamSetUserInfo {
2364 struct {
2365 /**Open handle to a user*/
2366 POLICY_HND *user_hnd;
2367
2368 /**Structure containing the data you would like to set*/
2369 CacUserInfo *info;
2370 } in;
2371};
2372
2373/**
2374 * Sets the user info using a CacUserInfo structure. If you would like to use a SAM_USERINFO_CTR directly use cac_SamSetUserInfoCtr().
2375 * @note All fields in the CacUserInfo structure will be set. Best to call cac_GetUserInfo() modify fields that you want, and then call cac_SetUserInfo().
2376 * @note When calling this, you _must_ set the user's password.
2377 * @param hnd Initialized and connected server handle
2378 * @param mem_ctx Context for memory allocation
2379 * @param op Initialized parameters
2380 * @see cac_SamSetUserInfoCtr()
2381 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2382 * @return CAC_SUCCESS The operation completed successfully
2383 */
2384int cac_SamSetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfo *op);
2385
2386struct SamGetUserInfoCtr {
2387 struct {
2388 /**Open handle to a user*/
2389 POLICY_HND *user_hnd;
2390
2391 /**What USER_INFO structure you want. See include/rpc_samr.h*/
2392 uint16 info_class;
2393 } in;
2394
2395 struct {
2396 /**returned user info*/
2397 SAM_USERINFO_CTR *ctr;
2398 } out;
2399};
2400
2401/**
2402 * Retrieves user information using a SAM_USERINFO_CTR structure. If you don't want to use this structure, user SamGetUserInfo()
2403 * @param hnd Initialized and connected server handle
2404 * @param mem_ctx Context for memory allocation
2405 * @param op Initialized parameters
2406 * @see cac_SamGetUserInfo()
2407 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2408 * @return CAC_SUCCESS The operation completed successfully
2409 */
2410int cac_SamGetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfoCtr *op);
2411
2412struct SamSetUserInfoCtr {
2413 struct {
2414 /**Open handle to a user*/
2415 POLICY_HND *user_hnd;
2416
2417 /**user info - make sure ctr->switch_value is set properly*/
2418 SAM_USERINFO_CTR *ctr;
2419 } in;
2420};
2421
2422/**
2423 * Sets the user info using a SAM_USERINFO_CTR structure. If you don't want to use this structure, use cac_SamSetUserInfo()
2424 * @param hnd Initialized and connected server handle
2425 * @param mem_ctx Context for memory allocation
2426 * @param op Initialized parameters
2427 * @see cac_SamSetUserInfo()
2428 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2429 * @return CAC_SUCCESS The operation completed successfully
2430 */
2431
2432int cac_SamSetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfoCtr *op);
2433
2434struct SamRenameUser {
2435 struct {
2436 /**Open handle to user*/
2437 POLICY_HND *user_hnd;
2438
2439 /**New user name*/
2440 char *new_name;
2441 } in;
2442};
2443
2444/**
2445 * Changes the name of a user.
2446 * @param hnd Initialized and connected server handle
2447 * @param mem_ctx Context for memory allocation
2448 * @param op Initialized parameters
2449 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2450 * @return CAC_SUCCESS The operation completed successfully
2451 */
2452int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameUser *op);
2453
2454struct SamGetGroupInfo {
2455 struct {
2456 /**Open handle to a group*/
2457 POLICY_HND *group_hnd;
2458 } in;
2459
2460 struct {
2461 /**Returned info about the group*/
2462 CacGroupInfo *info;
2463 } out;
2464};
2465
2466/**
2467 * Retrieves information about a group.
2468 * @param hnd Initialized and connected server handle
2469 * @param mem_ctx Context for memory allocation
2470 * @param op Initialized parameters
2471 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2472 * @return CAC_SUCCESS The operation completed successfully
2473 */
2474int cac_SamGetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupInfo *op);
2475
2476struct SamSetGroupInfo {
2477 struct {
2478 /**Open handle to a group*/
2479 POLICY_HND *group_hnd;
2480
2481 /**group info*/
2482 CacGroupInfo *info;
2483 } in;
2484};
2485
2486/**
2487 * Sets information about a group.
2488 * @param hnd Initialized and connected server handle
2489 * @param mem_ctx Context for memory allocation
2490 * @param op Initialized parameters
2491 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2492 * @return CAC_SUCCESS The operation completed successfully
2493 */
2494int cac_SamSetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupInfo *op);
2495
2496struct SamRenameGroup {
2497 struct {
2498 /**Open handle to a group*/
2499 POLICY_HND *group_hnd;
2500
2501 /**New name*/
2502 char *new_name;
2503 } in;
2504};
2505
2506/**
2507 * Changes the name of a group
2508 * @param hnd Initialized and connected server handle
2509 * @param mem_ctx Context for memory allocation
2510 * @param op Initialized parameters
2511 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2512 * @return CAC_SUCCESS The operation completed successfully
2513 */
2514
2515int cac_SamRenameGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameGroup *op);
2516
2517struct SamGetAliasInfo {
2518 struct {
2519 /**Open handle to an alias*/
2520 POLICY_HND *alias_hnd;
2521 } in;
2522
2523 struct {
2524 /**Returned alias info*/
2525 CacAliasInfo *info;
2526 } out;
2527};
2528
2529/**
2530 * Retrieves information about an alias.
2531 * @param hnd Initialized and connected server handle
2532 * @param mem_ctx Context for memory allocation
2533 * @param op Initialized parameters
2534 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2535 * @return CAC_SUCCESS The operation completed successfully
2536 */
2537int cac_SamGetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasInfo *op);
2538
2539struct SamSetAliasInfo {
2540 struct {
2541 /**Open handle to an alias*/
2542 POLICY_HND *alias_hnd;
2543
2544 /**Returned alias info*/
2545 CacAliasInfo *info;
2546 } in;
2547};
2548
2549/**
2550 * Sets information about an alias.
2551 * @param hnd Initialized and connected server handle
2552 * @param mem_ctx Context for memory allocation
2553 * @param op Initialized parameters
2554 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2555 * @return CAC_SUCCESS The operation completed successfully
2556 */
2557int cac_SamSetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasInfo *op);
2558
2559struct SamGetDomainInfo {
2560 struct {
2561 /**Open handle to the domain SAM*/
2562 POLICY_HND *dom_hnd;
2563 } in;
2564
2565 struct {
2566 /**Returned domain info*/
2567 CacDomainInfo *info;
2568 } out;
2569};
2570
2571/**
2572 * Gets domain information in the form of a CacDomainInfo structure.
2573 * @param hnd Initialized and connected server handle
2574 * @param mem_ctx Context for memory allocation
2575 * @param op Initialized parameters
2576 * @see SamGetDomainInfoCtr()
2577 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2578 * @return CAC_SUCCESS - the operation was successful
2579 * @return CAC_PARTIAL_SUCCESS - This function makes 3 rpc calls, if one or two fail and the rest succeed,
2580 * not all fields in the CacDomainInfo structure will be filled
2581 */
2582int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfo *op);
2583
2584struct SamGetDomainInfoCtr {
2585 struct {
2586 /**Open handle to domain*/
2587 POLICY_HND *dom_hnd;
2588
2589 /**What info level you want*/
2590 uint16 info_class;
2591 } in;
2592
2593 struct {
2594 SAM_UNK_CTR *info;
2595 } out;
2596};
2597
2598/**
2599 * Gets domain information in the form of a SAM_UNK_CTR structure.
2600 * @param hnd Initialized and connected server handle
2601 * @param mem_ctx Context for memory allocation
2602 * @param op Initialized parameters
2603 * @see SamGetDomainInfo()
2604 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2605 * @return CAC_SUCCESS - the operation was successful
2606 */
2607int cac_SamGetDomainInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfoCtr *op);
2608
2609struct SamGetDisplayInfo {
2610 struct {
2611 /**Open handle to domain*/
2612 POLICY_HND *dom_hnd;
2613
2614 /**What type of data*/
2615 uint16 info_class;
2616
2617 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2618 uint32 max_entries;
2619
2620 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2621 uint32 max_size;
2622 } in;
2623
2624 struct {
2625 /**Do not modify this value, use the same value between multiple calls (ie in while loop)*/
2626 uint32 resume_idx;
2627
2628 /**Number of entries returned*/
2629 uint32 num_entries;
2630
2631 /**Returned display info*/
2632 SAM_DISPINFO_CTR ctr;
2633
2634 /**Internal value. Do not modify.*/
2635 uint32 loop_count;
2636
2637 bool done;
2638 } out;
2639};
2640
2641/**
2642 * Gets dislpay information using a SAM_DISPINFO_CTR.
2643 * @param hnd Initialized and connected server handle
2644 * @param mem_ctx Context for memory allocation
2645 * @param op Initialized parameters
2646 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2647 * @return CAC_SUCCESS - the operation was successful
2648 */
2649int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDisplayInfo *op);
2650
2651struct SamLookupDomain {
2652 struct {
2653 /**Open handle to the sam (opened with cac_SamConnect() or cac_SamOpenDomain()*/
2654 POLICY_HND *sam;
2655
2656 /**Name of the domain to lookup*/
2657 char *name;
2658 } in;
2659
2660 struct {
2661 /**SID of the domain*/
2662 DOM_SID *sid;
2663 } out;
2664};
2665
2666/**
2667 * Looks up a Domain SID given it's name.
2668 * @param hnd Initialized and connected server handle
2669 * @param mem_ctx Context for memory allocation
2670 * @param op Initialized parameters
2671 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2672 * @return CAC_SUCCESS - the operation was successful
2673 */
2674int cac_SamLookupDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLookupDomain *op);
2675
2676struct SamGetSecurityObject {
2677 struct {
2678 /**An open handle (SAM, domain or user)*/
2679 POLICY_HND *pol;
2680 } in;
2681
2682 struct {
2683 SEC_DESC_BUF *sec;
2684 } out;
2685};
2686
2687/**
2688 * Retrievies Security descriptor information for a SAM/Domain/user
2689 * @param hnd Initialized and connected server handle
2690 * @param mem_ctx Context for memory allocation
2691 * @param op Initialized parameters
2692 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2693 * @return CAC_SUCCESS - the operation was successful
2694 */
2695int cac_SamGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetSecurityObject *op);
2696
2697struct SamFlush {
2698 struct {
2699 /**Open handle to the domain SAM*/
2700 POLICY_HND *dom_hnd;
2701
2702 /**(Optional)Domain SID. If NULL, the domain in hnd->domain will be opened*/
2703 DOM_SID *sid;
2704
2705 /**(Optional)Desired access to re-open the domain with. If 0, MAXIMUM_ALLOWED_ACCESS is used.*/
2706 uint32 access;
2707 } in;
2708};
2709
2710/**
2711 * Closes the domain handle, then re-opens it - effectively flushing any changes made.
2712 * WARNING: if this fails you will no longer have an open handle to the domain SAM.
2713 * @param hnd Initialized and connected server handle
2714 * @param mem_ctx Context for memory allocation
2715 * @param op Initialized Parameters
2716 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2717 * @return CAC_SUCCESS - the operation was successful
2718 */
2719int cac_SamFlush(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op);
2720
2721/**@}*/ /*SAM_Functions*/
2722
2723/**@addtogroup SCM_Functions
2724 * @{
2725 */
2726
2727struct SvcOpenScm {
2728 struct {
2729 /**Desired access to open the Handle with. See SC_RIGHT_MGR_* or SC_MANAGER_* in include/rpc_secdes.h*/
2730 uint32 access;
2731 } in;
2732
2733 struct {
2734 /**Handle to the SCM*/
2735 POLICY_HND *scm_hnd;
2736 } out;
2737};
2738
2739/**
2740 * Opens a handle to the SCM on the remote machine.
2741 * @param hnd Initialized and connected server handle
2742 * @param mem_ctx Context for memory allocation
2743 * @param op Initialized parameters
2744 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2745 * @return CAC_SUCCESS - the operation was successful
2746 */
2747int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm *op);
2748
2749/**
2750 * Closes an Svc handle (SCM or Service)
2751 * @param hnd Initialized and connected server handle
2752 * @param mem_ctx Context for memory allocation
2753 * @param scm_hnd The handle to close
2754 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2755 * @return CAC_SUCCESS - the operation was successful
2756 */
2757int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd);
2758
2759struct SvcEnumServices {
2760 struct {
2761 /**Open handle to the SCM*/
2762 POLICY_HND *scm_hnd;
2763
2764 /**(Optional)Type of service to enumerate. Possible values:
2765 * - SVCCTL_TYPE_WIN32
2766 * - SVCCTL_TYPE_DRIVER
2767 * If this is 0, (SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32) is assumed.
2768 */
2769 uint32 type;
2770
2771 /**(Optional)State of service to enumerate. Possible values:
2772 * - SVCCTL_STATE_ACTIVE
2773 * - SVCCTL_STATE_INACTIVE
2774 * - SVCCTL_STATE_ALL
2775 * If this is 0, SVCCTL_STATE_ALL is assumed.
2776 */
2777 uint32 state;
2778 } in;
2779
2780 struct {
2781 /**Number of services returned*/
2782 uint32 num_services;
2783
2784 /**Array of service structures*/
2785 CacService *services;
2786 } out;
2787};
2788
2789/**
2790 * Enumerates services on the remote machine.
2791 * @param hnd Initialized and connected server handle
2792 * @param mem_ctx Context for memory allocation
2793 * @param op Initialized parameters
2794 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2795 * @return CAC_SUCCESS - the operation was successful
2796 */
2797int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnumServices *op);
2798
2799struct SvcOpenService {
2800 struct {
2801 /**Handle to the Service Control Manager*/
2802 POLICY_HND *scm_hnd;
2803
2804 /**Access mask to open service with see SERVICE_* or SC_RIGHT_SVC_* in include/rpc_secdes.h*/
2805 uint32 access;
2806
2807 /**The name of the service. _not_ the display name*/
2808 char *name;
2809 } in;
2810
2811 struct {
2812 /**Handle to the open service*/
2813 POLICY_HND *svc_hnd;
2814 } out;
2815};
2816
2817/**
2818 * Opens a handle to a service.
2819 * @param hnd Initialized and connected server handle
2820 * @param mem_ctx Context for memory allocation
2821 * @param op Initialized Parameters
2822 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2823 * @return CAC_SUCCESS - the operation was successful
2824 */
2825
2826int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenService *op);
2827
2828struct SvcGetStatus {
2829 struct {
2830 /**Open handle to the service to query*/
2831 POLICY_HND *svc_hnd;
2832 } in;
2833
2834 struct {
2835 /**The status of the service. See include/rpc_svcctl.h for SERVICE_STATUS definition.*/
2836 SERVICE_STATUS status;
2837 } out;
2838};
2839
2840/**
2841 * Retrieves the status of a service.
2842 * @param hnd Initialized and connected server handle
2843 * @param mem_ctx Context for memory allocation
2844 * @param op Initialized Parameters
2845 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2846 * @return CAC_SUCCESS - the operation was successful
2847 */
2848int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetStatus *op);
2849
2850struct SvcStartService {
2851 struct {
2852 /**open handle to the service*/
2853 POLICY_HND *svc_hnd;
2854
2855 /**Array of parameters to start the service with. Can be NULL if num_parms is 0*/
2856 char **parms;
2857
2858 /**Number of parameters in the parms array*/
2859 uint32 num_parms;
2860
2861 /**Number of seconds to wait for the service to actually start. If this is 0, then the status will not be checked after the initial call*/
2862 uint32 timeout;
2863 } in;
2864};
2865
2866/**
2867 * Attempts to start a service.
2868 * @param hnd Initialized and connected server handle
2869 * @param mem_ctx Context for memory allocation
2870 * @param op Initialized Parameters
2871 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2872 * @return CAC_SUCCESS - the operation was successful
2873 */
2874
2875int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStartService *op);
2876
2877struct SvcControlService {
2878 struct {
2879 /**Open handle to the service to control*/
2880 POLICY_HND *svc_hnd;
2881
2882 /**The control operation to perform. Possible values (from include/rpc_svcctl.h):
2883 * - SVCCTL_CONTROL_STOP
2884 * - SVCCTL_CONTROL_PAUSE
2885 * - SVCCTL_CONTROL_CONTINUE
2886 * - SVCCTL_CONTROL_SHUTDOWN
2887 */
2888 uint32 control;
2889 } in;
2890
2891 struct {
2892 /**The returned status of the service, _immediately_ after the call*/
2893 SERVICE_STATUS *status;
2894 } out;
2895};
2896
2897/**
2898 * Performs a control operation on a service and _immediately_ returns.
2899 * @see cac_SvcStopService()
2900 * @see cac_SvcPauseService()
2901 * @see cac_SvcContinueService()
2902 * @see cac_SvcShutdownService()
2903 * @param hnd Initialized and connected server handle
2904 * @param mem_ctx Context for memory allocation
2905 * @param op Initialized Parameters
2906 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2907 * @return CAC_SUCCESS - the operation was successful
2908 */
2909int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcControlService *op);
2910
2911struct SvcStopService {
2912 struct {
2913 /**Open handle to the service*/
2914 POLICY_HND *svc_hnd;
2915
2916 /**Number of seconds to wait for the service to actually start.
2917 * If this is 0, then the status will not be checked after the initial call and CAC_SUCCESS might be returned if the status isn't actually started
2918 */
2919 uint32 timeout;
2920 } in;
2921
2922 struct {
2923 /**Status of the service after the operation*/
2924 SERVICE_STATUS status;
2925 } out;
2926};
2927
2928/**
2929 * Attempts to stop a service.
2930 * @see cacSvcControlService()
2931 * @param hnd Initialized and connected server handle
2932 * @param mem_ctx Context for memory allocation
2933 * @param op Initialized Parameters
2934 * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured.
2935 * @return CAC_SUCCESS - the operation was successful
2936 */
2937int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStopService *op);
2938
2939struct SvcPauseService {
2940 struct {
2941 /**Open handle to the service*/
2942 POLICY_HND *svc_hnd;
2943
2944 /**Number of seconds to wait for the service to actually start.
2945 * If this is 0, then the status will not be checked after the initial call and CAC_SUCCESS might be returned if the status isn't actually started
2946 */
2947 uint32 timeout;
2948 } in;
2949
2950 struct {
2951 /**Status of the service after the operation*/
2952 SERVICE_STATUS status;
2953 } out;
2954};
2955
2956/**
2957 * Attempts to pause a service.
2958 * @see cacSvcControlService()
2959 * @param hnd Initialized and connected server handle
2960 * @param mem_ctx Context for memory allocation
2961 * @param op Initialized Parameters
2962 * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured.
2963 * @return CAC_SUCCESS - the operation was successful
2964 */
2965int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPauseService *op);
2966
2967struct SvcContinueService {
2968 struct {
2969 /**Open handle to the service*/
2970 POLICY_HND *svc_hnd;
2971
2972 /**Number of seconds to wait for the service to actually start.
2973 * If this is 0, then the status will not be checked after the initial call and CAC_SUCCESS might be returned if the status isn't actually started
2974 */
2975 uint32 timeout;
2976 } in;
2977
2978 struct {
2979 /**Status of the service after the operation*/
2980 SERVICE_STATUS status;
2981 } out;
2982};
2983
2984/**
2985 * Attempts to continue a paused service.
2986 * @see cacSvcControlService()
2987 * @param hnd Initialized and connected server handle
2988 * @param mem_ctx Context for memory allocation
2989 * @param op Initialized Parameters
2990 * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured.
2991 * @return CAC_SUCCESS - the operation was successful
2992 */
2993int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcContinueService *op);
2994
2995struct SvcGetDisplayName {
2996 struct {
2997 /**Open handle to the service*/
2998 POLICY_HND *svc_hnd;
2999 } in;
3000
3001 struct {
3002 /**The returned display name of the service*/
3003 char *display_name;
3004 } out;
3005};
3006
3007/**
3008 * Retrieves the display name of a service _not currently working_
3009 * @param hnd Initialized and connected server handle
3010 * @param mem_ctx Context for memory allocation
3011 * @param op Initialized Parameters
3012 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
3013 * @return CAC_SUCCESS - the operation was successful
3014 */
3015int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetDisplayName *op);
3016
3017struct SvcGetServiceConfig {
3018 struct {
3019 /**Open handle to the service*/
3020 POLICY_HND *svc_hnd;
3021 } in;
3022
3023 struct {
3024 /**Returned Configuration information*/
3025 CacServiceConfig config;
3026 } out;
3027};
3028
3029/**
3030 * Retrieves configuration information about a service.
3031 * @param hnd Initialized and connected server handle
3032 * @param mem_ctx Context for memory allocation
3033 * @param op Initialized Parameters
3034 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
3035 * @return CAC_SUCCESS - the operation was successful
3036 */
3037int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetServiceConfig *op);
3038
3039/**@}*/ /*SCM_Functions*/
3040
3041struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx);
3042
3043#endif /* LIBMSRPC_H */
3044
3045
Note: See TracBrowser for help on using the repository browser.