📄 libmsrpc.h
字号:
*/ char *password; /** name or IP address of server we are currently working with */ char *server; /**stores the latest NTSTATUS code */ NTSTATUS status; /** internal. do not modify! */ struct CacServerHandleInternal _internal;} CacServerHandle;/*@}*//**internal function. do not call this function*/SMBCSRV *cac_GetServer(CacServerHandle *hnd);/** @addtogroup Library_Functions * @{ *//** * Initializes the library - do not need to call this function. Open's smb.conf as well as initializes logging. * @param debug Debug level for library to use */void cac_Init(int debug);/** * Creates an un-initialized CacServerHandle * @param allocate_fields If True, the function will allocate sizeof(fstring) bytes for all char * fields in the handle * @return - un-initialized server handle * - NULL if no memory could be allocated */CacServerHandle * cac_NewServerHandle(BOOL allocate_fields);/** * Specifies the smbc_get_auth_data_fn to use if you do not want to use the default. * @param hnd non-NULL server handle * @param auth_fn auth_data_fn to set in server handle */void cac_SetAuthDataFn(CacServerHandle *hnd, smbc_get_auth_data_fn auth_fn);/** Use your own libsmbclient context - not necessary. * @note You must still call cac_Connect() after specifying your own libsmbclient context * @param hnd Initialized, but not connected CacServerHandle * @param ctx The libsmbclient context you would like to use. */void cac_SetSmbcContext(CacServerHandle *hnd, SMBCCTX *ctx);/** Connects to a specified server. If there is already a connection to a different server, * it will be cleaned up before connecting to the new server. * @param hnd Pre-initialized CacServerHandle * @param srv (Optional) Name or IP of the server to connect to. If NULL, server from the CacServerHandle will be used. * * @return CAC_FAILURE if the operation could not be completed successfully (hnd->status will also be set with a NTSTATUS code) * @return CAC_SUCCESS if the operation succeeded */ int cac_Connect(CacServerHandle *hnd, const char *srv);/** * Cleans up any data used by the CacServerHandle. If the libsmbclient context was set using cac_SetSmbcContext(), it will not be free'd. * @param hnd the CacServerHandle to destroy */void cac_FreeHandle(CacServerHandle * hnd);/** * Initializes a CacTime structure based on an NTTIME structure * If the function fails, then the CacTime structure will be zero'd out */void cac_InitCacTime(CacTime *cactime, NTTIME nttime);/** * 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 * @param hnd Uninitialized server handle * @return CAC_FAILURE Memory could not be allocated * @return CAC_SUCCESS Memory was allocated */int cac_InitHandleMem(CacServerHandle *hnd);/** * Default smbc_get_auth_data_fn for libmsrpc. This function is called when libmsrpc needs to get more information about the * client (username/password, workgroup). * 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. * @see cac_SetAuthDataFn() * @param pServer Name/IP of the server to connect to. * @param pShare Share name to connect to * @param pWorkgroup libmsrpc passes in the workgroup/domain name from hnd->domain. It can be modified in the function. * @param maxLenWorkgroup The maximum length of a string pWogroup can hold. * @param pUsername libmsrpc passes in the username from hnd->username. It can be modified in the function. * @param maxLenUsername The maximum length of a string pUsername can hold. * @param pPassword libmsrpc pass in the password from hnd->password. It can be modified in the function. * @param maxLenPassword The maximum length of a string pPassword can hold. */void cac_GetAuthDataFn(const char * pServer, const char * pShare, char * pWorkgroup, int maxLenWorkgroup, char * pUsername, int maxLenUsername, char * pPassword, int maxLenPassword);/**@}*//***************** * LSA Functions * *****************//** @addtogroup LSA_Functions * @{ */struct LsaOpenPolicy { /**Inputs*/ struct { /**Access Mask. Refer to Security Access Masks in include/rpc_secdes.h*/ uint32 access; /**Use security quality of service? (True/False)*/ BOOL security_qos; } in; /**Outputs*/ struct { /**Handle to the open policy (needed for all other operations)*/ POLICY_HND *pol; } out;};/** * Opens a policy handle on a remote machine. * @param hnd fully initialized CacServerHandle for remote machine * @param mem_ctx Talloc context for memory allocation * @param op Initialized parameters * @return CAC_FAILURE if the policy could not be opened. hnd->status set with appropriate NTSTATUS * @return CAC_SUCCESS if the policy could be opened, the policy handle can be found */int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op);/** * Closes an LSA policy handle (Retrieved using cac_LsaOpenPolicy). * If successful, the handle will be closed on the server, and memory for pol will be freed * @param hnd - An initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param pol - the policy handle to close * @return CAC_FAILURE could not close the policy handle, hnd->status is set to the appropriate NTSTATUS error code * @return CAC_SUCCESS the policy handle was closed */int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *pol);struct LsaGetNamesFromSids { struct { /**handle to and open LSA policy*/ POLICY_HND *pol; /**the number of SIDs to lookup*/ uint32 num_sids; /**array of SIDs to lookup*/ DOM_SID *sids; } in; struct { /**The number of names returned (in case of CAC_PARTIAL_SUCCESS)*/ uint32 num_found; /**array of SID info each index is one sid */ CacSidInfo *sids; /**in case of partial success, an array of SIDs that could not be looked up (NULL if all sids were looked up)*/ DOM_SID *unknown; } out;};/** * Looks up the names for a list of SIDS * @param hnd initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op input and output parameters * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output * @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 */int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetNamesFromSids *op);struct LsaGetSidsFromNames { struct { /**handle to an open LSA policy*/ POLICY_HND *pol; /**number of SIDs to lookup*/ uint32 num_names; /**array of strings listing the names*/ char **names; } in; struct { /**The number of SIDs returned (in case of partial success*/ uint32 num_found; /**array of SID info for the looked up names*/ CacSidInfo *sids; /**in case of partial success, the names that were not looked up*/ char **unknown; } out;};/** * Looks up the SIDs for a list of names * @param hnd initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op input and output parameters * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output * @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 */int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSidsFromNames *op);struct LsaFetchSid { struct { /**handle to an open LSA policy*/ POLICY_HND *pol; /**can be CAC_LOCAL_INFO, CAC_DOMAIN_INFO, or (CAC_LOCAL_INFO | CAC_DOMAIN_INFO)*/ uint16 info_class; } in; struct { /**the machine's local SID and domain name (NULL if not asked for)*/ CacSidInfo *local_sid; /**the machine's domain SID and name (NULL if not asked for)*/ CacSidInfo *domain_sid; } out;};/** * Looks up the domain or local sid of a machine with an open LSA policy handle * @param hnd initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op input and output parameters * @return CAC_FAILURE if the SID could not be fetched * @return CAC_SUCCESS if the SID was fetched * @return CAC_PARTIAL_SUCCESS if you asked for both local and domain sids but only one was returned */int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSid *op);struct LsaQueryInfoPolicy { struct { /**Open LSA policy handle on remote server*/ POLICY_HND *pol; } in; struct { /**remote server's domain name*/ char *domain_name; /**remote server's dns name*/ char *dns_name; /**remote server's forest name*/ char *forest_name; /**remote server's domain guid*/ struct uuid *domain_guid; /**remote server's domain SID*/ DOM_SID *domain_sid; } out;};/** * Retrieves information about the LSA machine/domain * @param hnd initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op input and output parameters * Note: for pre-Windows 2000 machines, only op->out.SID and op->out.domain will be set. @see cac_LsaFetchSid * @return - CAC_FAILURE if the operation was not successful. hnd->status will be set with an accurate NT_STATUS code * @return CAC_SUCCESS the operation was successful. */int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryInfoPolicy *op);struct LsaEnumSids { struct { /**Open LSA Policy handle*/ POLICY_HND *pol; /**The prefered maximum number of SIDs returned per call*/ uint32 pref_max_sids; } in; struct { /**used to keep track of how many sids have been retrieved over multiple calls * should be set to zero via ZERO_STRUCT() befrore the first call. Use the same struct LsaEnumSids for multiple calls*/ uint32 resume_idx; /**The number of sids returned this call*/ uint32 num_sids; /**Array of sids returned*/ DOM_SID *sids; } out;};/** * Enumerates the SIDs in the LSA. Can be enumerated in blocks by calling the function multiple times. * Example: while(cac_LsaEnumSids(hnd, mem_ctx, op) { ... } * @param hnd - An initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op Initialized parameters * @return CAC_FAILURE there was an error during operations OR there are no more results * @return CAC_SUCCESS the operation completed and results were returned */int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSids *op);struct LsaEnumAccountRights { struct { /**Open LSA Policy handle*/ POLICY_HND *pol; /**(Optional) SID of the account - must supply either sid or name*/ DOM_SID *sid; /**(Optional) name of the account - must supply either sid or name*/ char *name; } in; struct { /**Count of rights for this account*/ uint32 num_privs; /**array of privilege names*/ char **priv_names; } out;};/** * Enumerates rights assigned to a given account. Takes a SID instead of account handle as input * @param hnd Initialized and connected server handle * @param mem_ctx Context for memory allocation * @param op Initialized Parameters * @return CAC_FAILURE the rights could not be retrieved. hnd->status is set with NT_STATUS code * @return CAC_SUCCESS the operation was successful. */int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumAccountRights *op);struct LsaEnumTrustedDomains { struct { /**Open LSA policy handle*/ POLICY_HND *pol; } in; struct { /**used to keep track of how many domains have been retrieved over multiple calls * should be set to zero via ZERO_STRUCT() before the first call. Use the same struct LsaEnumSids for multiple calls*/ uint32 resume_idx; /**The number of domains returned by the remote server this call*/ uint32 num_domains; /**array of trusted domain names returned by the remote server*/ char **domain_names; /**array of trusted domain sids returned by the remote server*/ DOM_SID *domain_sids; } out;}; /** * Enumerates the trusted domains in the LSA. * @param hnd - An initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op - initialized parameters * @return CAC_FAILURE there was an error during operations OR there are no more results * @return CAC_SUCCESS the operation completed and results were returned */int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumTrustedDomains *op);struct LsaOpenTrustedDomain { struct { /**an open LSA policy handle*/ POLICY_HND *pol; /**SID of the trusted domain to open*/ DOM_SID *domain_sid; /**Desired access on the open domain*/ uint32 access; } in; struct { /**A handle to the policy that is opened*/ POLICY_HND *domain_pol; } out;};/** * Opens a trusted domain by SID. * @param hnd An initialized and connected server handle * @param mem_ctx Talloc context for memory allocation * @param op initialized I/O parameters * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code * @return CAC_SUCCESS the domain was opened successfully */int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenTrustedDomain *op);struct LsaQueryTrustedDomainInfo { struct { /**Open LSA policy handle*/ POLICY_HND *pol; /**Info class of returned data*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -