2 * Unix SMB/CIFS implementation.
3 * MS-RPC client library API definitions/prototypes
5 * Copyright (C) Chris Nicholls 2005.
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 2 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, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "libsmbclient.h"
28 #include "libsmb_internal.h"
30 /*server capability levels*/
33 #define SRV_WIN_2K_SP3 3
36 /**@defgroup handle Server Handle*/
37 /**@defgroup Library_Functions Library/Utility Functions*/
38 /**@defgroup lsa_defs LSA Definitions*/
39 /**@defgroup LSA_Functions LSA Functions*/
40 /**@defgroup reg_defs Registry Definitions*/
41 /**@defgroup Reg_Functions Registry Functions*/
42 /**@defgroup sam_defs SAM Definitions*/
43 /**@defgroup SAM_Functions SAM Functions*/
44 /**@defgroup svc_defs Service Control Definitions*/
45 /**@defgroup SCM_Functions Service Control Functions*/
47 /**Operation was unsuccessful*/
49 /**Operation was successful*/
51 /**Operation was only partially successful
52 * an example of this is if you try to lookup a list of accounts to SIDs and not all accounts can be resolved*/
53 #define CAC_PARTIAL_SUCCESS 2
55 /**@ingroup CAC_errors Use this to see if the last operation failed - useful for enumeration functions that use multiple calls*/
56 #define CAC_OP_FAILED(status) !NT_STATUS_IS_OK(status) && \
57 NT_STATUS_V(status) != NT_STATUS_V(STATUS_SOME_UNMAPPED) && \
58 NT_STATUS_V(status) != NT_STATUS_V(STATUS_NO_MORE_FILES) && \
59 NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_NO_MORE_ENTRIES) && \
60 NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_NONE_MAPPED) && \
61 NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_GUIDS_EXHAUSTED)
64 /**Privilege string constants*/
65 #define CAC_SE_CREATE_TOKEN "SeCreateTokenPrivilege"
66 #define CAC_SE_ASSIGN_PRIMARY_TOKEN "SeAssignPrimaryTokenPrivilege"
67 #define CAC_SE_LOCK_MEMORY "SeLockMemoryPrivilege"
68 #define CAC_SE_INCREASE_QUOTA "SeIncreaseQuotaPrivilege"
69 #define CAC_SE_MACHINE_ACCOUNT "SeMachineAccountPrivilege"
70 #define CAC_SE_TCB "SeTcbPrivilege"
71 #define CAC_SE_SECURITY "SeSecurityPrivilege"
72 #define CAC_SE_TAKE_OWNERSHIP "SeTakeOwnershipPrivilege"
73 #define CAC_SE_LOAD_DRIVER "SeLoadDriverPrivilege"
74 #define CAC_SE_SYSTEM_PROFILE "SeSystemProfilePrivilege"
75 #define CAC_SE_SYSTEM_TIME "SeSystemtimePrivilege"
76 #define CAC_SE_PROFILE_SINGLE_PROC "SeProfileSingleProcessPrivilege"
77 #define CAC_SE_INCREASE_BASE_PRIORITY "SeIncreaseBasePriorityPrivilege"
78 #define CAC_SE_CREATE_PAGEFILE "SeCreatePagefilePrivilege"
79 #define CAC_SE_CREATE_PERMANENT "SeCreatePermanentPrivilege"
80 #define CAC_SE_BACKUP "SeBackupPrivilege"
81 #define CAC_SE_RESTORE "SeRestorePrivilege"
82 #define CAC_SE_SHUTDOWN "SeShutdownPrivilege"
83 #define CAC_SE_DEBUG "SeDebugPrivilege"
84 #define CAC_SE_AUDIT "SeAuditPrivilege"
85 #define CAC_SE_SYSTEM_ENV "SeSystemEnvironmentPrivilege"
86 #define CAC_SE_CHANGE_NOTIFY "SeChangeNotifyPrivilege"
87 #define CAC_SE_REMOTE_SHUTDOWN "SeRemoteShutdownPrivilege"
88 #define CAC_SE_UNDOCK "SeUndockPrivilege"
89 #define CAC_SE_SYNC_AGENT "SeSyncAgentPrivilege"
90 #define CAC_SE_ENABLE_DELEGATION "SeEnableDelegationPrivilege"
91 #define CAC_SE_MANAGE_VOLUME "SeManageVolumePrivilege"
92 #define CAC_SE_IMPERSONATE "SeImpersonatePrivilege"
93 #define CAC_SE_CREATE_GLOBAL "SeCreateGlobalPrivilege"
94 #define CAC_SE_PRINT_OPERATOR "SePrintOperatorPrivilege"
95 #define CAC_SE_NETWORK_LOGON "SeNetworkLogonRight"
96 #define CAC_SE_INTERACTIVE_LOGON "SeInteractiveLogonRight"
97 #define CAC_SE_BATCH_LOGON "SeBatchLogonRight"
98 #define CAC_SE_SERVICE_LOGON "SeServiceLogonRight"
99 #define CAC_SE_ADD_USERS "SeAddUsersPrivilege"
100 #define CAC_SE_DISK_OPERATOR "SeDiskOperatorPrivilege"
103 * @addtogroup lsa_defs
106 /**used to specify what data to retrieve using cac_LsaQueryTrustedDomainInformation*/
107 #define CAC_INFO_TRUSTED_DOMAIN_NAME 0x1
108 #define CAC_INFO_TRUSTED_DOMAIN_POSIX_OFFSET 0x3
109 #define CAC_INFO_TRUSTED_DOMAIN_PASSWORD 0x4
111 /**Used when requesting machine domain information*/
112 #define CAC_DOMAIN_INFO 0x0003
114 /**Used when requesting machine local information*/
115 #define CAC_LOCAL_INFO 0x0005
117 /**Stores information about a SID*/
118 typedef struct _CACSIDINFO
{
122 /**The name of the object which maps to this SID*/
125 /**The domain the SID belongs to*/
131 * @addtogroup reg_defs
134 /**Null terminated string*/
135 typedef char* REG_SZ_DATA
;
137 /**Null terminated string with windows environment variables that should be expanded*/
138 typedef char* REG_EXPAND_SZ_DATA
;
140 /**Binary data of some kind*/
141 typedef struct _REGBINARYDATA
{
146 /**32-bit (little endian) number*/
147 typedef uint32 REG_DWORD_DATA
;
149 /**32-bit big endian number*/
150 typedef uint32 REG_DWORD_BE_DATA
;
152 /**array of strings*/
153 typedef struct _REGMULTISZDATA
{
159 typedef union _REGVALUEDATA
{
161 REG_EXPAND_SZ_DATA reg_expand_sz
;
162 REG_BINARY_DATA reg_binary
;
163 REG_DWORD_DATA reg_dword
;
164 REG_DWORD_BE_DATA reg_dword_be
;
165 REG_MULTI_SZ_DATA reg_multi_sz
;
170 * @addtogroup sam_defs
174 #define CAC_USER_RID 0x1
175 #define CAC_GROUP_RID 0x2
177 typedef struct _CACLOOKUPRIDSRECORD
{
181 /**If found, this will be one of:
187 /*if the name or RID was looked up, then found = True*/
189 } CacLookupRidsRecord
;
191 typedef struct _CACUSERINFO
{
195 /**Last logoff time*/
198 /**Last kickoff time*/
201 /**Last password set time*/
202 time_t pass_last_set_time
;
204 /**Time password can change*/
205 time_t pass_can_change_time
;
207 /**Time password must change*/
208 time_t pass_must_change_time
;
210 /**LM user password*/
211 uint8 lm_password
[8];
213 /**NT user password*/
214 uint8 nt_password
[8];
219 /**RID of primary group*/
225 /**Bad password count*/
226 uint16 bad_passwd_count
;
228 /**Number of logons*/
231 /**Change password at next logon?*/
232 BOOL pass_must_change
;
237 /**User's full name*/
240 /**User's home directory*/
243 /**Home directory drive*/
252 /**Account description*/
255 /**Login from workstations*/
260 /**Possible logon hours*/
261 LOGON_HRS
*logon_hours
;
265 typedef struct _CACGROUPINFO
{
272 /**Number of members*/
274 } CacGroupInfo
, CacAliasInfo
;
276 /**Represents a period (duration) of time*/
277 typedef struct _CACTIME
{
284 /**Number of minutes*/
287 /**number of seconds*/
292 typedef struct _CACDOMINFO
{
293 /**The server role. Should be one of:
302 /**Number of domain users*/
305 /**Number of domain groups*/
306 uint32 num_domain_groups
;
308 /**Number of local groups*/
309 uint32 num_local_groups
;
320 /**Minimum password length*/
321 uint16 min_pass_length
;
323 /**How many previous passwords to remember - ie, password cannot be the same as N previous passwords*/
326 /**How long (from now) before passwords expire*/
329 /**How long (from now) before passwords can be changed*/
330 CacTime min_pass_age
;
332 /**How long users are locked out for too many bad password attempts*/
333 CacTime lockout_duration
;
335 /**How long before lockouts are reset*/
336 CacTime lockout_reset
;
338 /**How many bad password attempts before lockout occurs*/
339 uint16 num_bad_attempts
;
344 /**@addtogroup svc_defs
347 typedef struct _CACSERVICE
{
348 /**The service name*/
351 /**The display name of the service*/
354 /**Current status of the service - see include/rpc_svcctl.h for SERVICE_STATUS definition*/
355 SERVICE_STATUS status
;
358 typedef struct __CACSERVICECONFIG
{
359 /**The service type*/
362 /**The start type. Should be one of:
363 * - SVCCTL_BOOT_START
364 * - SVCCTL_SYSTEM_START
365 * - SVCCTL_AUTO_START
366 * - SVCCTL_DEMAND_START
370 uint32 error_control
;
372 /**Path to executable*/
376 char *load_order_group
;
380 /**Any dependencies for the service*/
386 /**Service display name*/
392 #include "libmsrpc_internal.h"
400 * Server handle used to keep track of client/server/pipe information. Use cac_NewServerHandle() to allocate.
401 * Initiliaze as many values as possible before calling cac_Connect().
403 * @note When allocating memory for the fields, use SMB_MALLOC() (or equivalent) instead of talloc() (or equivalent) -
404 * If memory is not allocated for a field, cac_Connect will allocate sizeof(fstring) bytes for it.
406 * @note It may be wise to allocate large buffers for these fields and strcpy data into them.
408 * @see cac_NewServerHandle()
409 * @see cac_FreeHandle()
411 typedef struct _CACSERVERHANDLE
{
416 /** netbios name used to make connections
420 /** domain name used to make connections
424 /** username used to make connections
428 /** user's password plain text string
432 /** name or IP address of server we are currently working with
436 /**stores the latest NTSTATUS code
440 /** internal. do not modify!
442 struct CacServerHandleInternal _internal
;
448 /**internal function. do not call this function*/
449 SMBCSRV
*cac_GetServer(CacServerHandle
*hnd
);
452 /** @addtogroup Library_Functions
456 * Initializes the library - do not need to call this function. Open's smb.conf as well as initializes logging.
457 * @param debug Debug level for library to use
460 void cac_Init(int debug
);
463 * Creates an un-initialized CacServerHandle
464 * @param allocate_fields If True, the function will allocate sizeof(fstring) bytes for all char * fields in the handle
465 * @return - un-initialized server handle
466 * - NULL if no memory could be allocated
468 CacServerHandle
* cac_NewServerHandle(BOOL allocate_fields
);
471 * Specifies the smbc_get_auth_data_fn to use if you do not want to use the default.
472 * @param hnd non-NULL server handle
473 * @param auth_fn auth_data_fn to set in server handle
476 void cac_SetAuthDataFn(CacServerHandle
*hnd
, smbc_get_auth_data_fn auth_fn
);
478 /** Use your own libsmbclient context - not necessary.
479 * @note You must still call cac_Connect() after specifying your own libsmbclient context
480 * @param hnd Initialized, but not connected CacServerHandle
481 * @param ctx The libsmbclient context you would like to use.
483 void cac_SetSmbcContext(CacServerHandle
*hnd
, SMBCCTX
*ctx
);
485 /** Connects to a specified server. If there is already a connection to a different server,
486 * it will be cleaned up before connecting to the new server.
487 * @param hnd Pre-initialized CacServerHandle
488 * @param srv (Optional) Name or IP of the server to connect to. If NULL, server from the CacServerHandle will be used.
490 * @return CAC_FAILURE if the operation could not be completed successfully (hnd->status will also be set with a NTSTATUS code)
491 * @return CAC_SUCCESS if the operation succeeded
493 int cac_Connect(CacServerHandle
*hnd
, const char *srv
);
497 * Cleans up any data used by the CacServerHandle. If the libsmbclient context was set using cac_SetSmbcContext(), it will not be free'd.
498 * @param hnd the CacServerHandle to destroy
500 void cac_FreeHandle(CacServerHandle
* hnd
);
503 * Initializes a CacTime structure based on an NTTIME structure
504 * If the function fails, then the CacTime structure will be zero'd out
506 void cac_InitCacTime(CacTime
*cactime
, NTTIME nttime
);
509 * 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
510 * @param hnd Uninitialized server handle
511 * @return CAC_FAILURE Memory could not be allocated
512 * @return CAC_SUCCESS Memory was allocated
514 int cac_InitHandleMem(CacServerHandle
*hnd
);
517 * Default smbc_get_auth_data_fn for libmsrpc. This function is called when libmsrpc needs to get more information about the
518 * client (username/password, workgroup).
519 * 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.
520 * @see cac_SetAuthDataFn()
521 * @param pServer Name/IP of the server to connect to.
522 * @param pShare Share name to connect to
523 * @param pWorkgroup libmsrpc passes in the workgroup/domain name from hnd->domain. It can be modified in the function.
524 * @param maxLenWorkgroup The maximum length of a string pWogroup can hold.
525 * @param pUsername libmsrpc passes in the username from hnd->username. It can be modified in the function.
526 * @param maxLenUsername The maximum length of a string pUsername can hold.
527 * @param pPassword libmsrpc pass in the password from hnd->password. It can be modified in the function.
528 * @param maxLenPassword The maximum length of a string pPassword can hold.
530 void cac_GetAuthDataFn(const char * pServer
,
546 /** @addtogroup LSA_Functions
550 struct LsaOpenPolicy
{
553 /**Access Mask. Refer to Security Access Masks in include/rpc_secdes.h*/
556 /**Use security quality of service? (True/False)*/
562 /**Handle to the open policy (needed for all other operations)*/
568 * Opens a policy handle on a remote machine.
569 * @param hnd fully initialized CacServerHandle for remote machine
570 * @param mem_ctx Talloc context for memory allocation
571 * @param op Initialized parameters
572 * @return CAC_FAILURE if the policy could not be opened. hnd->status set with appropriate NTSTATUS
573 * @return CAC_SUCCESS if the policy could be opened, the policy handle can be found
575 int cac_LsaOpenPolicy(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaOpenPolicy
*op
);
579 * Closes an LSA policy handle (Retrieved using cac_LsaOpenPolicy).
580 * If successful, the handle will be closed on the server, and memory for pol will be freed
581 * @param hnd - An initialized and connected server handle
582 * @param mem_ctx Talloc context for memory allocation
583 * @param pol - the policy handle to close
584 * @return CAC_FAILURE could not close the policy handle, hnd->status is set to the appropriate NTSTATUS error code
585 * @return CAC_SUCCESS the policy handle was closed
587 int cac_LsaClosePolicy(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*pol
);
590 struct LsaGetNamesFromSids
{
592 /**handle to and open LSA policy*/
595 /**the number of SIDs to lookup*/
598 /**array of SIDs to lookup*/
603 /**The number of names returned (in case of CAC_PARTIAL_SUCCESS)*/
606 /**array of SID info each index is one sid */
609 /**in case of partial success, an array of SIDs that could not be looked up (NULL if all sids were looked up)*/
615 * Looks up the names for a list of SIDS
616 * @param hnd initialized and connected server handle
617 * @param mem_ctx Talloc context for memory allocation
618 * @param op input and output parameters
619 * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code
620 * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output
621 * @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
623 int cac_LsaGetNamesFromSids(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaGetNamesFromSids
*op
);
625 struct LsaGetSidsFromNames
{
627 /**handle to an open LSA policy*/
630 /**number of SIDs to lookup*/
633 /**array of strings listing the names*/
638 /**The number of SIDs returned (in case of partial success*/
641 /**array of SID info for the looked up names*/
644 /**in case of partial success, the names that were not looked up*/
650 * Looks up the SIDs for a list of names
651 * @param hnd initialized and connected server handle
652 * @param mem_ctx Talloc context for memory allocation
653 * @param op input and output parameters
654 * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code
655 * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output
656 * @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
658 int cac_LsaGetSidsFromNames(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaGetSidsFromNames
*op
);
662 /**handle to an open LSA policy*/
665 /**can be CAC_LOCAL_INFO, CAC_DOMAIN_INFO, or (CAC_LOCAL_INFO | CAC_DOMAIN_INFO)*/
670 /**the machine's local SID and domain name (NULL if not asked for)*/
671 CacSidInfo
*local_sid
;
673 /**the machine's domain SID and name (NULL if not asked for)*/
674 CacSidInfo
*domain_sid
;
680 * Looks up the domain or local sid of a machine with an open LSA policy handle
681 * @param hnd initialized and connected server handle
682 * @param mem_ctx Talloc context for memory allocation
683 * @param op input and output parameters
684 * @return CAC_FAILURE if the SID could not be fetched
685 * @return CAC_SUCCESS if the SID was fetched
686 * @return CAC_PARTIAL_SUCCESS if you asked for both local and domain sids but only one was returned
688 int cac_LsaFetchSid(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaFetchSid
*op
);
690 struct LsaQueryInfoPolicy
{
692 /**Open LSA policy handle on remote server*/
697 /**remote server's domain name*/
700 /**remote server's dns name*/
703 /**remote server's forest name*/
706 /**remote server's domain guid*/
707 struct GUID
*domain_guid
;
709 /**remote server's domain SID*/
715 * Retrieves information about the LSA machine/domain
716 * @param hnd initialized and connected server handle
717 * @param mem_ctx Talloc context for memory allocation
718 * @param op input and output parameters
719 * Note: for pre-Windows 2000 machines, only op->out.SID and op->out.domain will be set. @see cac_LsaFetchSid
720 * @return - CAC_FAILURE if the operation was not successful. hnd->status will be set with an accurate NT_STATUS code
721 * @return CAC_SUCCESS the operation was successful.
723 int cac_LsaQueryInfoPolicy(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaQueryInfoPolicy
*op
);
727 /**Open LSA Policy handle*/
730 /**The prefered maximum number of SIDs returned per call*/
731 uint32 pref_max_sids
;
735 /**used to keep track of how many sids have been retrieved over multiple calls
736 * should be set to zero via ZERO_STRUCT() befrore the first call. Use the same struct LsaEnumSids for multiple calls*/
739 /**The number of sids returned this call*/
742 /**Array of sids returned*/
749 * Enumerates the SIDs in the LSA. Can be enumerated in blocks by calling the function multiple times.
750 * Example: while(cac_LsaEnumSids(hnd, mem_ctx, op) { ... }
751 * @param hnd - An initialized and connected server handle
752 * @param mem_ctx Talloc context for memory allocation
753 * @param op Initialized parameters
754 * @return CAC_FAILURE there was an error during operations OR there are no more results
755 * @return CAC_SUCCESS the operation completed and results were returned
757 int cac_LsaEnumSids(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaEnumSids
*op
);
759 struct LsaEnumAccountRights
{
761 /**Open LSA Policy handle*/
764 /**(Optional) SID of the account - must supply either sid or name*/
767 /**(Optional) name of the account - must supply either sid or name*/
772 /**Count of rights for this account*/
775 /**array of privilege names*/
781 * Enumerates rights assigned to a given account. Takes a SID instead of account handle as input
782 * @param hnd Initialized and connected server handle
783 * @param mem_ctx Context for memory allocation
784 * @param op Initialized Parameters
785 * @return CAC_FAILURE the rights could not be retrieved. hnd->status is set with NT_STATUS code
786 * @return CAC_SUCCESS the operation was successful.
789 int cac_LsaEnumAccountRights(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaEnumAccountRights
*op
);
791 struct LsaEnumTrustedDomains
{
793 /**Open LSA policy handle*/
798 /**used to keep track of how many domains have been retrieved over multiple calls
799 * should be set to zero via ZERO_STRUCT() before the first call. Use the same struct LsaEnumSids for multiple calls*/
802 /**The number of domains returned by the remote server this call*/
805 /**array of trusted domain names returned by the remote server*/
808 /**array of trusted domain sids returned by the remote server*/
809 DOM_SID
*domain_sids
;
814 * Enumerates the trusted domains in the LSA.
815 * @param hnd - An initialized and connected server handle
816 * @param mem_ctx Talloc context for memory allocation
817 * @param op - initialized parameters
818 * @return CAC_FAILURE there was an error during operations OR there are no more results
819 * @return CAC_SUCCESS the operation completed and results were returned
821 int cac_LsaEnumTrustedDomains(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaEnumTrustedDomains
*op
);
823 struct LsaOpenTrustedDomain
{
825 /**an open LSA policy handle*/
828 /**SID of the trusted domain to open*/
831 /**Desired access on the open domain*/
836 /**A handle to the policy that is opened*/
837 POLICY_HND
*domain_pol
;
842 * Opens a trusted domain by SID.
843 * @param hnd An initialized and connected server handle
844 * @param mem_ctx Talloc context for memory allocation
845 * @param op initialized I/O parameters
846 * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code
847 * @return CAC_SUCCESS the domain was opened successfully
849 int cac_LsaOpenTrustedDomain(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaOpenTrustedDomain
*op
);
851 struct LsaQueryTrustedDomainInfo
{
853 /**Open LSA policy handle*/
856 /**Info class of returned data*/
859 /**(Optional)SID of trusted domain to query (must specify either SID or name of trusted domain)*/
862 /**(Optional)Name of trusted domain to query (must specify either SID or name of trusted domain)*/
867 /**information about the trusted domain*/
868 LSA_TRUSTED_DOMAIN_INFO
*info
;
873 * Retrieves information a trusted domain.
874 * @param hnd An initialized and connected server handle
875 * @param mem_ctx Talloc context for memory allocation
876 * @param op initialized I/O parameters
877 * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code
878 * @return CAC_SUCCESS the domain was opened successfully
881 int cac_LsaQueryTrustedDomainInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaQueryTrustedDomainInfo
*op
);
883 struct LsaEnumPrivileges
{
885 /**An open LSA policy handle*/
888 /**The _preferred_ maxinum number of privileges returned per call*/
889 uint32 pref_max_privs
;
893 /**Used to keep track of how many privileges have been retrieved over multiple calls. Do not modify this value between calls*/
896 /**The number of privileges returned this call*/
899 /**Array of privilege names*/
902 /**Array of high bits for privilege LUID*/
905 /**Array of low bits for privilege LUID*/
911 * Enumerates the Privileges supported by the LSA. Can be enumerated in blocks by calling the function multiple times.
912 * Example: while(cac_LsaEnumPrivileges(hnd, mem_ctx, op) { ... }
913 * @param hnd An initialized and connected server handle
914 * @param mem_ctx Talloc context for memory allocation
915 * @param op Initialized parameters
916 * @return CAC_FAILURE there was an error during operations OR there are no more results
917 * @return CAC_SUCCESS the operation completed and results were returned
918 * @see CAC_OP_FAILED()
920 int cac_LsaEnumPrivileges(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaEnumPrivileges
*op
);
922 struct LsaOpenAccount
{
924 /**An open LSA policy handle*/
927 /**(Optional) account SID - must supply either sid or name*/
930 /**(Optional) account name - must supply either sid or name*/
933 /**desired access for the handle*/
938 /**A handle to the opened user*/
944 * Opens a handle to an account in the LSA
945 * @param hnd Initialized and connected server handle
946 * @param mem_ctx Context for memory allocation
947 * @param op Initialized Parameters
948 * @return CAC_FAILURE the account could not be opened. hnd->status has appropriate NT_STATUS code
949 * @return CAC_SUCCESS the account was opened
951 int cac_LsaOpenAccount(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaOpenAccount
*op
);
953 struct LsaAddPrivileges
{
955 /**An open LSA policy handle*/
958 /**(Optional) The user's SID (must specify at least sid or name)*/
961 /**(Optional) The user's name (must specify at least sid or name)*/
964 /**The privilege names of the privileges to add for the account*/
967 /**The number of privileges in the priv_names array*/
974 * Adds Privileges an account.
975 * @param hnd Initialized and connected server handle
976 * @param mem_ctx Context for memory allocation
977 * @param op Initialized Parameters
978 * @return CAC_FAILURE the privileges could not be set. hnd->status has appropriate NT_STATUS code
979 * @return CAC_SUCCESS the privileges were set.
981 int cac_LsaAddPrivileges(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaAddPrivileges
*op
);
983 struct LsaRemovePrivileges
{
985 /**An open handle to the LSA*/
988 /**(Optional) The account SID (must specify at least sid or name)*/
991 /**(Optional) The account name (must specify at least sid or name)*/
994 /**The privilege names of the privileges to remove from the account*/
997 /**The number of privileges in the priv_names array*/
1005 * Removes a _specific_ set of privileges from an account
1006 * @param hnd Initialized and connected server handle
1007 * @param mem_ctx Context for memory allocation
1008 * @param op Initialized Parameters
1009 * @return CAC_FAILURE the privileges could not be removed. hnd->status is set with NT_STATUS code
1010 * @return CAC_SUCCESS the privileges were removed
1012 int cac_LsaRemovePrivileges(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaRemovePrivileges
*op
);
1014 struct LsaClearPrivileges
{
1016 /**An open handle to the LSA*/
1019 /**(Optional) The user's SID (must specify at least sid or name)*/
1022 /**(Optional) The user's name (must specify at least sid or name)*/
1029 * Removes ALL privileges from an account
1030 * @param hnd Initialized and connected server handle
1031 * @param mem_ctx Context for memory allocation
1032 * @param op Initialized Parameters
1033 * @return CAC_FAILURE the operation was not successful, hnd->status set with NT_STATUS code
1034 * @return CAC_SUCCESS the opeartion was successful.
1036 int cac_LsaClearPrivileges(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaClearPrivileges
*op
);
1039 * Sets an accounts priviliges. Removes all privileges and then adds specified privileges.
1040 * @param hnd Initialized and connected server handle
1041 * @param mem_ctx Context for memory allocation
1042 * @param op Initialized Parameters
1043 * @return CAC_FAILURE The operation could not complete successfully
1044 * @return CAC_SUCCESS The operation completed successfully
1046 int cac_LsaSetPrivileges(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaAddPrivileges
*op
);
1048 struct LsaGetSecurityObject
{
1050 /**Open LSA policy handle*/
1055 /**Returned security descriptor information*/
1061 * Retrieves Security Descriptor information about the LSA
1062 * @param hnd Initialized and connected server handle
1063 * @param mem_ctx Context for memory allocation
1064 * @param op Initialized Parameters
1065 * @return CAC_FAILURE The operation could not complete successfully
1066 * @return CAC_SUCCESS The operation completed successfully
1068 int cac_LsaGetSecurityObject(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct LsaGetSecurityObject
*op
);
1071 /**@}*/ /*LSA_Functions*/
1073 /**********************
1074 * Registry Functions *
1075 *********************/
1077 /**@addtogroup Reg_Functions
1083 /** must be one of :
1084 * HKEY_CLASSES_ROOT,
1085 * HKEY_LOCAL_MACHINE,
1087 * HKEY_PERFORMANCE_DATA,
1091 /**desired access on the root key
1097 * found in include/rpc_secdes.h*/
1107 * Opens a handle to the registry on the server
1108 * @param hnd Initialized and connected server handle
1109 * @param mem_ctx Context for memory allocation
1110 * @param op Initialized Parameters
1111 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1112 * @return CAC_SUCCESS The operation completed successfully
1114 int cac_RegConnect(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegConnect
*op
);
1117 * Closes an open registry handle
1118 * @param hnd Initialized and connected server handle
1119 * @param mem_ctx Context for memory allocation
1120 * @param key The Key/Handle to close
1121 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1122 * @return CAC_SUCCESS The operation completed successfully
1124 int cac_RegClose(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*key
);
1128 /**(Optional)parent key.
1129 * If this is NULL, then cac_RegOpenKey() will attempt to connect to the registry, name MUST start with something like:<br>
1130 * HKEY_LOCAL_MACHINE\ or an abbreviation like HKCR\
1132 * supported root names:
1133 * - HKEY_LOCAL_MACHINE\ or HKLM\
1134 * - HKEY_CLASSES_ROOT\ or HKCR\
1135 * - HKEY_USERS\ or HKU\
1136 * - HKEY_PERFORMANCE_DATA or HKPD\
1138 POLICY_HND
*parent_key
;
1140 /**name/path of key*/
1143 /**desired access on this key*/
1153 * Opens a registry key
1154 * @param hnd Initialized and connected server handle
1155 * @param mem_ctx Context for memory allocation
1156 * @param op Initialized parameters
1157 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1158 * @return CAC_SUCCESS The operation completed successfully
1161 int cac_RegOpenKey(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegOpenKey
*op
);
1163 struct RegEnumKeys
{
1165 /**enumerate subkeys of this key*/
1168 /**maximum number of keys to enumerate each call*/
1173 /**keeps track of the index to resume enumerating*/
1176 /**the number of keys returned this call*/
1179 /**array of key names*/
1182 /**class names of the keys*/
1185 /**last modification time of the key*/
1191 * Enumerates Subkeys of a given key. Can be run in a loop. Example: while(cac_RegEnumKeys(hnd, mem_ctx, op)) { ... }
1192 * @param hnd Initialized and connected server handle
1193 * @param mem_ctx Context for memory allocation
1194 * @param op Initialized Parameters
1195 * @see CAC_OP_FAILED()
1196 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1197 * @return CAC_SUCCESS The operation completed successfully
1199 int cac_RegEnumKeys(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegEnumKeys
*op
);
1202 struct RegCreateKey
{
1204 /**create a subkey of parent_key*/
1205 POLICY_HND
*parent_key
;
1207 /**name of the key to create*/
1210 /**class of the key*/
1213 /**Access mask to open the key with. See REG_KEY_* in include/rpc_secdes.h*/
1218 /**Open handle to the key*/
1224 * Creates a registry key, if the key already exists, it will be opened __Creating keys is not currently working__.
1225 * @param hnd Initialized and connected server handle
1226 * @param mem_ctx Context for memory allocation
1227 * @param op Initialized Parmeters
1228 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1229 * @return CAC_SUCCESS The operation completed successfully
1231 int cac_RegCreateKey(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegCreateKey
*op
);
1233 struct RegDeleteKey
{
1235 /**handle to open registry key*/
1236 POLICY_HND
*parent_key
;
1238 /**name of the key to delete*/
1241 /**delete recursively. WARNING: this might not always work as planned*/
1248 * 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.
1249 * @param hnd Initialized and connected server handle
1250 * @param mem_ctx Context for memory allocation
1251 * @param op Initialized parameters
1252 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1253 * @return CAC_SUCCESS The operation completed successfully
1256 int cac_RegDeleteKey(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegDeleteKey
*op
);
1258 struct RegDeleteValue
{
1260 /**handle to open registry key*/
1261 POLICY_HND
*parent_key
;
1263 /**name of the value to delete*/
1269 * Deletes a registry value.
1270 * @param hnd Initialized and connected server handle
1271 * @param mem_ctx Context for memory allocation
1272 * @param op Initialized Parameters
1273 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1274 * @return CAC_SUCCESS The operation completed successfully
1276 int cac_RegDeleteValue(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegDeleteValue
*op
);
1278 struct RegQueryKeyInfo
{
1280 /**Open handle to the key to query*/
1285 /**name of the key class*/
1288 /**number of subkeys of the key*/
1291 /**length (in characters) of the longest subkey name*/
1292 uint32 longest_subkey
;
1294 /**length (in characters) of the longest class name*/
1295 uint32 longest_class
;
1297 /**number of values in this key*/
1300 /**length (in characters) of the longest value name*/
1301 uint32 longest_value_name
;
1303 /**length (in bytes) of the biggest value data*/
1304 uint32 longest_value_data
;
1306 /**size (in bytes) of the security descriptor*/
1307 uint32 security_desc_size
;
1309 /**time of the last write*/
1310 time_t last_write_time
;
1315 * Retrieves information about an open key
1316 * @param hnd Initialized and connected server handle
1317 * @param mem_ctx Context for memory allocation
1318 * @param op Initialized parameters
1319 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1320 * @return CAC_SUCCESS The operation completed successfully
1323 int cac_RegQueryKeyInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegQueryKeyInfo
*op
);
1327 /**Open key to be saved*/
1330 /**The path (on the remote computer) to save the file to*/
1336 * Saves a key to a file on the remote machine __Not currently working__.
1337 * @param hnd Initialized and connected server handle
1338 * @param mem_ctx Context for memory allocation
1339 * @param op Initialized parameters
1340 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1341 * @return CAC_SUCCESS The operation completed successfully
1344 int cac_RegSaveKey(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegSaveKey
*op
);
1346 struct RegQueryValue
{
1348 /**handle to open registry key*/
1351 /**name of the value to query*/
1358 * - REG_DWORD (equivalent to REG_DWORD_LE)
1368 REG_VALUE_DATA
*data
;
1373 * Retrieves a value (type and data) _not currently working_.
1374 * @param hnd Initialized and connected server handle
1375 * @param mem_ctx Context for memory allocation
1376 * @param op Initialized parameters
1377 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1378 * @return CAC_SUCCESS The operation completed successfully
1381 int cac_RegQueryValue(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegQueryValue
*op
);
1383 struct RegEnumValues
{
1385 /**handle to open key*/
1388 /**max number of values returned per call*/
1394 /**keeps track of the index to resume from - used over multiple calls*/
1397 /**the number of values that were returned this call*/
1400 /**Array of value types. A type can be one of:
1401 * - REG_DWORD (equivalent to REG_DWORD_LE)
1410 /**array of strings storing the names of the values*/
1413 /**array of pointers to the value data returned*/
1414 REG_VALUE_DATA
**values
;
1419 * Enumerates a number of Registry values in an open registry key.
1420 * Can be run in a loop. Example: while(cac_RegEnumValues(hnd, mem_ctx, op)) { ... }
1421 * @param hnd Initialized and connected server handle
1422 * @param mem_ctx Context for memory allocation
1423 * @param op Initialized Parameters
1424 * @see CAC_OP_FAILED()
1425 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1426 * @return CAC_SUCCESS The operation completed successfully
1428 int cac_RegEnumValues(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegEnumValues
*op
);
1430 struct RegSetValue
{
1432 /**Handle to open registry key*/
1435 /**Name of the value*/
1440 * - REG_DWORD (equivalent to REG_DWORD_LE)
1450 REG_VALUE_DATA value
;
1455 * Sets or creates value (type and data).
1456 * @param hnd Initialized and connected server handle
1457 * @param mem_ctx Context for memory allocation
1458 * @param op Initialized parameters
1459 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1460 * @return CAC_SUCCESS The operation completed successfully
1462 int cac_RegSetValue(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegSetValue
*op
);
1464 struct RegGetVersion
{
1466 /**open registry key*/
1477 * Retrieves the registry version number
1478 * @param hnd Initialized and connected server handle
1479 * @param mem_ctx Context for memory allocation
1480 * @param op Initialized parameters
1481 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1482 * @return CAC_SUCCESS The operation completed successfully
1484 int cac_RegGetVersion(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegGetVersion
*op
);
1486 struct RegGetKeySecurity
{
1488 /**Handle to key to query*/
1491 /**Info that you want. Should be a combination of (1 or more or'd):
1492 * - OWNER_SECURITY_INFORMATION
1493 * - GROUP_SECURITY_INFORMATION
1494 * - DACL_SECURITY_INFORMATION
1495 * - SACL_SECURITY_INFORMATION
1496 * - UNPROTECTED_SACL_SECURITY_INFORMATION
1497 * - UNPROTECTED_DACL_SECURITY_INFORMATION
1498 * - PROTECTED_SACL_SECURITY_INFORMATION
1499 * - PROTECTED_DACL_SECURITY_INFORMATION
1502 * - ALL_SECURITY_INFORMATION
1504 * all definitions from include/rpc_secdes.h
1510 /**size of the data returned*/
1513 /**Security descriptor*/
1514 SEC_DESC
*descriptor
;
1519 * Retrieves a key security descriptor.
1520 * @param hnd Initialized and connected server handle
1521 * @param mem_ctx Context for memory allocation
1522 * @param op Initialized parameters
1523 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1524 * @return CAC_SUCCESS The operation completed successfully
1527 int cac_RegGetKeySecurity(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegGetKeySecurity
*op
);
1529 struct RegSetKeySecurity
{
1531 /**Handle to key to query*/
1534 /**Info that you want. Should be a combination of (1 or more or'd):
1535 * - OWNER_SECURITY_INFORMATION
1536 * - GROUP_SECURITY_INFORMATION
1537 * - DACL_SECURITY_INFORMATION
1538 * - SACL_SECURITY_INFORMATION
1539 * - UNPROTECTED_SACL_SECURITY_INFORMATION
1540 * - UNPROTECTED_DACL_SECURITY_INFORMATION
1541 * - PROTECTED_SACL_SECURITY_INFORMATION
1542 * - PROTECTED_DACL_SECURITY_INFORMATION
1545 * - ALL_SECURITY_INFORMATION
1547 * all definitions from include/rpc_secdes.h
1551 /**size of the descriptor*/
1554 /**Security descriptor*/
1555 SEC_DESC
*descriptor
;
1560 * Sets the key security descriptor.
1561 * @param hnd Initialized and connected server handle
1562 * @param mem_ctx Context for memory allocation
1563 * @param op Initialized parameters
1564 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1565 * @return CAC_SUCCESS The operation completed successfully
1567 int cac_RegSetKeySecurity(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct RegSetKeySecurity
*op
);
1569 /**@}*/ /*Reg_Functions*/
1573 /**the message to display (can be NULL)*/
1576 /**timeout in seconds*/
1579 /**False = shutdown, True = reboot*/
1585 /*FIXME: make this useful*/
1592 * Shutdown the server _not currently working_.
1593 * @param hnd Initialized and connected server handle
1594 * @param mem_ctx Context for memory allocation
1595 * @param op Initialized parameters
1596 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1597 * @return CAC_SUCCESS The operation completed successfully
1599 int cac_Shutdown(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct Shutdown
*op
);
1602 * Attempt to abort initiated shutdown on the server _not currently working_.
1603 * @param hnd Initialized and connected server handle
1604 * @param mem_ctx Context for memory allocation
1605 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1606 * @return CAC_SUCCESS The operation completed successfully
1608 int cac_AbortShutdown(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
);
1614 /**@addtogroup SAM_Functions
1619 /**Access mask to open with
1620 * see generic access masks in include/smb.h*/
1630 * Connects to the SAM. This can be skipped by just calling cac_SamOpenDomain()
1631 * @param hnd Initialized and connected server handle
1632 * @param mem_ctx Context for memory allocation
1633 * @param op Initialized parameters
1634 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1635 * @return CAC_SUCCESS The operation completed successfully
1638 int cac_SamConnect(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamConnect
*op
);
1642 * Closes any (SAM, domain, user, group, etc.) SAM handle.
1643 * @param hnd Initialized and connected server handle
1644 * @param mem_ctx Context for memory allocation
1645 * @param sam Handle to close
1646 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1647 * @return CAC_SUCCESS The operation completed successfully
1650 int cac_SamClose(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*sam
);
1652 struct SamOpenDomain
{
1654 /**The desired access. See generic access masks - include/smb.h*/
1657 /**(Optional) An open handle to the SAM. If it is NULL, the function will connect to the SAM with the access mask above*/
1660 /**(Optional) The SID of the domain to open.
1661 * If this this is NULL, the function will attempt to open the domain specified in hnd->domain */
1666 /**handle to the open domain*/
1667 POLICY_HND
*dom_hnd
;
1669 /**Handle to the open SAM*/
1675 * Opens a handle to a domain. This must be called before any other SAM functions
1676 * @param hnd Initialized and connected server handle
1677 * @param mem_ctx Context for memory allocation
1678 * @param op Initialized parameters
1679 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1680 * @return CAC_SUCCESS The operation completed successfully
1682 int cac_SamOpenDomain(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamOpenDomain
*op
);
1684 struct SamCreateUser
{
1686 /**Open domain handle*/
1687 POLICY_HND
*dom_hnd
;
1692 /**See Allowable account control bits in include/smb.h*/
1697 /**handle to the user*/
1698 POLICY_HND
*user_hnd
;
1700 /**rid of the user*/
1706 * Creates a new domain user, if the account already exists it will _not_ be opened and hnd->status will be NT_STATUS_USER_EXISTS
1707 * @param hnd Initialized and connected server handle
1708 * @param mem_ctx Context for memory allocation
1709 * @param op Initialized parameters
1710 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1711 * @return CAC_SUCCESS The operation completed successfully
1714 int cac_SamCreateUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamCreateUser
*op
);
1716 struct SamOpenUser
{
1718 /**Handle to open SAM connection*/
1719 POLICY_HND
*dom_hnd
;
1721 /**desired access - see generic access masks in include/smb.h*/
1724 /**RID of the user*/
1727 /**(Optional) name of the user - must supply either RID or user name*/
1732 /**Handle to the user*/
1733 POLICY_HND
*user_hnd
;
1738 * Opens a domain user.
1739 * @param hnd Initialized and connected server handle
1740 * @param mem_ctx Context for memory allocation
1741 * @param op Initialized parameters
1742 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1743 * @return CAC_SUCCESS The operation completed successfully
1745 int cac_SamOpenUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamOpenUser
*op
);
1748 * Deletes a domain user.
1749 * @param hnd Initialized and connected server handle
1750 * @param mem_ctx Context for memory allocation
1751 * @param user_hnd Open handle to the user
1752 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1753 * @return CAC_SUCCESS The operation completed successfully
1755 int cac_SamDeleteUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*user_hnd
);
1758 struct SamEnumUsers
{
1760 /**Open handle to a domain*/
1761 POLICY_HND
*dom_hnd
;
1763 /**Enumerate users with specific ACB. If 0, all users will be enumerated*/
1768 /**where to resume from. Used over multiple calls*/
1771 /**the number of users returned this call*/
1774 /**Array storing the rids of the returned users*/
1777 /**Array storing the names of all the users returned*/
1785 * Enumerates domain users. Can be used as a loop condition. Example: while(cac_SamEnumUsers(hnd, mem_ctx, op)) { ... }
1786 * @param hnd Initialized and connected server handle
1787 * @param mem_ctx Context for memory allocation
1788 * @param op Initialized parameters
1789 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1790 * @return CAC_SUCCESS The operation completed successfully
1792 int cac_SamEnumUsers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamEnumUsers
*op
);
1794 struct SamGetNamesFromRids
{
1796 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1797 POLICY_HND
*dom_hnd
;
1799 /**Number of RIDs to resolve*/
1802 /**Array of RIDs to resolve*/
1807 /**the number of names returned - if this is 0, the map is NULL*/
1810 /**array contiaing the Names and RIDs*/
1811 CacLookupRidsRecord
*map
;
1816 * Returns a list of names which map to a list of RIDs.
1817 * @param hnd Initialized and connected server handle
1818 * @param mem_ctx Context for memory allocation
1819 * @param op Initialized parameters
1820 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1821 * @return CAC_SUCCESS The operation completed successfully
1823 int cac_SamGetNamesFromRids(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetNamesFromRids
*op
);
1825 struct SamGetRidsFromNames
{
1827 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1828 POLICY_HND
*dom_hnd
;
1830 /**Number of names to resolve*/
1833 /**Array of names to resolve*/
1838 /**the number of names returned - if this is 0, then map is NULL*/
1841 /**array contiaing the Names and RIDs*/
1842 CacLookupRidsRecord
*map
;
1847 * Returns a list of RIDs which map to a list of names.
1848 * @param hnd Initialized and connected server handle
1849 * @param mem_ctx Context for memory allocation
1850 * @param op Initialized parameters
1851 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1852 * @return CAC_SUCCESS The operation completed successfully
1854 int cac_SamGetRidsFromNames(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetRidsFromNames
*op
);
1856 struct SamGetGroupsForUser
{
1858 /**An open handle to the user*/
1859 POLICY_HND
*user_hnd
;
1863 /**The number of groups the user is a member of*/
1866 /**The RIDs of the groups*/
1869 /**The attributes of the groups*/
1874 * Retrieves a list of groups that a user is a member of.
1875 * @param hnd Initialized and connected server handle
1876 * @param mem_ctx Context for memory allocation
1877 * @param op Initialized parameters
1878 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1879 * @return CAC_SUCCESS The operation completed successfully
1881 int cac_SamGetGroupsForUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetGroupsForUser
*op
);
1883 struct SamOpenGroup
{
1885 /**Open handle to the domain SAM*/
1886 POLICY_HND
*dom_hnd
;
1888 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
1891 /**rid of the group*/
1896 /**Handle to the group*/
1897 POLICY_HND
*group_hnd
;
1902 * Opens a domain group.
1903 * @param hnd Initialized and connected server handle
1904 * @param mem_ctx Context for memory allocation
1905 * @param op Initialized parameters
1906 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1907 * @return CAC_SUCCESS The operation completed successfully
1909 int cac_SamOpenGroup(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamOpenGroup
*op
);
1911 struct SamCreateGroup
{
1913 /**Open handle to the domain SAM*/
1914 POLICY_HND
*dom_hnd
;
1916 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
1919 /**The name of the group*/
1924 /**Handle to the group*/
1925 POLICY_HND
*group_hnd
;
1930 * Creates a group. If the group already exists it will not be opened.
1931 * @param hnd Initialized and connected server handle
1932 * @param mem_ctx Context for memory allocation
1933 * @param op Initialized parameters
1934 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1935 * @return CAC_SUCCESS The operation completed successfully
1937 int cac_SamCreateGroup(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamCreateGroup
*op
);
1940 * Deletes a domain group.
1941 * @param hnd Initialized and connected server handle
1942 * @param mem_ctx Context for memory allocation
1943 * @param group_hnd Open handle to the group.
1944 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1945 * @return CAC_SUCCESS The operation completed successfully
1947 int cac_SamDeleteGroup(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*group_hnd
);
1949 struct SamGetGroupMembers
{
1951 /**Open handle to a group*/
1952 POLICY_HND
*group_hnd
;
1956 /**The number of members in the group*/
1959 /**An array storing the RIDs of the users*/
1968 * Retrives a list of users in a group.
1969 * @param hnd Initialized and connected server handle
1970 * @param mem_ctx Context for memory allocation
1971 * @param op Initialized parameters
1972 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1973 * @return CAC_SUCCESS The operation completed successfully
1975 int cac_SamGetGroupMembers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetGroupMembers
*op
);
1977 struct SamAddGroupMember
{
1979 /**Open handle to a group*/
1980 POLICY_HND
*group_hnd
;
1982 /**RID of new member*/
1988 * Adds a user to a group.
1989 * @param hnd Initialized and connected server handle
1990 * @param mem_ctx Context for memory allocation
1991 * @param op Initialized parameters
1992 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
1993 * @return CAC_SUCCESS The operation completed successfully
1995 int cac_SamAddGroupMember(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamAddGroupMember
*op
);
1997 struct SamRemoveGroupMember
{
1999 /**Open handle to a group*/
2000 POLICY_HND
*group_hnd
;
2002 /**RID of member to remove*/
2008 * Removes a user from a group.
2009 * @param hnd Initialized and connected server handle
2010 * @param mem_ctx Context for memory allocation
2011 * @param op Initialized parameters
2012 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2013 * @return CAC_SUCCESS The operation completed successfully
2015 int cac_SamRemoveGroupMember(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamRemoveGroupMember
*op
);
2018 * Removes all the members of a group - warning: if this function fails is is possible that some but not all members were removed
2019 * @param hnd Initialized and connected server handle
2020 * @param mem_ctx Context for memory allocation
2021 * @param group_hnd Open handle to the group to clear
2022 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2023 * @return CAC_SUCCESS The operation completed successfully
2025 int cac_SamClearGroupMembers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*group_hnd
);
2027 struct SamSetGroupMembers
{
2029 /**Open handle to the group*/
2030 POLICY_HND
*group_hnd
;
2032 /**Number of members in the group - if this is 0, all members of the group will be removed*/
2035 /**The RIDs of the users to add*/
2041 * Clears the members of a group and adds a list of members to the group
2042 * @param hnd Initialized and connected server handle
2043 * @param mem_ctx Context for memory allocation
2044 * @param op Initialized parameters
2045 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2046 * @return CAC_SUCCESS The operation completed successfully
2048 int cac_SamSetGroupMembers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetGroupMembers
*op
);
2050 struct SamEnumGroups
{
2052 /**Open handle to a domain*/
2053 POLICY_HND
*dom_hnd
;
2057 /**Where to resume from _do not_ modify this value. Used over multiple calls.*/
2060 /**the number of users returned this call*/
2063 /**Array storing the rids of the returned groups*/
2066 /**Array storing the names of all the groups returned*/
2069 /**Array storing the descriptions of all the groups returned*/
2070 char **descriptions
;
2077 * Enumerates domain groups. Can be used as a loop condition. Example: while(cac_SamEnumGroups(hnd, mem_ctx, op)) { ... }
2078 * @param hnd Initialized and connected server handle
2079 * @param mem_ctx Context for memory allocation
2080 * @param op Initialized parameters
2081 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2082 * @return CAC_SUCCESS The operation completed successfully
2084 int cac_SamEnumGroups(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamEnumGroups
*op
);
2086 struct SamEnumAliases
{
2088 /**Open handle to a domain*/
2089 POLICY_HND
*dom_hnd
;
2093 /**where to resume from. Used over multiple calls*/
2096 /**the number of users returned this call*/
2099 /**Array storing the rids of the returned groups*/
2102 /**Array storing the names of all the groups returned*/
2105 /**Array storing the descriptions of all the groups returned*/
2106 char **descriptions
;
2113 * Enumerates domain aliases. Can be used as a loop condition. Example: while(cac_SamEnumAliases(hnd, mem_ctx, op)) { ... }
2114 * @param hnd Initialized and connected server handle
2115 * @param mem_ctx Context for memory allocation
2116 * @param op Initialized parameters
2117 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2118 * @return CAC_SUCCESS The operation completed successfully
2120 int cac_SamEnumAliases(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamEnumAliases
*op
);
2122 struct SamCreateAlias
{
2124 /**Open handle to the domain SAM*/
2125 POLICY_HND
*dom_hnd
;
2127 /**The name of the alias*/
2132 /**Handle to the group*/
2133 POLICY_HND
*alias_hnd
;
2138 * Creates an alias. If the alias already exists it will not be opened.
2139 * @param hnd Initialized and connected server handle
2140 * @param mem_ctx Context for memory allocation
2141 * @param op Initialized parameters
2142 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2143 * @return CAC_SUCCESS The operation completed successfully
2146 int cac_SamCreateAlias(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamCreateAlias
*op
);
2148 struct SamOpenAlias
{
2150 /**Open handle to the domain SAM*/
2151 POLICY_HND
*dom_hnd
;
2153 /**Desired access to open the group with. See Generic access masks in include/smb.h*/
2156 /**rid of the alias*/
2161 /**Handle to the alias*/
2162 POLICY_HND
*alias_hnd
;
2167 * Opens a handle to an alias.
2168 * @param hnd Initialized and connected server handle
2169 * @param mem_ctx Context for memory allocation
2170 * @param op Initialized parameters
2171 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2172 * @return CAC_SUCCESS The operation completed successfully
2174 int cac_SamOpenAlias(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamOpenAlias
*op
);
2178 * @param hnd Initialized and connected server handle
2179 * @param mem_ctx Context for memory allocation
2180 * @param alias_hnd Open handle to the alias
2181 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2182 * @return CAC_SUCCESS The operation completed successfully
2184 int cac_SamDeleteAlias(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*alias_hnd
);
2186 struct SamAddAliasMember
{
2188 /**Open handle to a alias*/
2189 POLICY_HND
*alias_hnd
;
2191 /**SID of new member*/
2197 * Adds an account to an alias.
2198 * @param hnd Initialized and connected server handle
2199 * @param mem_ctx Context for memory allocation
2200 * @param op Initialized parameters
2201 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2202 * @return CAC_SUCCESS The operation completed successfully
2204 int cac_SamAddAliasMember(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamAddAliasMember
*op
);
2206 struct SamRemoveAliasMember
{
2208 /**Open handle to the alias*/
2209 POLICY_HND
*alias_hnd
;
2211 /**The SID of the member*/
2217 * Removes an account from an alias.
2218 * @param hnd Initialized and connected server handle
2219 * @param mem_ctx Context for memory allocation
2220 * @param op Initialized parameters
2221 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2222 * @return CAC_SUCCESS The operation completed successfully
2224 int cac_SamRemoveAliasMember(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamRemoveAliasMember
*op
);
2226 struct SamGetAliasMembers
{
2228 /**Open handle to the alias*/
2229 POLICY_HND
*alias_hnd
;
2233 /**The number of members*/
2236 /**An array storing the SIDs of the accounts*/
2242 * Retrieves a list of all accounts in an alias.
2243 * @param hnd Initialized and connected server handle
2244 * @param mem_ctx Context for memory allocation
2245 * @param op Initialized parameters
2246 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2247 * @return CAC_SUCCESS The operation completed successfully
2249 int cac_SamGetAliasMembers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetAliasMembers
*op
);
2252 * Removes all the members of an alias - warning: if this function fails is is possible that some but not all members were removed
2253 * @param hnd Initialized and connected server handle
2254 * @param mem_ctx Context for memory allocation
2255 * @param alias_hnd Handle to the alias to clear
2256 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2257 * @return CAC_SUCCESS The operation completed successfully
2260 int cac_SamClearAliasMembers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*alias_hnd
);
2262 struct SamSetAliasMembers
{
2264 /**Open handle to the group*/
2265 POLICY_HND
*alias_hnd
;
2267 /**Number of members in the group - if this is 0, all members of the group will be removed*/
2270 /**The SIDs of the accounts to add*/
2276 * Clears the members of an alias and adds a list of members to the alias
2277 * @param hnd Initialized and connected server handle
2278 * @param mem_ctx Context for memory allocation
2279 * @param op Initialized parameters
2280 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2281 * @return CAC_SUCCESS The operation completed successfully
2283 int cac_SamSetAliasMembers(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetAliasMembers
*op
);
2286 struct SamUserChangePasswd
{
2291 /**The current password*/
2294 /**The new password*/
2298 /**Used by a user to change their password*/
2299 int cac_SamUserChangePasswd(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamUserChangePasswd
*op
);
2303 * @param hnd Initialized and connected server handle
2304 * @param mem_ctx Context for memory allocation
2305 * @param user_hnd Open handle to the user to enable
2306 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2307 * @return CAC_SUCCESS The operation completed successfully
2309 int cac_SamEnableUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*user_hnd
);
2313 * @param hnd Initialized and connected server handle
2314 * @param mem_ctx Context for memory allocation
2315 * @param user_hnd Open handle to the user to disables
2316 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2317 * @return CAC_SUCCESS The operation completed successfully
2319 int cac_SamDisableUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*user_hnd
);
2321 struct SamSetPassword
{
2323 /**Open handle to a user*/
2324 POLICY_HND
*user_hnd
;
2326 /**The new password*/
2332 * Sets a user's password
2333 * @param hnd Initialized and connected server handle
2334 * @param mem_ctx Context for memory allocation
2335 * @param op Initialized parameters
2336 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2337 * @return CAC_SUCCESS The operation completed successfully
2340 int cac_SamSetPassword(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetPassword
*op
);
2342 struct SamGetUserInfo
{
2344 /**Open Handle to a user*/
2345 POLICY_HND
*user_hnd
;
2354 * Retrieves user information using a CacUserInfo structure. If you would like to use a SAM_USERINFO_CTR directly, use cac_SamGetUserInfoCtr()
2355 * @param hnd Initialized and connected server handle
2356 * @param mem_ctx Context for memory allocation
2357 * @param op Initialized parameters
2358 * @see cac_SamGetUserInfoCtr()
2359 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2360 * @return CAC_SUCCESS The operation completed successfully
2362 int cac_SamGetUserInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetUserInfo
*op
);
2364 struct SamSetUserInfo
{
2366 /**Open handle to a user*/
2367 POLICY_HND
*user_hnd
;
2369 /**Structure containing the data you would like to set*/
2375 * Sets the user info using a CacUserInfo structure. If you would like to use a SAM_USERINFO_CTR directly use cac_SamSetUserInfoCtr().
2376 * @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().
2377 * @note When calling this, you _must_ set the user's password.
2378 * @param hnd Initialized and connected server handle
2379 * @param mem_ctx Context for memory allocation
2380 * @param op Initialized parameters
2381 * @see cac_SamSetUserInfoCtr()
2382 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2383 * @return CAC_SUCCESS The operation completed successfully
2385 int cac_SamSetUserInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetUserInfo
*op
);
2387 struct SamGetUserInfoCtr
{
2389 /**Open handle to a user*/
2390 POLICY_HND
*user_hnd
;
2392 /**What USER_INFO structure you want. See include/rpc_samr.h*/
2397 /**returned user info*/
2398 SAM_USERINFO_CTR
*ctr
;
2403 * Retrieves user information using a SAM_USERINFO_CTR structure. If you don't want to use this structure, user SamGetUserInfo()
2404 * @param hnd Initialized and connected server handle
2405 * @param mem_ctx Context for memory allocation
2406 * @param op Initialized parameters
2407 * @see cac_SamGetUserInfo()
2408 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2409 * @return CAC_SUCCESS The operation completed successfully
2411 int cac_SamGetUserInfoCtr(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetUserInfoCtr
*op
);
2413 struct SamSetUserInfoCtr
{
2415 /**Open handle to a user*/
2416 POLICY_HND
*user_hnd
;
2418 /**user info - make sure ctr->switch_value is set properly*/
2419 SAM_USERINFO_CTR
*ctr
;
2424 * Sets the user info using a SAM_USERINFO_CTR structure. If you don't want to use this structure, use cac_SamSetUserInfo()
2425 * @param hnd Initialized and connected server handle
2426 * @param mem_ctx Context for memory allocation
2427 * @param op Initialized parameters
2428 * @see cac_SamSetUserInfo()
2429 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2430 * @return CAC_SUCCESS The operation completed successfully
2433 int cac_SamSetUserInfoCtr(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetUserInfoCtr
*op
);
2435 struct SamRenameUser
{
2437 /**Open handle to user*/
2438 POLICY_HND
*user_hnd
;
2446 * Changes the name of a user.
2447 * @param hnd Initialized and connected server handle
2448 * @param mem_ctx Context for memory allocation
2449 * @param op Initialized parameters
2450 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2451 * @return CAC_SUCCESS The operation completed successfully
2453 int cac_SamRenameUser(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamRenameUser
*op
);
2455 struct SamGetGroupInfo
{
2457 /**Open handle to a group*/
2458 POLICY_HND
*group_hnd
;
2462 /**Returned info about the group*/
2468 * Retrieves information about a group.
2469 * @param hnd Initialized and connected server handle
2470 * @param mem_ctx Context for memory allocation
2471 * @param op Initialized parameters
2472 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2473 * @return CAC_SUCCESS The operation completed successfully
2475 int cac_SamGetGroupInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetGroupInfo
*op
);
2477 struct SamSetGroupInfo
{
2479 /**Open handle to a group*/
2480 POLICY_HND
*group_hnd
;
2488 * Sets information about a group.
2489 * @param hnd Initialized and connected server handle
2490 * @param mem_ctx Context for memory allocation
2491 * @param op Initialized parameters
2492 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2493 * @return CAC_SUCCESS The operation completed successfully
2495 int cac_SamSetGroupInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetGroupInfo
*op
);
2497 struct SamRenameGroup
{
2499 /**Open handle to a group*/
2500 POLICY_HND
*group_hnd
;
2508 * Changes the name of a group
2509 * @param hnd Initialized and connected server handle
2510 * @param mem_ctx Context for memory allocation
2511 * @param op Initialized parameters
2512 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2513 * @return CAC_SUCCESS The operation completed successfully
2516 int cac_SamRenameGroup(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamRenameGroup
*op
);
2518 struct SamGetAliasInfo
{
2520 /**Open handle to an alias*/
2521 POLICY_HND
*alias_hnd
;
2525 /**Returned alias info*/
2531 * Retrieves information about an alias.
2532 * @param hnd Initialized and connected server handle
2533 * @param mem_ctx Context for memory allocation
2534 * @param op Initialized parameters
2535 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2536 * @return CAC_SUCCESS The operation completed successfully
2538 int cac_SamGetAliasInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetAliasInfo
*op
);
2540 struct SamSetAliasInfo
{
2542 /**Open handle to an alias*/
2543 POLICY_HND
*alias_hnd
;
2545 /**Returned alias info*/
2551 * Sets information about an alias.
2552 * @param hnd Initialized and connected server handle
2553 * @param mem_ctx Context for memory allocation
2554 * @param op Initialized parameters
2555 * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code
2556 * @return CAC_SUCCESS The operation completed successfully
2558 int cac_SamSetAliasInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamSetAliasInfo
*op
);
2560 struct SamGetDomainInfo
{
2562 /**Open handle to the domain SAM*/
2563 POLICY_HND
*dom_hnd
;
2567 /**Returned domain info*/
2568 CacDomainInfo
*info
;
2573 * Gets domain information in the form of a CacDomainInfo structure.
2574 * @param hnd Initialized and connected server handle
2575 * @param mem_ctx Context for memory allocation
2576 * @param op Initialized parameters
2577 * @see SamGetDomainInfoCtr()
2578 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2579 * @return CAC_SUCCESS - the operation was successful
2580 * @return CAC_PARTIAL_SUCCESS - This function makes 3 rpc calls, if one or two fail and the rest succeed,
2581 * not all fields in the CacDomainInfo structure will be filled
2583 int cac_SamGetDomainInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetDomainInfo
*op
);
2585 struct SamGetDomainInfoCtr
{
2587 /**Open handle to domain*/
2588 POLICY_HND
*dom_hnd
;
2590 /**What info level you want*/
2600 * Gets domain information in the form of a SAM_UNK_CTR structure.
2601 * @param hnd Initialized and connected server handle
2602 * @param mem_ctx Context for memory allocation
2603 * @param op Initialized parameters
2604 * @see SamGetDomainInfo()
2605 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2606 * @return CAC_SUCCESS - the operation was successful
2608 int cac_SamGetDomainInfoCtr(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetDomainInfoCtr
*op
);
2610 struct SamGetDisplayInfo
{
2612 /**Open handle to domain*/
2613 POLICY_HND
*dom_hnd
;
2615 /**What type of data*/
2618 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2621 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2626 /**Do not modify this value, use the same value between multiple calls (ie in while loop)*/
2629 /**Number of entries returned*/
2632 /**Returned display info*/
2633 SAM_DISPINFO_CTR ctr
;
2635 /**Internal value. Do not modify.*/
2643 * Gets dislpay information using a SAM_DISPINFO_CTR.
2644 * @param hnd Initialized and connected server handle
2645 * @param mem_ctx Context for memory allocation
2646 * @param op Initialized parameters
2647 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2648 * @return CAC_SUCCESS - the operation was successful
2650 int cac_SamGetDisplayInfo(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetDisplayInfo
*op
);
2652 struct SamLookupDomain
{
2654 /**Open handle to the sam (opened with cac_SamConnect() or cac_SamOpenDomain()*/
2657 /**Name of the domain to lookup*/
2662 /**SID of the domain*/
2668 * Looks up a Domain SID given it's name.
2669 * @param hnd Initialized and connected server handle
2670 * @param mem_ctx Context for memory allocation
2671 * @param op Initialized parameters
2672 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2673 * @return CAC_SUCCESS - the operation was successful
2675 int cac_SamLookupDomain(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamLookupDomain
*op
);
2677 struct SamGetSecurityObject
{
2679 /**An open handle (SAM, domain or user)*/
2689 * Retrievies Security descriptor information for a SAM/Domain/user
2690 * @param hnd Initialized and connected server handle
2691 * @param mem_ctx Context for memory allocation
2692 * @param op Initialized parameters
2693 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2694 * @return CAC_SUCCESS - the operation was successful
2696 int cac_SamGetSecurityObject(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamGetSecurityObject
*op
);
2700 /**Open handle to the domain SAM*/
2701 POLICY_HND
*dom_hnd
;
2703 /**(Optional)Domain SID. If NULL, the domain in hnd->domain will be opened*/
2706 /**(Optional)Desired access to re-open the domain with. If 0, MAXIMUM_ALLOWED_ACCESS is used.*/
2712 * Closes the domain handle, then re-opens it - effectively flushing any changes made.
2713 * WARNING: if this fails you will no longer have an open handle to the domain SAM.
2714 * @param hnd Initialized and connected server handle
2715 * @param mem_ctx Context for memory allocation
2716 * @param op Initialized Parameters
2717 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2718 * @return CAC_SUCCESS - the operation was successful
2720 int cac_SamFlush(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamFlush
*op
);
2722 /**@}*/ /*SAM_Functions*/
2724 /**@addtogroup SCM_Functions
2730 /**Desired access to open the Handle with. See SC_RIGHT_MGR_* or SC_MANAGER_* in include/rpc_secdes.h*/
2735 /**Handle to the SCM*/
2736 POLICY_HND
*scm_hnd
;
2741 * Opens a handle to the SCM on the remote machine.
2742 * @param hnd Initialized and connected server handle
2743 * @param mem_ctx Context for memory allocation
2744 * @param op Initialized parameters
2745 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2746 * @return CAC_SUCCESS - the operation was successful
2748 int cac_SvcOpenScm(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcOpenScm
*op
);
2751 * Closes an Svc handle (SCM or Service)
2752 * @param hnd Initialized and connected server handle
2753 * @param mem_ctx Context for memory allocation
2754 * @param scm_hnd The handle to close
2755 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2756 * @return CAC_SUCCESS - the operation was successful
2758 int cac_SvcClose(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, POLICY_HND
*scm_hnd
);
2760 struct SvcEnumServices
{
2762 /**Open handle to the SCM*/
2763 POLICY_HND
*scm_hnd
;
2765 /**(Optional)Type of service to enumerate. Possible values:
2766 * - SVCCTL_TYPE_WIN32
2767 * - SVCCTL_TYPE_DRIVER
2768 * If this is 0, (SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32) is assumed.
2772 /**(Optional)State of service to enumerate. Possible values:
2773 * - SVCCTL_STATE_ACTIVE
2774 * - SVCCTL_STATE_INACTIVE
2775 * - SVCCTL_STATE_ALL
2776 * If this is 0, SVCCTL_STATE_ALL is assumed.
2782 /**Number of services returned*/
2783 uint32 num_services
;
2785 /**Array of service structures*/
2786 CacService
*services
;
2791 * Enumerates services on the remote machine.
2792 * @param hnd Initialized and connected server handle
2793 * @param mem_ctx Context for memory allocation
2794 * @param op Initialized parameters
2795 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2796 * @return CAC_SUCCESS - the operation was successful
2798 int cac_SvcEnumServices(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcEnumServices
*op
);
2800 struct SvcOpenService
{
2802 /**Handle to the Service Control Manager*/
2803 POLICY_HND
*scm_hnd
;
2805 /**Access mask to open service with see SERVICE_* or SC_RIGHT_SVC_* in include/rpc_secdes.h*/
2808 /**The name of the service. _not_ the display name*/
2813 /**Handle to the open service*/
2814 POLICY_HND
*svc_hnd
;
2819 * Opens a handle to a service.
2820 * @param hnd Initialized and connected server handle
2821 * @param mem_ctx Context for memory allocation
2822 * @param op Initialized Parameters
2823 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2824 * @return CAC_SUCCESS - the operation was successful
2827 int cac_SvcOpenService(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcOpenService
*op
);
2829 struct SvcGetStatus
{
2831 /**Open handle to the service to query*/
2832 POLICY_HND
*svc_hnd
;
2836 /**The status of the service. See include/rpc_svcctl.h for SERVICE_STATUS definition.*/
2837 SERVICE_STATUS status
;
2842 * Retrieves the status of a service.
2843 * @param hnd Initialized and connected server handle
2844 * @param mem_ctx Context for memory allocation
2845 * @param op Initialized Parameters
2846 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2847 * @return CAC_SUCCESS - the operation was successful
2849 int cac_SvcGetStatus(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcGetStatus
*op
);
2851 struct SvcStartService
{
2853 /**open handle to the service*/
2854 POLICY_HND
*svc_hnd
;
2856 /**Array of parameters to start the service with. Can be NULL if num_parms is 0*/
2859 /**Number of parameters in the parms array*/
2862 /**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*/
2868 * Attempts to start a service.
2869 * @param hnd Initialized and connected server handle
2870 * @param mem_ctx Context for memory allocation
2871 * @param op Initialized Parameters
2872 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2873 * @return CAC_SUCCESS - the operation was successful
2876 int cac_SvcStartService(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcStartService
*op
);
2878 struct SvcControlService
{
2880 /**Open handle to the service to control*/
2881 POLICY_HND
*svc_hnd
;
2883 /**The control operation to perform. Possible values (from include/rpc_svcctl.h):
2884 * - SVCCTL_CONTROL_STOP
2885 * - SVCCTL_CONTROL_PAUSE
2886 * - SVCCTL_CONTROL_CONTINUE
2887 * - SVCCTL_CONTROL_SHUTDOWN
2893 /**The returned status of the service, _immediately_ after the call*/
2894 SERVICE_STATUS
*status
;
2899 * Performs a control operation on a service and _immediately_ returns.
2900 * @see cac_SvcStopService()
2901 * @see cac_SvcPauseService()
2902 * @see cac_SvcContinueService()
2903 * @see cac_SvcShutdownService()
2904 * @param hnd Initialized and connected server handle
2905 * @param mem_ctx Context for memory allocation
2906 * @param op Initialized Parameters
2907 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
2908 * @return CAC_SUCCESS - the operation was successful
2910 int cac_SvcControlService(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcControlService
*op
);
2912 struct SvcStopService
{
2914 /**Open handle to the service*/
2915 POLICY_HND
*svc_hnd
;
2917 /**Number of seconds to wait for the service to actually start.
2918 * 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
2924 /**Status of the service after the operation*/
2925 SERVICE_STATUS status
;
2930 * Attempts to stop a service.
2931 * @see cacSvcControlService()
2932 * @param hnd Initialized and connected server handle
2933 * @param mem_ctx Context for memory allocation
2934 * @param op Initialized Parameters
2935 * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured.
2936 * @return CAC_SUCCESS - the operation was successful
2938 int cac_SvcStopService(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcStopService
*op
);
2940 struct SvcPauseService
{
2942 /**Open handle to the service*/
2943 POLICY_HND
*svc_hnd
;
2945 /**Number of seconds to wait for the service to actually start.
2946 * 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
2952 /**Status of the service after the operation*/
2953 SERVICE_STATUS status
;
2958 * Attempts to pause a service.
2959 * @see cacSvcControlService()
2960 * @param hnd Initialized and connected server handle
2961 * @param mem_ctx Context for memory allocation
2962 * @param op Initialized Parameters
2963 * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured.
2964 * @return CAC_SUCCESS - the operation was successful
2966 int cac_SvcPauseService(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcPauseService
*op
);
2968 struct SvcContinueService
{
2970 /**Open handle to the service*/
2971 POLICY_HND
*svc_hnd
;
2973 /**Number of seconds to wait for the service to actually start.
2974 * 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
2980 /**Status of the service after the operation*/
2981 SERVICE_STATUS status
;
2986 * Attempts to continue a paused service.
2987 * @see cacSvcControlService()
2988 * @param hnd Initialized and connected server handle
2989 * @param mem_ctx Context for memory allocation
2990 * @param op Initialized Parameters
2991 * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured.
2992 * @return CAC_SUCCESS - the operation was successful
2994 int cac_SvcContinueService(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcContinueService
*op
);
2996 struct SvcGetDisplayName
{
2998 /**Open handle to the service*/
2999 POLICY_HND
*svc_hnd
;
3003 /**The returned display name of the service*/
3009 * Retrieves the display name of a service _not currently working_
3010 * @param hnd Initialized and connected server handle
3011 * @param mem_ctx Context for memory allocation
3012 * @param op Initialized Parameters
3013 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
3014 * @return CAC_SUCCESS - the operation was successful
3016 int cac_SvcGetDisplayName(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcGetDisplayName
*op
);
3018 struct SvcGetServiceConfig
{
3020 /**Open handle to the service*/
3021 POLICY_HND
*svc_hnd
;
3025 /**Returned Configuration information*/
3026 CacServiceConfig config
;
3031 * Retrieves configuration information about a service.
3032 * @param hnd Initialized and connected server handle
3033 * @param mem_ctx Context for memory allocation
3034 * @param op Initialized Parameters
3035 * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately
3036 * @return CAC_SUCCESS - the operation was successful
3038 int cac_SvcGetServiceConfig(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SvcGetServiceConfig
*op
);
3040 /**@}*/ /*SCM_Functions*/
3042 struct rpc_pipe_client
*cac_GetPipe(CacServerHandle
*hnd
, int pi_idx
);
3044 #endif /* LIBMSRPC_H */