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 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/>.
26 #include "libsmbclient.h"
27 #include "libsmb_internal.h"
29 /*server capability levels*/
32 #define SRV_WIN_2K_SP3 3
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*/
48 /**Operation was successful*/
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
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
{
121 /**The name of the object which maps to this SID*/
124 /**The domain the SID belongs to*/
130 * @addtogroup reg_defs
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
{
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
{
158 typedef union _REGVALUEDATA
{
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
;
169 * @addtogroup sam_defs
173 #define CAC_USER_RID 0x1
174 #define CAC_GROUP_RID 0x2
176 typedef struct _CACLOOKUPRIDSRECORD
{
180 /**If found, this will be one of:
186 /*if the name or RID was looked up, then found = True*/
188 } CacLookupRidsRecord
;
190 typedef struct _CACUSERINFO
{
194 /**Last logoff time*/
197 /**Last 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];
218 /**RID of primary group*/
224 /**Bad password count*/
225 uint16 bad_passwd_count
;
227 /**Number of logons*/
230 /**Change password at next logon?*/
231 bool pass_must_change
;
236 /**User's full name*/
239 /**User's home directory*/
242 /**Home directory drive*/
251 /**Account description*/
254 /**Login from workstations*/
259 /**Possible logon hours*/
260 LOGON_HRS
*logon_hours
;
264 typedef struct _CACGROUPINFO
{
271 /**Number of members*/
273 } CacGroupInfo
, CacAliasInfo
;
275 /**Represents a period (duration) of time*/
276 typedef struct _CACTIME
{
283 /**Number of minutes*/
286 /**number of seconds*/
291 typedef struct _CACDOMINFO
{
292 /**The server role. Should be one of:
301 /**Number of domain users*/
304 /**Number of domain groups*/
305 uint32 num_domain_groups
;
307 /**Number of local groups*/
308 uint32 num_local_groups
;
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*/
325 /**How long (from now) before passwords 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
;
343 /**@addtogroup svc_defs
346 typedef struct _CACSERVICE
{
347 /**The service name*/
350 /**The display name of the service*/
353 /**Current status of the service - see include/rpc_svcctl.h for SERVICE_STATUS definition*/
354 SERVICE_STATUS status
;
357 typedef struct __CACSERVICECONFIG
{
358 /**The service 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
369 uint32 error_control
;
371 /**Path to executable*/
375 char *load_order_group
;
379 /**Any dependencies for the service*/
385 /**Service display name*/
391 #include "libmsrpc_internal.h"
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
{
415 /** netbios name used to make connections
419 /** domain name used to make connections
423 /** username used to make connections
427 /** user's password plain text string
431 /** name or IP address of server we are currently working with
435 /**stores the latest NTSTATUS code
439 /** internal. do not modify!
441 struct CacServerHandleInternal _internal
;
447 /**internal function. do not call this function*/
448 SMBCSRV
*cac_GetServer(CacServerHandle
*hnd
);
451 /** @addtogroup Library_Functions
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
,
545 /** @addtogroup LSA_Functions
549 struct LsaOpenPolicy
{
552 /**Access Mask. Refer to Security Access Masks in include/rpc_secdes.h*/
555 /**Use security quality of service? (True/False)*/
561 /**Handle to the open policy (needed for all other operations)*/
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
);
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
{
591 /**handle to and open LSA policy*/
594 /**the number of SIDs to lookup*/
597 /**array of SIDs to lookup*/
602 /**The number of names returned (in case of CAC_PARTIAL_SUCCESS)*/
605 /**array of SID info each index is one sid */
608 /**in case of partial success, an array of SIDs that could not be looked up (NULL if all sids were looked up)*/
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
{
626 /**handle to an open LSA policy*/
629 /**number of SIDs to lookup*/
632 /**array of strings listing the names*/
637 /**The number of SIDs returned (in case of partial success*/
640 /**array of SID info for the looked up names*/
643 /**in case of partial success, the names that were not looked up*/
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
);
661 /**handle to an open LSA policy*/
664 /**can be CAC_LOCAL_INFO, CAC_DOMAIN_INFO, or (CAC_LOCAL_INFO | CAC_DOMAIN_INFO)*/
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
;
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
{
691 /**Open LSA policy handle on remote server*/
696 /**remote server's domain name*/
699 /**remote server's dns name*/
702 /**remote server's forest name*/
705 /**remote server's domain guid*/
706 struct GUID
*domain_guid
;
708 /**remote server's domain SID*/
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
);
726 /**Open LSA Policy handle*/
729 /**The prefered maximum number of SIDs returned per call*/
730 uint32 pref_max_sids
;
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*/
738 /**The number of sids returned this call*/
741 /**Array of sids returned*/
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
{
760 /**Open LSA Policy handle*/
763 /**(Optional) SID of the account - must supply either sid or name*/
766 /**(Optional) name of the account - must supply either sid or name*/
771 /**Count of rights for this account*/
774 /**array of privilege names*/
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
{
792 /**Open LSA policy handle*/
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*/
801 /**The number of domains returned by the remote server this call*/
804 /**array of trusted domain names returned by the remote server*/
807 /**array of trusted domain sids returned by the remote server*/
808 DOM_SID
*domain_sids
;
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
{
824 /**an open LSA policy handle*/
827 /**SID of the trusted domain to open*/
830 /**Desired access on the open domain*/
835 /**A handle to the policy that is opened*/
836 POLICY_HND
*domain_pol
;
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
{
852 /**Open LSA policy handle*/
855 /**Info class of returned data*/
858 /**(Optional)SID of trusted domain to query (must specify either SID or name of trusted domain)*/
861 /**(Optional)Name of trusted domain to query (must specify either SID or name of trusted domain)*/
866 /**information about the trusted domain*/
867 LSA_TRUSTED_DOMAIN_INFO
*info
;
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
{
884 /**An open LSA policy handle*/
887 /**The _preferred_ maxinum number of privileges returned per call*/
888 uint32 pref_max_privs
;
892 /**Used to keep track of how many privileges have been retrieved over multiple calls. Do not modify this value between calls*/
895 /**The number of privileges returned this call*/
898 /**Array of privilege names*/
901 /**Array of high bits for privilege LUID*/
904 /**Array of low bits for privilege LUID*/
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
{
923 /**An open LSA policy handle*/
926 /**(Optional) account SID - must supply either sid or name*/
929 /**(Optional) account name - must supply either sid or name*/
932 /**desired access for the handle*/
937 /**A handle to the opened user*/
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
{
954 /**An open LSA policy handle*/
957 /**(Optional) The user's SID (must specify at least sid or name)*/
960 /**(Optional) The user's name (must specify at least sid or name)*/
963 /**The privilege names of the privileges to add for the account*/
966 /**The number of privileges in the priv_names array*/
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
{
984 /**An open handle to the LSA*/
987 /**(Optional) The account SID (must specify at least sid or name)*/
990 /**(Optional) The account name (must specify at least sid or name)*/
993 /**The privilege names of the privileges to remove from the account*/
996 /**The number of privileges in the priv_names array*/
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
{
1015 /**An open handle to the LSA*/
1018 /**(Optional) The user's SID (must specify at least sid or name)*/
1021 /**(Optional) The user's name (must specify at least sid or name)*/
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
);
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
{
1049 /**Open LSA policy handle*/
1054 /**Returned security descriptor information*/
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
1082 /** must be one of :
1083 * HKEY_CLASSES_ROOT,
1084 * HKEY_LOCAL_MACHINE,
1086 * HKEY_PERFORMANCE_DATA,
1090 /**desired access on the root key
1096 * found in include/rpc_secdes.h*/
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
);
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*/
1142 /**desired access on this key*/
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
{
1164 /**enumerate subkeys of this key*/
1167 /**maximum number of keys to enumerate each call*/
1172 /**keeps track of the index to resume enumerating*/
1175 /**the number of keys returned this call*/
1178 /**array of key names*/
1181 /**class names of the keys*/
1184 /**last modification time of the key*/
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
{
1203 /**create a subkey of parent_key*/
1204 POLICY_HND
*parent_key
;
1206 /**name of the key to create*/
1209 /**class of the key*/
1212 /**Access mask to open the key with. See REG_KEY_* in include/rpc_secdes.h*/
1217 /**Open handle to the key*/
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
{
1234 /**handle to open registry key*/
1235 POLICY_HND
*parent_key
;
1237 /**name of the key to delete*/
1240 /**delete recursively. WARNING: this might not always work as planned*/
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
{
1259 /**handle to open registry key*/
1260 POLICY_HND
*parent_key
;
1262 /**name of the value to delete*/
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
{
1279 /**Open handle to the key to query*/
1284 /**name of the key class*/
1287 /**number of subkeys of the key*/
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*/
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
;
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
);
1326 /**Open key to be saved*/
1329 /**The path (on the remote computer) to save the file to*/
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
{
1347 /**handle to open registry key*/
1350 /**name of the value to query*/
1357 * - REG_DWORD (equivalent to REG_DWORD_LE)
1367 REG_VALUE_DATA
*data
;
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
{
1384 /**handle to open key*/
1387 /**max number of values returned per call*/
1393 /**keeps track of the index to resume from - used over multiple calls*/
1396 /**the number of values that were returned this call*/
1399 /**Array of value types. A type can be one of:
1400 * - REG_DWORD (equivalent to REG_DWORD_LE)
1409 /**array of strings storing the names of the values*/
1412 /**array of pointers to the value data returned*/
1413 REG_VALUE_DATA
**values
;
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
{
1431 /**Handle to open registry key*/
1434 /**Name of the value*/
1439 * - REG_DWORD (equivalent to REG_DWORD_LE)
1449 REG_VALUE_DATA value
;
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
{
1465 /**open registry key*/
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
{
1487 /**Handle to key to query*/
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
1501 * - ALL_SECURITY_INFORMATION
1503 * all definitions from include/rpc_secdes.h
1509 /**size of the data returned*/
1512 /**Security descriptor*/
1513 SEC_DESC
*descriptor
;
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
{
1530 /**Handle to key to query*/
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
1544 * - ALL_SECURITY_INFORMATION
1546 * all definitions from include/rpc_secdes.h
1550 /**size of the descriptor*/
1553 /**Security descriptor*/
1554 SEC_DESC
*descriptor
;
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*/
1572 /**the message to display (can be NULL)*/
1575 /**timeout in seconds*/
1578 /**False = shutdown, True = reboot*/
1584 /*FIXME: make this useful*/
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
);
1613 /**@addtogroup SAM_Functions
1618 /**Access mask to open with
1619 * see generic access masks in include/smb.h*/
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
);
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
{
1653 /**The desired access. See generic access masks - include/smb.h*/
1656 /**(Optional) An open handle to the SAM. If it is NULL, the function will connect to the SAM with the access mask above*/
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 */
1665 /**handle to the open domain*/
1666 POLICY_HND
*dom_hnd
;
1668 /**Handle to the open SAM*/
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
{
1685 /**Open domain handle*/
1686 POLICY_HND
*dom_hnd
;
1691 /**See Allowable account control bits in include/smb.h*/
1696 /**handle to the user*/
1697 POLICY_HND
*user_hnd
;
1699 /**rid of the user*/
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
{
1717 /**Handle to open SAM connection*/
1718 POLICY_HND
*dom_hnd
;
1720 /**desired access - see generic access masks in include/smb.h*/
1723 /**RID of the user*/
1726 /**(Optional) name of the user - must supply either RID or user name*/
1731 /**Handle to the user*/
1732 POLICY_HND
*user_hnd
;
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
);
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
{
1759 /**Open handle to a domain*/
1760 POLICY_HND
*dom_hnd
;
1762 /**Enumerate users with specific ACB. If 0, all users will be enumerated*/
1767 /**where to resume from. Used over multiple calls*/
1770 /**the number of users returned this call*/
1773 /**Array storing the rids of the returned users*/
1776 /**Array storing the names of all the users returned*/
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
{
1795 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1796 POLICY_HND
*dom_hnd
;
1798 /**Number of RIDs to resolve*/
1801 /**Array of RIDs to resolve*/
1806 /**the number of names returned - if this is 0, the map is NULL*/
1809 /**array contiaing the Names and RIDs*/
1810 CacLookupRidsRecord
*map
;
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
{
1826 /**An open handle to the domain SAM from cac_SamOpenDomain()*/
1827 POLICY_HND
*dom_hnd
;
1829 /**Number of names to resolve*/
1832 /**Array of names to resolve*/
1837 /**the number of names returned - if this is 0, then map is NULL*/
1840 /**array contiaing the Names and RIDs*/
1841 CacLookupRidsRecord
*map
;
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
{
1857 /**An open handle to the user*/
1858 POLICY_HND
*user_hnd
;
1862 /**The number of groups the user is a member of*/
1865 /**The RIDs of the groups*/
1868 /**The attributes of the groups*/
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
{
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*/
1890 /**rid of the group*/
1895 /**Handle to the group*/
1896 POLICY_HND
*group_hnd
;
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
{
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*/
1918 /**The name of the group*/
1923 /**Handle to the group*/
1924 POLICY_HND
*group_hnd
;
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
);
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
{
1950 /**Open handle to a group*/
1951 POLICY_HND
*group_hnd
;
1955 /**The number of members in the group*/
1958 /**An array storing the RIDs of the users*/
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
{
1978 /**Open handle to a group*/
1979 POLICY_HND
*group_hnd
;
1981 /**RID of new member*/
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
{
1998 /**Open handle to a group*/
1999 POLICY_HND
*group_hnd
;
2001 /**RID of member to remove*/
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
{
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*/
2034 /**The RIDs of the users to add*/
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
{
2051 /**Open handle to a domain*/
2052 POLICY_HND
*dom_hnd
;
2056 /**Where to resume from _do not_ modify this value. Used over multiple calls.*/
2059 /**the number of users returned this call*/
2062 /**Array storing the rids of the returned groups*/
2065 /**Array storing the names of all the groups returned*/
2068 /**Array storing the descriptions of all the groups returned*/
2069 char **descriptions
;
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
{
2087 /**Open handle to a domain*/
2088 POLICY_HND
*dom_hnd
;
2092 /**where to resume from. Used over multiple calls*/
2095 /**the number of users returned this call*/
2098 /**Array storing the rids of the returned groups*/
2101 /**Array storing the names of all the groups returned*/
2104 /**Array storing the descriptions of all the groups returned*/
2105 char **descriptions
;
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
{
2123 /**Open handle to the domain SAM*/
2124 POLICY_HND
*dom_hnd
;
2126 /**The name of the alias*/
2131 /**Handle to the group*/
2132 POLICY_HND
*alias_hnd
;
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
{
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*/
2155 /**rid of the alias*/
2160 /**Handle to the alias*/
2161 POLICY_HND
*alias_hnd
;
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
);
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
{
2187 /**Open handle to a alias*/
2188 POLICY_HND
*alias_hnd
;
2190 /**SID of new member*/
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
{
2207 /**Open handle to the alias*/
2208 POLICY_HND
*alias_hnd
;
2210 /**The SID of the member*/
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
{
2227 /**Open handle to the alias*/
2228 POLICY_HND
*alias_hnd
;
2232 /**The number of members*/
2235 /**An array storing the SIDs of the accounts*/
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
{
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*/
2269 /**The SIDs of the accounts to add*/
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
{
2290 /**The current password*/
2293 /**The new password*/
2297 /**Used by a user to change their password*/
2298 int cac_SamUserChangePasswd(CacServerHandle
*hnd
, TALLOC_CTX
*mem_ctx
, struct SamUserChangePasswd
*op
);
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
);
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
{
2322 /**Open handle to a user*/
2323 POLICY_HND
*user_hnd
;
2325 /**The new password*/
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
{
2343 /**Open Handle to a user*/
2344 POLICY_HND
*user_hnd
;
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
{
2365 /**Open handle to a user*/
2366 POLICY_HND
*user_hnd
;
2368 /**Structure containing the data you would like to set*/
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
{
2388 /**Open handle to a user*/
2389 POLICY_HND
*user_hnd
;
2391 /**What USER_INFO structure you want. See include/rpc_samr.h*/
2396 /**returned user info*/
2397 SAM_USERINFO_CTR
*ctr
;
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
{
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
;
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
{
2436 /**Open handle to user*/
2437 POLICY_HND
*user_hnd
;
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
{
2456 /**Open handle to a group*/
2457 POLICY_HND
*group_hnd
;
2461 /**Returned info about the group*/
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
{
2478 /**Open handle to a group*/
2479 POLICY_HND
*group_hnd
;
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
{
2498 /**Open handle to a group*/
2499 POLICY_HND
*group_hnd
;
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
{
2519 /**Open handle to an alias*/
2520 POLICY_HND
*alias_hnd
;
2524 /**Returned alias info*/
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
{
2541 /**Open handle to an alias*/
2542 POLICY_HND
*alias_hnd
;
2544 /**Returned alias info*/
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
{
2561 /**Open handle to the domain SAM*/
2562 POLICY_HND
*dom_hnd
;
2566 /**Returned domain info*/
2567 CacDomainInfo
*info
;
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
{
2586 /**Open handle to domain*/
2587 POLICY_HND
*dom_hnd
;
2589 /**What info level you want*/
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
{
2611 /**Open handle to domain*/
2612 POLICY_HND
*dom_hnd
;
2614 /**What type of data*/
2617 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2620 /**(Optional)If 0, max_entries and max_size will be filled in by the function*/
2625 /**Do not modify this value, use the same value between multiple calls (ie in while loop)*/
2628 /**Number of entries returned*/
2631 /**Returned display info*/
2632 SAM_DISPINFO_CTR ctr
;
2634 /**Internal value. Do not modify.*/
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
{
2653 /**Open handle to the sam (opened with cac_SamConnect() or cac_SamOpenDomain()*/
2656 /**Name of the domain to lookup*/
2661 /**SID of the domain*/
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
{
2678 /**An open handle (SAM, domain or user)*/
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
);
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*/
2705 /**(Optional)Desired access to re-open the domain with. If 0, MAXIMUM_ALLOWED_ACCESS is used.*/
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
2729 /**Desired access to open the Handle with. See SC_RIGHT_MGR_* or SC_MANAGER_* in include/rpc_secdes.h*/
2734 /**Handle to the SCM*/
2735 POLICY_HND
*scm_hnd
;
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
{
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.
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.
2781 /**Number of services returned*/
2782 uint32 num_services
;
2784 /**Array of service structures*/
2785 CacService
*services
;
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
{
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*/
2807 /**The name of the service. _not_ the display name*/
2812 /**Handle to the open service*/
2813 POLICY_HND
*svc_hnd
;
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
{
2830 /**Open handle to the service to query*/
2831 POLICY_HND
*svc_hnd
;
2835 /**The status of the service. See include/rpc_svcctl.h for SERVICE_STATUS definition.*/
2836 SERVICE_STATUS status
;
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
{
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*/
2858 /**Number of parameters in the parms array*/
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*/
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
{
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
2892 /**The returned status of the service, _immediately_ after the call*/
2893 SERVICE_STATUS
*status
;
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
{
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
2923 /**Status of the service after the operation*/
2924 SERVICE_STATUS status
;
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
{
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
2951 /**Status of the service after the operation*/
2952 SERVICE_STATUS status
;
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
{
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
2979 /**Status of the service after the operation*/
2980 SERVICE_STATUS status
;
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
{
2997 /**Open handle to the service*/
2998 POLICY_HND
*svc_hnd
;
3002 /**The returned display name of the service*/
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
{
3019 /**Open handle to the service*/
3020 POLICY_HND
*svc_hnd
;
3024 /**Returned Configuration information*/
3025 CacServiceConfig config
;
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 */