Fix typo.
[Samba/gebeck_regimport.git] / source3 / include / libmsrpc.h
blob3f2a7260ca08b56769afb56c71454343929c2db7
1 /*
2 * Unix SMB/CIFS implementation.
3 * MS-RPC client library API definitions/prototypes
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.
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.
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/>.
21 #ifndef LIBMSRPC_H
22 #define LIBMSRPC_H
25 #include "includes.h"
26 #include "libsmbclient.h"
27 #include "libsmb_internal.h"
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
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*/
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
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)
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"
102 * @addtogroup lsa_defs
103 * @{
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
110 /**Used when requesting machine domain information*/
111 #define CAC_DOMAIN_INFO 0x0003
113 /**Used when requesting machine local information*/
114 #define CAC_LOCAL_INFO 0x0005
116 /**Stores information about a SID*/
117 typedef struct _CACSIDINFO {
118 /**The actual SID*/
119 DOM_SID sid;
121 /**The name of the object which maps to this SID*/
122 char *name;
124 /**The domain the SID belongs to*/
125 char *domain;
126 } CacSidInfo;
127 /* @} */
130 * @addtogroup reg_defs
131 * @{
133 /**Null terminated string*/
134 typedef char* REG_SZ_DATA;
136 /**Null terminated string with windows environment variables that should be expanded*/
137 typedef char* REG_EXPAND_SZ_DATA;
139 /**Binary data of some kind*/
140 typedef struct _REGBINARYDATA {
141 uint32 data_length;
142 uint8 * data;
143 } REG_BINARY_DATA;
145 /**32-bit (little endian) number*/
146 typedef uint32 REG_DWORD_DATA;
148 /**32-bit big endian number*/
149 typedef uint32 REG_DWORD_BE_DATA;
151 /**array of strings*/
152 typedef struct _REGMULTISZDATA {
153 uint32 num_strings;
155 char **strings;
156 } REG_MULTI_SZ_DATA;
158 typedef 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 /**@}*/
169 * @addtogroup sam_defs
170 * @{
173 #define CAC_USER_RID 0x1
174 #define CAC_GROUP_RID 0x2
176 typedef struct _CACLOOKUPRIDSRECORD {
177 char *name;
178 uint32 rid;
180 /**If found, this will be one of:
181 * - CAC_USER_RID
182 * - CAC_GROUP_RID
184 uint32 type;
186 /*if the name or RID was looked up, then found = True*/
187 bool found;
188 } CacLookupRidsRecord;
190 typedef struct _CACUSERINFO {
191 /**Last logon time*/
192 time_t logon_time;
194 /**Last logoff time*/
195 time_t logoff_time;
197 /**Last kickoff time*/
198 time_t kickoff_time;
200 /**Last password set time*/
201 time_t pass_last_set_time;
203 /**Time password can change*/
204 time_t pass_can_change_time;
206 /**Time password must change*/
207 time_t pass_must_change_time;
209 /**LM user password*/
210 uint8 lm_password[8];
212 /**NT user password*/
213 uint8 nt_password[8];
215 /**User's RID*/
216 uint32 rid;
218 /**RID of primary group*/
219 uint32 group_rid;
221 /**User's ACB mask*/
222 uint32 acb_mask;
224 /**Bad password count*/
225 uint16 bad_passwd_count;
227 /**Number of logons*/
228 uint16 logon_count;
230 /**Change password at next logon?*/
231 bool pass_must_change;
233 /**Username*/
234 char *username;
236 /**User's full name*/
237 char *full_name;
239 /**User's home directory*/
240 char *home_dir;
242 /**Home directory drive*/
243 char *home_drive;
245 /**Logon script*/
246 char *logon_script;
248 /**Path to profile*/
249 char *profile_path;
251 /**Account description*/
252 char *description;
254 /**Login from workstations*/
255 char *workstations;
257 char *dial;
259 /**Possible logon hours*/
260 LOGON_HRS *logon_hours;
262 } CacUserInfo;
264 typedef struct _CACGROUPINFO {
265 /**Group name*/
266 char *name;
268 /**Description*/
269 char *description;
271 /**Number of members*/
272 uint32 num_members;
273 } CacGroupInfo, CacAliasInfo;
275 /**Represents a period (duration) of time*/
276 typedef struct _CACTIME {
277 /**Number of days*/
278 uint32 days;
280 /**Number of hours*/
281 uint32 hours;
283 /**Number of minutes*/
284 uint32 minutes;
286 /**number of seconds*/
287 uint32 seconds;
288 } CacTime;
291 typedef 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
299 uint32 server_role;
301 /**Number of domain users*/
302 uint32 num_users;
304 /**Number of domain groups*/
305 uint32 num_domain_groups;
307 /**Number of local groups*/
308 uint32 num_local_groups;
310 /**Comment*/
311 char *comment;
313 /**Domain name*/
314 char *domain_name;
316 /**Server name*/
317 char *server_name;
319 /**Minimum password length*/
320 uint16 min_pass_length;
322 /**How many previous passwords to remember - ie, password cannot be the same as N previous passwords*/
323 uint16 pass_history;
325 /**How long (from now) before passwords expire*/
326 CacTime expire;
328 /**How long (from now) before passwords can be changed*/
329 CacTime min_pass_age;
331 /**How long users are locked out for too many bad password attempts*/
332 CacTime lockout_duration;
334 /**How long before lockouts are reset*/
335 CacTime lockout_reset;
337 /**How many bad password attempts before lockout occurs*/
338 uint16 num_bad_attempts;
339 } CacDomainInfo;
341 /**@}*/ /*sam_defs*/
343 /**@addtogroup svc_defs
344 * @{
346 typedef struct _CACSERVICE {
347 /**The service name*/
348 char *service_name;
350 /**The display name of the service*/
351 char *display_name;
353 /**Current status of the service - see include/rpc_svcctl.h for SERVICE_STATUS definition*/
354 SERVICE_STATUS status;
355 } CacService;
357 typedef struct __CACSERVICECONFIG {
358 /**The service type*/
359 uint32 type;
361 /**The start type. Should be one of:
362 * - SVCCTL_BOOT_START
363 * - SVCCTL_SYSTEM_START
364 * - SVCCTL_AUTO_START
365 * - SVCCTL_DEMAND_START
367 uint32 start_type;
369 uint32 error_control;
371 /**Path to executable*/
372 char *exe_path;
374 /***/
375 char *load_order_group;
377 uint32 tag_id;
379 /**Any dependencies for the service*/
380 char *dependencies;
382 /**Run as...*/
383 char *start_name;
385 /**Service display name*/
386 char *display_name;
388 } CacServiceConfig;
389 /**@}*/ /*svc_defs*/
391 #include "libmsrpc_internal.h"
394 * @addtogroup handle
395 * @{
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().
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.
405 * @note It may be wise to allocate large buffers for these fields and strcpy data into them.
407 * @see cac_NewServerHandle()
408 * @see cac_FreeHandle()
410 typedef struct _CACSERVERHANDLE {
411 /** debug level
413 int debug;
415 /** netbios name used to make connections
417 char *netbios_name;
419 /** domain name used to make connections
421 char *domain;
423 /** username used to make connections
425 char *username;
427 /** user's password plain text string
429 char *password;
431 /** name or IP address of server we are currently working with
433 char *server;
435 /**stores the latest NTSTATUS code
437 NTSTATUS status;
439 /** internal. do not modify!
441 struct CacServerHandleInternal _internal;
443 } CacServerHandle;
445 /*@}*/
447 /**internal function. do not call this function*/
448 SMBCSRV *cac_GetServer(CacServerHandle *hnd);
451 /** @addtogroup Library_Functions
452 * @{
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
459 void cac_Init(int debug);
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
467 CacServerHandle * cac_NewServerHandle(bool allocate_fields);
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
475 void cac_SetAuthDataFn(CacServerHandle *hnd, smbc_get_auth_data_fn auth_fn);
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.
482 void cac_SetSmbcContext(CacServerHandle *hnd, SMBCCTX *ctx);
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.
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
492 int cac_Connect(CacServerHandle *hnd, const char *srv);
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
499 void cac_FreeHandle(CacServerHandle * hnd);
502 * Initializes a CacTime structure based on an NTTIME structure
503 * If the function fails, then the CacTime structure will be zero'd out
505 void cac_InitCacTime(CacTime *cactime, NTTIME nttime);
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
513 int cac_InitHandleMem(CacServerHandle *hnd);
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.
529 void 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);
539 /**@}*/
541 /*****************
542 * LSA Functions *
543 *****************/
545 /** @addtogroup LSA_Functions
546 * @{
549 struct LsaOpenPolicy {
550 /**Inputs*/
551 struct {
552 /**Access Mask. Refer to Security Access Masks in include/rpc_secdes.h*/
553 uint32 access;
555 /**Use security quality of service? (True/False)*/
556 bool security_qos;
557 } in;
559 /**Outputs*/
560 struct {
561 /**Handle to the open policy (needed for all other operations)*/
562 POLICY_HND *pol;
563 } out;
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
574 int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op);
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
586 int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *pol);
589 struct LsaGetNamesFromSids {
590 struct {
591 /**handle to and open LSA policy*/
592 POLICY_HND *pol;
594 /**the number of SIDs to lookup*/
595 uint32 num_sids;
597 /**array of SIDs to lookup*/
598 DOM_SID *sids;
599 } in;
601 struct {
602 /**The number of names returned (in case of CAC_PARTIAL_SUCCESS)*/
603 uint32 num_found;
605 /**array of SID info each index is one sid */
606 CacSidInfo *sids;
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;
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
622 int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetNamesFromSids *op);
624 struct LsaGetSidsFromNames {
625 struct {
626 /**handle to an open LSA policy*/
627 POLICY_HND *pol;
629 /**number of SIDs to lookup*/
630 uint32 num_names;
632 /**array of strings listing the names*/
633 char **names;
634 } in;
636 struct {
637 /**The number of SIDs returned (in case of partial success*/
638 uint32 num_found;
640 /**array of SID info for the looked up names*/
641 CacSidInfo *sids;
643 /**in case of partial success, the names that were not looked up*/
644 char **unknown;
645 } out;
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
657 int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSidsFromNames *op);
659 struct LsaFetchSid {
660 struct {
661 /**handle to an open LSA policy*/
662 POLICY_HND *pol;
664 /**can be CAC_LOCAL_INFO, CAC_DOMAIN_INFO, or (CAC_LOCAL_INFO | CAC_DOMAIN_INFO)*/
665 uint16 info_class;
666 } in;
668 struct {
669 /**the machine's local SID and domain name (NULL if not asked for)*/
670 CacSidInfo *local_sid;
672 /**the machine's domain SID and name (NULL if not asked for)*/
673 CacSidInfo *domain_sid;
675 } out;
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
687 int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSid *op);
689 struct LsaQueryInfoPolicy {
690 struct {
691 /**Open LSA policy handle on remote server*/
692 POLICY_HND *pol;
693 } in;
695 struct {
696 /**remote server's domain name*/
697 char *domain_name;
699 /**remote server's dns name*/
700 char *dns_name;
702 /**remote server's forest name*/
703 char *forest_name;
705 /**remote server's domain guid*/
706 struct GUID *domain_guid;
708 /**remote server's domain SID*/
709 DOM_SID *domain_sid;
710 } out;
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.
722 int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryInfoPolicy *op);
724 struct LsaEnumSids {
725 struct {
726 /**Open LSA Policy handle*/
727 POLICY_HND *pol;
729 /**The prefered maximum number of SIDs returned per call*/
730 uint32 pref_max_sids;
731 } in;
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;
738 /**The number of sids returned this call*/
739 uint32 num_sids;
741 /**Array of sids returned*/
742 DOM_SID *sids;
744 } out;
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
756 int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSids *op);
758 struct LsaEnumAccountRights {
759 struct {
760 /**Open LSA Policy handle*/
761 POLICY_HND *pol;
763 /**(Optional) SID of the account - must supply either sid or name*/
764 DOM_SID *sid;
766 /**(Optional) name of the account - must supply either sid or name*/
767 char *name;
768 } in;
770 struct {
771 /**Count of rights for this account*/
772 uint32 num_privs;
774 /**array of privilege names*/
775 char **priv_names;
776 } out;
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.
788 int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumAccountRights *op);
790 struct LsaEnumTrustedDomains {
791 struct {
792 /**Open LSA policy handle*/
793 POLICY_HND *pol;
794 } in;
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;
801 /**The number of domains returned by the remote server this call*/
802 uint32 num_domains;
804 /**array of trusted domain names returned by the remote server*/
805 char **domain_names;
807 /**array of trusted domain sids returned by the remote server*/
808 DOM_SID *domain_sids;
809 } out;
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
820 int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumTrustedDomains *op);
822 struct LsaOpenTrustedDomain {
823 struct {
824 /**an open LSA policy handle*/
825 POLICY_HND *pol;
827 /**SID of the trusted domain to open*/
828 DOM_SID *domain_sid;
830 /**Desired access on the open domain*/
831 uint32 access;
832 } in;
834 struct {
835 /**A handle to the policy that is opened*/
836 POLICY_HND *domain_pol;
837 } out;
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
848 int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenTrustedDomain *op);
850 struct LsaQueryTrustedDomainInfo {
851 struct {
852 /**Open LSA policy handle*/
853 POLICY_HND *pol;
855 /**Info class of returned data*/
856 uint16 info_class;
858 /**(Optional)SID of trusted domain to query (must specify either SID or name of trusted domain)*/
859 DOM_SID *domain_sid;
861 /**(Optional)Name of trusted domain to query (must specify either SID or name of trusted domain)*/
862 char *domain_name;
863 } in;
865 struct {
866 /**information about the trusted domain*/
867 LSA_TRUSTED_DOMAIN_INFO *info;
868 } out;
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
880 int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryTrustedDomainInfo *op);
882 struct LsaEnumPrivileges {
883 struct {
884 /**An open LSA policy handle*/
885 POLICY_HND *pol;
887 /**The _preferred_ maxinum number of privileges returned per call*/
888 uint32 pref_max_privs;
889 } in;
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;
895 /**The number of privileges returned this call*/
896 uint32 num_privs;
898 /**Array of privilege names*/
899 char **priv_names;
901 /**Array of high bits for privilege LUID*/
902 uint32 *high_bits;
904 /**Array of low bits for privilege LUID*/
905 uint32 *low_bits;
906 } out;
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()
919 int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumPrivileges *op);
921 struct LsaOpenAccount {
922 struct {
923 /**An open LSA policy handle*/
924 POLICY_HND *pol;
926 /**(Optional) account SID - must supply either sid or name*/
927 DOM_SID *sid;
929 /**(Optional) account name - must supply either sid or name*/
930 char *name;
932 /**desired access for the handle*/
933 uint32 access;
934 } in;
936 struct {
937 /**A handle to the opened user*/
938 POLICY_HND *user;
939 } out;
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
950 int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenAccount *op);
952 struct LsaAddPrivileges {
953 struct {
954 /**An open LSA policy handle*/
955 POLICY_HND *pol;
957 /**(Optional) The user's SID (must specify at least sid or name)*/
958 DOM_SID *sid;
960 /**(Optional) The user's name (must specify at least sid or name)*/
961 char *name;
963 /**The privilege names of the privileges to add for the account*/
964 char **priv_names;
966 /**The number of privileges in the priv_names array*/
967 uint32 num_privs;
969 } in;
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.
980 int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op);
982 struct LsaRemovePrivileges {
983 struct {
984 /**An open handle to the LSA*/
985 POLICY_HND *pol;
987 /**(Optional) The account SID (must specify at least sid or name)*/
988 DOM_SID *sid;
990 /**(Optional) The account name (must specify at least sid or name)*/
991 char *name;
993 /**The privilege names of the privileges to remove from the account*/
994 char **priv_names;
996 /**The number of privileges in the priv_names array*/
997 uint32 num_privs;
999 } in;
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
1011 int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaRemovePrivileges *op);
1013 struct LsaClearPrivileges {
1014 struct {
1015 /**An open handle to the LSA*/
1016 POLICY_HND *pol;
1018 /**(Optional) The user's SID (must specify at least sid or name)*/
1019 DOM_SID *sid;
1021 /**(Optional) The user's name (must specify at least sid or name)*/
1022 char *name;
1023 } in;
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.
1035 int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaClearPrivileges *op);
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
1045 int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op);
1047 struct LsaGetSecurityObject {
1048 struct {
1049 /**Open LSA policy handle*/
1050 POLICY_HND *pol;
1051 } in;
1053 struct {
1054 /**Returned security descriptor information*/
1055 SEC_DESC_BUF *sec;
1056 } out;
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
1067 int cac_LsaGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSecurityObject *op);
1070 /**@}*/ /*LSA_Functions*/
1072 /**********************
1073 * Registry Functions *
1074 *********************/
1076 /**@addtogroup Reg_Functions
1077 * @{
1080 struct RegConnect {
1081 struct {
1082 /** must be one of :
1083 * HKEY_CLASSES_ROOT,
1084 * HKEY_LOCAL_MACHINE,
1085 * HKEY_USERS,
1086 * HKEY_PERFORMANCE_DATA,
1088 int root;
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;
1100 struct {
1101 POLICY_HND *key;
1102 } out;
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
1113 int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op);
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
1123 int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key);
1125 struct 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\
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\
1137 POLICY_HND *parent_key;
1139 /**name/path of key*/
1140 char *name;
1142 /**desired access on this key*/
1143 uint32 access;
1144 } in;
1146 struct {
1147 POLICY_HND *key;
1148 } out;
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
1160 int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey *op);
1162 struct RegEnumKeys {
1163 struct {
1164 /**enumerate subkeys of this key*/
1165 POLICY_HND *key;
1167 /**maximum number of keys to enumerate each call*/
1168 uint32 max_keys;
1169 } in;
1171 struct {
1172 /**keeps track of the index to resume enumerating*/
1173 uint32 resume_idx;
1175 /**the number of keys returned this call*/
1176 uint32 num_keys;
1178 /**array of key names*/
1179 char **key_names;
1181 /**class names of the keys*/
1182 char **class_names;
1184 /**last modification time of the key*/
1185 time_t *mod_times;
1186 } out;
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
1198 int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op);
1201 struct RegCreateKey {
1202 struct {
1203 /**create a subkey of parent_key*/
1204 POLICY_HND *parent_key;
1206 /**name of the key to create*/
1207 char *key_name;
1209 /**class of the key*/
1210 char *class_name;
1212 /**Access mask to open the key with. See REG_KEY_* in include/rpc_secdes.h*/
1213 uint32 access;
1214 } in;
1216 struct {
1217 /**Open handle to the key*/
1218 POLICY_HND *key;
1219 } out;
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
1230 int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op);
1232 struct RegDeleteKey {
1233 struct {
1234 /**handle to open registry key*/
1235 POLICY_HND *parent_key;
1237 /**name of the key to delete*/
1238 char *name;
1240 /**delete recursively. WARNING: this might not always work as planned*/
1241 bool recursive;
1242 } in;
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
1255 int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op);
1257 struct RegDeleteValue {
1258 struct {
1259 /**handle to open registry key*/
1260 POLICY_HND *parent_key;
1262 /**name of the value to delete*/
1263 char *name;
1264 } in;
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
1275 int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op);
1277 struct RegQueryKeyInfo {
1278 struct {
1279 /**Open handle to the key to query*/
1280 POLICY_HND *key;
1281 } in;
1283 struct {
1284 /**name of the key class*/
1285 char *class_name;
1287 /**number of subkeys of the key*/
1288 uint32 num_subkeys;
1290 /**length (in characters) of the longest subkey name*/
1291 uint32 longest_subkey;
1293 /**length (in characters) of the longest class name*/
1294 uint32 longest_class;
1296 /**number of values in this key*/
1297 uint32 num_values;
1299 /**length (in characters) of the longest value name*/
1300 uint32 longest_value_name;
1302 /**length (in bytes) of the biggest value data*/
1303 uint32 longest_value_data;
1305 /**size (in bytes) of the security descriptor*/
1306 uint32 security_desc_size;
1308 /**time of the last write*/
1309 time_t last_write_time;
1310 } out;
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
1322 int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryKeyInfo *op);
1324 struct RegSaveKey {
1325 struct {
1326 /**Open key to be saved*/
1327 POLICY_HND *key;
1329 /**The path (on the remote computer) to save the file to*/
1330 char *filename;
1331 } in;
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
1343 int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op);
1345 struct RegQueryValue {
1346 struct {
1347 /**handle to open registry key*/
1348 POLICY_HND *key;
1350 /**name of the value to query*/
1351 char *val_name;
1352 } in;
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
1364 uint32 type;
1366 /**The value*/
1367 REG_VALUE_DATA *data;
1368 } out;
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
1380 int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op);
1382 struct RegEnumValues {
1383 struct {
1384 /**handle to open key*/
1385 POLICY_HND *key;
1387 /**max number of values returned per call*/
1388 uint32 max_values;
1390 } in;
1392 struct {
1393 /**keeps track of the index to resume from - used over multiple calls*/
1394 uint32 resume_idx;
1396 /**the number of values that were returned this call*/
1397 uint32 num_values;
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
1407 uint32 *types;
1409 /**array of strings storing the names of the values*/
1410 char **value_names;
1412 /**array of pointers to the value data returned*/
1413 REG_VALUE_DATA **values;
1414 } out;
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
1427 int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op);
1429 struct RegSetValue {
1430 struct {
1431 /**Handle to open registry key*/
1432 POLICY_HND *key;
1434 /**Name of the value*/
1435 char *val_name;
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
1446 uint32 type;
1448 /**the value*/
1449 REG_VALUE_DATA value;
1450 } in;
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
1461 int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op);
1463 struct RegGetVersion {
1464 struct {
1465 /**open registry key*/
1466 POLICY_HND *key;
1467 } in;
1469 struct {
1470 /**version number*/
1471 uint32 version;
1472 } out;
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
1483 int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op);
1485 struct RegGetKeySecurity {
1486 struct {
1487 /**Handle to key to query*/
1488 POLICY_HND *key;
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
1500 * or use:
1501 * - ALL_SECURITY_INFORMATION
1503 * all definitions from include/rpc_secdes.h
1505 uint32 info_type;
1506 } in;
1508 struct {
1509 /**size of the data returned*/
1510 uint32 size;
1512 /**Security descriptor*/
1513 SEC_DESC *descriptor;
1514 } out;
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
1526 int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op);
1528 struct RegSetKeySecurity {
1529 struct {
1530 /**Handle to key to query*/
1531 POLICY_HND *key;
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
1543 * or use:
1544 * - ALL_SECURITY_INFORMATION
1546 * all definitions from include/rpc_secdes.h
1548 uint32 info_type;
1550 /**size of the descriptor*/
1551 size_t size;
1553 /**Security descriptor*/
1554 SEC_DESC *descriptor;
1555 } in;
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
1566 int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op);
1568 /**@}*/ /*Reg_Functions*/
1570 struct Shutdown {
1571 struct {
1572 /**the message to display (can be NULL)*/
1573 char *message;
1575 /**timeout in seconds*/
1576 uint32 timeout;
1578 /**False = shutdown, True = reboot*/
1579 bool reboot;
1581 /**force the*/
1582 bool force;
1584 /*FIXME: make this useful*/
1585 uint32 reason;
1586 } in;
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
1598 int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op);
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
1607 int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx);
1609 /*****************
1610 * SAM Functions *
1611 *****************/
1613 /**@addtogroup SAM_Functions
1614 * @{
1616 struct SamConnect {
1617 struct {
1618 /**Access mask to open with
1619 * see generic access masks in include/smb.h*/
1620 uint32 access;
1621 } in;
1623 struct {
1624 POLICY_HND *sam;
1625 } out;
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
1637 int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect *op);
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
1649 int cac_SamClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sam);
1651 struct SamOpenDomain {
1652 struct {
1653 /**The desired access. See generic access masks - include/smb.h*/
1654 uint32 access;
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;
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;
1664 struct {
1665 /**handle to the open domain*/
1666 POLICY_HND *dom_hnd;
1668 /**Handle to the open SAM*/
1669 POLICY_HND *sam;
1670 } out;
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
1681 int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenDomain *op);
1683 struct SamCreateUser {
1684 struct {
1685 /**Open domain handle*/
1686 POLICY_HND *dom_hnd;
1688 /**Username*/
1689 char *name;
1691 /**See Allowable account control bits in include/smb.h*/
1692 uint32 acb_mask;
1693 } in;
1695 struct {
1696 /**handle to the user*/
1697 POLICY_HND *user_hnd;
1699 /**rid of the user*/
1700 uint32 rid;
1701 } out;
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
1713 int cac_SamCreateUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateUser *op);
1715 struct SamOpenUser {
1716 struct {
1717 /**Handle to open SAM connection*/
1718 POLICY_HND *dom_hnd;
1720 /**desired access - see generic access masks in include/smb.h*/
1721 uint32 access;
1723 /**RID of the user*/
1724 uint32 rid;
1726 /**(Optional) name of the user - must supply either RID or user name*/
1727 char *name;
1728 } in;
1730 struct {
1731 /**Handle to the user*/
1732 POLICY_HND *user_hnd;
1733 } out;
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
1744 int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUser *op);
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
1754 int cac_SamDeleteUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd);
1757 struct SamEnumUsers {
1758 struct {
1759 /**Open handle to a domain*/
1760 POLICY_HND *dom_hnd;
1762 /**Enumerate users with specific ACB. If 0, all users will be enumerated*/
1763 uint32 acb_mask;
1764 } in;
1766 struct {
1767 /**where to resume from. Used over multiple calls*/
1768 uint32 resume_idx;
1770 /**the number of users returned this call*/
1771 uint32 num_users;
1773 /**Array storing the rids of the returned users*/
1774 uint32 *rids;
1776 /**Array storing the names of all the users returned*/
1777 char **names;
1779 bool done;
1780 } out;
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
1791 int cac_SamEnumUsers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUsers *op);
1793 struct SamGetNamesFromRids {
1794 struct {
1795 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1796 POLICY_HND *dom_hnd;
1798 /**Number of RIDs to resolve*/
1799 uint32 num_rids;
1801 /**Array of RIDs to resolve*/
1802 uint32 *rids;
1803 } in;
1805 struct {
1806 /**the number of names returned - if this is 0, the map is NULL*/
1807 uint32 num_names;
1809 /**array contiaing the Names and RIDs*/
1810 CacLookupRidsRecord *map;
1811 } out;
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
1822 int cac_SamGetNamesFromRids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetNamesFromRids *op);
1824 struct SamGetRidsFromNames {
1825 struct {
1826 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1827 POLICY_HND *dom_hnd;
1829 /**Number of names to resolve*/
1830 uint32 num_names;
1832 /**Array of names to resolve*/
1833 char **names;
1834 } in;
1836 struct {
1837 /**the number of names returned - if this is 0, then map is NULL*/
1838 uint32 num_rids;
1840 /**array contiaing the Names and RIDs*/
1841 CacLookupRidsRecord *map;
1842 } out;
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
1853 int cac_SamGetRidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetRidsFromNames *op);
1855 struct SamGetGroupsForUser {
1856 struct {
1857 /**An open handle to the user*/
1858 POLICY_HND *user_hnd;
1859 } in;
1861 struct {
1862 /**The number of groups the user is a member of*/
1863 uint32 num_groups;
1865 /**The RIDs of the groups*/
1866 uint32 *rids;
1868 /**The attributes of the groups*/
1869 uint32 *attributes;
1870 } out;
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
1880 int cac_SamGetGroupsForUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupsForUser *op);
1882 struct SamOpenGroup {
1883 struct {
1884 /**Open handle to the domain SAM*/
1885 POLICY_HND *dom_hnd;
1887 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
1888 uint32 access;
1890 /**rid of the group*/
1891 uint32 rid;
1892 } in;
1894 struct {
1895 /**Handle to the group*/
1896 POLICY_HND *group_hnd;
1897 } out;
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
1908 int cac_SamOpenGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGroup *op);
1910 struct SamCreateGroup {
1911 struct {
1912 /**Open handle to the domain SAM*/
1913 POLICY_HND *dom_hnd;
1915 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
1916 uint32 access;
1918 /**The name of the group*/
1919 char *name;
1920 } in;
1922 struct {
1923 /**Handle to the group*/
1924 POLICY_HND *group_hnd;
1925 } out;
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
1936 int cac_SamCreateGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateGroup *op);
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
1946 int cac_SamDeleteGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd);
1948 struct SamGetGroupMembers {
1949 struct {
1950 /**Open handle to a group*/
1951 POLICY_HND *group_hnd;
1952 } in;
1954 struct {
1955 /**The number of members in the group*/
1956 uint32 num_members;
1958 /**An array storing the RIDs of the users*/
1959 uint32 *rids;
1961 /**The attributes*/
1962 uint32 *attributes;
1963 } out;
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
1974 int cac_SamGetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupMembers *op);
1976 struct SamAddGroupMember {
1977 struct {
1978 /**Open handle to a group*/
1979 POLICY_HND *group_hnd;
1981 /**RID of new member*/
1982 uint32 rid;
1983 } in;
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
1994 int cac_SamAddGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddGroupMember *op);
1996 struct SamRemoveGroupMember {
1997 struct {
1998 /**Open handle to a group*/
1999 POLICY_HND *group_hnd;
2001 /**RID of member to remove*/
2002 uint32 rid;
2003 } in;
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
2014 int cac_SamRemoveGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveGroupMember *op);
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
2024 int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd);
2026 struct SamSetGroupMembers {
2027 struct {
2028 /**Open handle to the group*/
2029 POLICY_HND *group_hnd;
2031 /**Number of members in the group - if this is 0, all members of the group will be removed*/
2032 uint32 num_members;
2034 /**The RIDs of the users to add*/
2035 uint32 *rids;
2036 } in;
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
2047 int cac_SamSetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupMembers *op);
2049 struct SamEnumGroups {
2050 struct {
2051 /**Open handle to a domain*/
2052 POLICY_HND *dom_hnd;
2053 } in;
2055 struct {
2056 /**Where to resume from _do not_ modify this value. Used over multiple calls.*/
2057 uint32 resume_idx;
2059 /**the number of users returned this call*/
2060 uint32 num_groups;
2062 /**Array storing the rids of the returned groups*/
2063 uint32 *rids;
2065 /**Array storing the names of all the groups returned*/
2066 char **names;
2068 /**Array storing the descriptions of all the groups returned*/
2069 char **descriptions;
2071 bool done;
2072 } out;
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
2083 int cac_SamEnumGroups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumGroups *op);
2085 struct SamEnumAliases {
2086 struct {
2087 /**Open handle to a domain*/
2088 POLICY_HND *dom_hnd;
2089 } in;
2091 struct {
2092 /**where to resume from. Used over multiple calls*/
2093 uint32 resume_idx;
2095 /**the number of users returned this call*/
2096 uint32 num_aliases;
2098 /**Array storing the rids of the returned groups*/
2099 uint32 *rids;
2101 /**Array storing the names of all the groups returned*/
2102 char **names;
2104 /**Array storing the descriptions of all the groups returned*/
2105 char **descriptions;
2107 bool done;
2108 } out;
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
2119 int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumAliases *op);
2121 struct SamCreateAlias {
2122 struct {
2123 /**Open handle to the domain SAM*/
2124 POLICY_HND *dom_hnd;
2126 /**The name of the alias*/
2127 char *name;
2128 } in;
2130 struct {
2131 /**Handle to the group*/
2132 POLICY_HND *alias_hnd;
2133 } out;
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
2145 int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op);
2147 struct SamOpenAlias {
2148 struct {
2149 /**Open handle to the domain SAM*/
2150 POLICY_HND *dom_hnd;
2152 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
2153 uint32 access;
2155 /**rid of the alias*/
2156 uint32 rid;
2157 } in;
2159 struct {
2160 /**Handle to the alias*/
2161 POLICY_HND *alias_hnd;
2162 } out;
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
2173 int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op);
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
2183 int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd);
2185 struct SamAddAliasMember {
2186 struct {
2187 /**Open handle to a alias*/
2188 POLICY_HND *alias_hnd;
2190 /**SID of new member*/
2191 DOM_SID *sid;
2192 } in;
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
2203 int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op);
2205 struct SamRemoveAliasMember {
2206 struct {
2207 /**Open handle to the alias*/
2208 POLICY_HND *alias_hnd;
2210 /**The SID of the member*/
2211 DOM_SID *sid;
2212 } in;
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
2223 int cac_SamRemoveAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveAliasMember *op);
2225 struct SamGetAliasMembers {
2226 struct {
2227 /**Open handle to the alias*/
2228 POLICY_HND *alias_hnd;
2229 } in;
2231 struct {
2232 /**The number of members*/
2233 uint32 num_members;
2235 /**An array storing the SIDs of the accounts*/
2236 DOM_SID *sids;
2237 } out;
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
2248 int cac_SamGetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasMembers *op);
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
2259 int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd);
2261 struct SamSetAliasMembers {
2262 struct {
2263 /**Open handle to the group*/
2264 POLICY_HND *alias_hnd;
2266 /**Number of members in the group - if this is 0, all members of the group will be removed*/
2267 uint32 num_members;
2269 /**The SIDs of the accounts to add*/
2270 DOM_SID *sids;
2271 } in;
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
2282 int cac_SamSetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasMembers *op);
2285 struct SamUserChangePasswd {
2286 struct {
2287 /**The username*/
2288 char *username;
2290 /**The current password*/
2291 char *password;
2293 /**The new password*/
2294 char *new_password;
2295 } in;
2297 /**Used by a user to change their password*/
2298 int cac_SamUserChangePasswd(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamUserChangePasswd *op);
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
2308 int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd);
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
2318 int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd);
2320 struct SamSetPassword {
2321 struct {
2322 /**Open handle to a user*/
2323 POLICY_HND *user_hnd;
2325 /**The new password*/
2326 char *password;
2327 } in;
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
2339 int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetPassword *op);
2341 struct SamGetUserInfo {
2342 struct {
2343 /**Open Handle to a user*/
2344 POLICY_HND *user_hnd;
2345 } in;
2347 struct {
2348 CacUserInfo *info;
2349 } out;
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
2361 int cac_SamGetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfo *op);
2363 struct SamSetUserInfo {
2364 struct {
2365 /**Open handle to a user*/
2366 POLICY_HND *user_hnd;
2368 /**Structure containing the data you would like to set*/
2369 CacUserInfo *info;
2370 } in;
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
2384 int cac_SamSetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfo *op);
2386 struct SamGetUserInfoCtr {
2387 struct {
2388 /**Open handle to a user*/
2389 POLICY_HND *user_hnd;
2391 /**What USER_INFO structure you want. See include/rpc_samr.h*/
2392 uint16 info_class;
2393 } in;
2395 struct {
2396 /**returned user info*/
2397 SAM_USERINFO_CTR *ctr;
2398 } out;
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
2410 int cac_SamGetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfoCtr *op);
2412 struct SamSetUserInfoCtr {
2413 struct {
2414 /**Open handle to a user*/
2415 POLICY_HND *user_hnd;
2417 /**user info - make sure ctr->switch_value is set properly*/
2418 SAM_USERINFO_CTR *ctr;
2419 } in;
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
2432 int cac_SamSetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfoCtr *op);
2434 struct SamRenameUser {
2435 struct {
2436 /**Open handle to user*/
2437 POLICY_HND *user_hnd;
2439 /**New user name*/
2440 char *new_name;
2441 } in;
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
2452 int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameUser *op);
2454 struct SamGetGroupInfo {
2455 struct {
2456 /**Open handle to a group*/
2457 POLICY_HND *group_hnd;
2458 } in;
2460 struct {
2461 /**Returned info about the group*/
2462 CacGroupInfo *info;
2463 } out;
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
2474 int cac_SamGetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupInfo *op);
2476 struct SamSetGroupInfo {
2477 struct {
2478 /**Open handle to a group*/
2479 POLICY_HND *group_hnd;
2481 /**group info*/
2482 CacGroupInfo *info;
2483 } in;
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
2494 int cac_SamSetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupInfo *op);
2496 struct SamRenameGroup {
2497 struct {
2498 /**Open handle to a group*/
2499 POLICY_HND *group_hnd;
2501 /**New name*/
2502 char *new_name;
2503 } in;
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
2515 int cac_SamRenameGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameGroup *op);
2517 struct SamGetAliasInfo {
2518 struct {
2519 /**Open handle to an alias*/
2520 POLICY_HND *alias_hnd;
2521 } in;
2523 struct {
2524 /**Returned alias info*/
2525 CacAliasInfo *info;
2526 } out;
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
2537 int cac_SamGetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasInfo *op);
2539 struct SamSetAliasInfo {
2540 struct {
2541 /**Open handle to an alias*/
2542 POLICY_HND *alias_hnd;
2544 /**Returned alias info*/
2545 CacAliasInfo *info;
2546 } in;
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
2557 int cac_SamSetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasInfo *op);
2559 struct SamGetDomainInfo {
2560 struct {
2561 /**Open handle to the domain SAM*/
2562 POLICY_HND *dom_hnd;
2563 } in;
2565 struct {
2566 /**Returned domain info*/
2567 CacDomainInfo *info;
2568 } out;
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
2582 int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfo *op);
2584 struct SamGetDomainInfoCtr {
2585 struct {
2586 /**Open handle to domain*/
2587 POLICY_HND *dom_hnd;
2589 /**What info level you want*/
2590 uint16 info_class;
2591 } in;
2593 struct {
2594 SAM_UNK_CTR *info;
2595 } out;
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
2607 int cac_SamGetDomainInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfoCtr *op);
2609 struct SamGetDisplayInfo {
2610 struct {
2611 /**Open handle to domain*/
2612 POLICY_HND *dom_hnd;
2614 /**What type of data*/
2615 uint16 info_class;
2617 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2618 uint32 max_entries;
2620 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2621 uint32 max_size;
2622 } in;
2624 struct {
2625 /**Do not modify this value, use the same value between multiple calls (ie in while loop)*/
2626 uint32 resume_idx;
2628 /**Number of entries returned*/
2629 uint32 num_entries;
2631 /**Returned display info*/
2632 SAM_DISPINFO_CTR ctr;
2634 /**Internal value. Do not modify.*/
2635 uint32 loop_count;
2637 bool done;
2638 } out;
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
2649 int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDisplayInfo *op);
2651 struct SamLookupDomain {
2652 struct {
2653 /**Open handle to the sam (opened with cac_SamConnect() or cac_SamOpenDomain()*/
2654 POLICY_HND *sam;
2656 /**Name of the domain to lookup*/
2657 char *name;
2658 } in;
2660 struct {
2661 /**SID of the domain*/
2662 DOM_SID *sid;
2663 } out;
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
2674 int cac_SamLookupDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLookupDomain *op);
2676 struct SamGetSecurityObject {
2677 struct {
2678 /**An open handle (SAM, domain or user)*/
2679 POLICY_HND *pol;
2680 } in;
2682 struct {
2683 SEC_DESC_BUF *sec;
2684 } out;
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
2695 int cac_SamGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetSecurityObject *op);
2697 struct SamFlush {
2698 struct {
2699 /**Open handle to the domain SAM*/
2700 POLICY_HND *dom_hnd;
2702 /**(Optional)Domain SID. If NULL, the domain in hnd->domain will be opened*/
2703 DOM_SID *sid;
2705 /**(Optional)Desired access to re-open the domain with. If 0, MAXIMUM_ALLOWED_ACCESS is used.*/
2706 uint32 access;
2707 } in;
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
2719 int cac_SamFlush(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op);
2721 /**@}*/ /*SAM_Functions*/
2723 /**@addtogroup SCM_Functions
2724 * @{
2727 struct 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;
2733 struct {
2734 /**Handle to the SCM*/
2735 POLICY_HND *scm_hnd;
2736 } out;
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
2747 int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm *op);
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
2757 int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd);
2759 struct SvcEnumServices {
2760 struct {
2761 /**Open handle to the SCM*/
2762 POLICY_HND *scm_hnd;
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.
2769 uint32 type;
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.
2777 uint32 state;
2778 } in;
2780 struct {
2781 /**Number of services returned*/
2782 uint32 num_services;
2784 /**Array of service structures*/
2785 CacService *services;
2786 } out;
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
2797 int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnumServices *op);
2799 struct SvcOpenService {
2800 struct {
2801 /**Handle to the Service Control Manager*/
2802 POLICY_HND *scm_hnd;
2804 /**Access mask to open service with see SERVICE_* or SC_RIGHT_SVC_* in include/rpc_secdes.h*/
2805 uint32 access;
2807 /**The name of the service. _not_ the display name*/
2808 char *name;
2809 } in;
2811 struct {
2812 /**Handle to the open service*/
2813 POLICY_HND *svc_hnd;
2814 } out;
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
2826 int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenService *op);
2828 struct SvcGetStatus {
2829 struct {
2830 /**Open handle to the service to query*/
2831 POLICY_HND *svc_hnd;
2832 } in;
2834 struct {
2835 /**The status of the service. See include/rpc_svcctl.h for SERVICE_STATUS definition.*/
2836 SERVICE_STATUS status;
2837 } out;
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
2848 int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetStatus *op);
2850 struct SvcStartService {
2851 struct {
2852 /**open handle to the service*/
2853 POLICY_HND *svc_hnd;
2855 /**Array of parameters to start the service with. Can be NULL if num_parms is 0*/
2856 char **parms;
2858 /**Number of parameters in the parms array*/
2859 uint32 num_parms;
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;
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
2875 int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStartService *op);
2877 struct SvcControlService {
2878 struct {
2879 /**Open handle to the service to control*/
2880 POLICY_HND *svc_hnd;
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
2888 uint32 control;
2889 } in;
2891 struct {
2892 /**The returned status of the service, _immediately_ after the call*/
2893 SERVICE_STATUS *status;
2894 } out;
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
2909 int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcControlService *op);
2911 struct SvcStopService {
2912 struct {
2913 /**Open handle to the service*/
2914 POLICY_HND *svc_hnd;
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
2919 uint32 timeout;
2920 } in;
2922 struct {
2923 /**Status of the service after the operation*/
2924 SERVICE_STATUS status;
2925 } out;
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
2937 int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStopService *op);
2939 struct SvcPauseService {
2940 struct {
2941 /**Open handle to the service*/
2942 POLICY_HND *svc_hnd;
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
2947 uint32 timeout;
2948 } in;
2950 struct {
2951 /**Status of the service after the operation*/
2952 SERVICE_STATUS status;
2953 } out;
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
2965 int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPauseService *op);
2967 struct SvcContinueService {
2968 struct {
2969 /**Open handle to the service*/
2970 POLICY_HND *svc_hnd;
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
2975 uint32 timeout;
2976 } in;
2978 struct {
2979 /**Status of the service after the operation*/
2980 SERVICE_STATUS status;
2981 } out;
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
2993 int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcContinueService *op);
2995 struct SvcGetDisplayName {
2996 struct {
2997 /**Open handle to the service*/
2998 POLICY_HND *svc_hnd;
2999 } in;
3001 struct {
3002 /**The returned display name of the service*/
3003 char *display_name;
3004 } out;
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
3015 int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetDisplayName *op);
3017 struct SvcGetServiceConfig {
3018 struct {
3019 /**Open handle to the service*/
3020 POLICY_HND *svc_hnd;
3021 } in;
3023 struct {
3024 /**Returned Configuration information*/
3025 CacServiceConfig config;
3026 } out;
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
3037 int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetServiceConfig *op);
3039 /**@}*/ /*SCM_Functions*/
3041 struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx);
3043 #endif /* LIBMSRPC_H */