char **auth_method_list = NULL;
NTSTATUS nt_status;
- if (lp_auth_methods() && !str_list_copy(&auth_method_list, lp_auth_methods())) {
+ if (lp_auth_methods()
+ && !str_list_copy(talloc_tos(), &auth_method_list,
+ lp_auth_methods())) {
return NT_STATUS_NO_MEMORY;
}
{
case SEC_DOMAIN:
DEBUG(5,("Making default auth method list for security=domain\n"));
- auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest sam winbind:ntdomain",
+ NULL);
break;
case SEC_SERVER:
DEBUG(5,("Making default auth method list for security=server\n"));
- auth_method_list = str_list_make("guest sam smbserver", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest sam smbserver",
+ NULL);
break;
case SEC_USER:
if (lp_encrypted_passwords()) {
if ((lp_server_role() == ROLE_DOMAIN_PDC) || (lp_server_role() == ROLE_DOMAIN_BDC)) {
DEBUG(5,("Making default auth method list for DC, security=user, encrypt passwords = yes\n"));
- auth_method_list = str_list_make("guest sam winbind:trustdomain", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(),
+ "guest sam winbind:trustdomain",
+ NULL);
} else {
DEBUG(5,("Making default auth method list for standalone security=user, encrypt passwords = yes\n"));
- auth_method_list = str_list_make("guest sam", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest sam",
+ NULL);
}
} else {
DEBUG(5,("Making default auth method list for security=user, encrypt passwords = no\n"));
- auth_method_list = str_list_make("guest unix", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest unix", NULL);
}
break;
case SEC_SHARE:
if (lp_encrypted_passwords()) {
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = yes\n"));
- auth_method_list = str_list_make("guest sam", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest sam", NULL);
} else {
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = no\n"));
- auth_method_list = str_list_make("guest unix", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest unix", NULL);
}
break;
case SEC_ADS:
DEBUG(5,("Making default auth method list for security=ADS\n"));
- auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL);
+ auth_method_list = str_list_make(
+ talloc_tos(), "guest sam winbind:ntdomain",
+ NULL);
break;
default:
DEBUG(5,("Unknown auth method!\n"));
DEBUG(5,("Using specified auth order\n"));
}
- if (!NT_STATUS_IS_OK(nt_status = make_auth_context_text_list(auth_context, auth_method_list))) {
- str_list_free(&auth_method_list);
- return nt_status;
- }
-
- str_list_free(&auth_method_list);
+ nt_status = make_auth_context_text_list(auth_context,
+ auth_method_list);
+
+ TALLOC_FREE(auth_method_list);
return nt_status;
}
}
/****************************************************************************
- Do a specific test for a struct samu being vaild for this connection
+ Do a specific test for a struct samu being valid for this connection
(ie not disabled, expired and the like).
****************************************************************************/
session keepalives and then drop them here.
*/
if (FD_ISSET(cli->fd,&fds)) {
- if (receive_smb_raw(cli->fd,cli->inbuf,0,0,&cli->smb_rw_error) == -1) {
- DEBUG(0, ("Read from server failed, maybe it closed the "
- "connection\n"));
+ NTSTATUS status;
+ size_t len;
+
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
+
+ status = receive_smb_raw(cli->fd, cli->inbuf, 0, 0, &len);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Read from server failed, maybe it closed "
+ "the connection\n"));
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
+ set_smb_read_error(&cli->smb_rw_error,
+ SMB_READ_EOF);
+ return;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ set_smb_read_error(&cli->smb_rw_error,
+ SMB_READ_TIMEOUT);
+ return;
+ }
+
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR);
return;
}
if(CVAL(cli->inbuf,0) != SMBkeepalive) {
AC_CHECK_HEADERS(sys/syslog.h syslog.h)
AC_CHECK_HEADERS(langinfo.h locale.h)
AC_CHECK_HEADERS(xfs/libxfs.h)
+AC_CHECK_HEADERS(netgroup.h)
AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
#if HAVE_RPC_RPC_H
}\
dyn_##name = SMB_STRDUP(newpath);\
return dyn_##name;\
+}\
+\
+ bool is_default_dyn_##name(void) \
+{\
+ return (dyn_##name == NULL);\
}
DEFINE_DYN_CONFIG_PARAM(SBINDIR)
const char *get_dyn_SBINDIR(void);
const char *set_dyn_SBINDIR(const char *newpath);
+bool is_default_dyn_SBINDIR(void);
const char *get_dyn_BINDIR(void);
const char *set_dyn_BINDIR(const char *newpath);
+bool is_default_dyn_BINDIR(void);
const char *get_dyn_SWATDIR(void);
const char *set_dyn_SWATDIR(const char *newpath);
+bool is_default_dyn_SWATDIR(void);
const char *get_dyn_CONFIGFILE(void);
const char *set_dyn_CONFIGFILE(const char *newpath);
+bool is_default_dyn_CONFIGFILE(void);
-const char *get_dyn_dyn_LOGFILEBASE(void);
-const char *set_dyn_dyn_LOGFILEBASE(const char *newpath);
+const char *get_dyn_LOGFILEBASE(void);
+const char *set_dyn_LOGFILEBASE(const char *newpath);
+bool is_default_dyn_LOGFILEBASE(void);
const char *get_dyn_LMHOSTSFILE(void);
const char *set_dyn_LMHOSTSFILE(const char *newpath);
+bool is_default_dyn_LOGFILEBASE(void);
const char *get_dyn_CODEPAGEDIR(void);
const char *set_dyn_CODEPAGEDIR(const char *newpath);
+bool is_default_dyn_CODEPAGEDIR(void);
const char *get_dyn_LIBDIR(void);
const char *set_dyn_LIBDIR(const char *newpath);
+bool is_default_dyn_LIBDIR(void);
const char *get_dyn_SHLIBEXT(void);
const char *set_dyn_SHLIBEXT(const char *newpath);
+bool is_default_dyn_SHLIBEXT(void);
const char *get_dyn_LOCKDIR(void);
const char *set_dyn_LOCKDIR(const char *newpath);
+bool is_default_dyn_LOCKDIR(void);
const char *get_dyn_PIDDIR(void);
const char *set_dyn_PIDDIR(const char *newpath);
+bool is_default_dyn_PIDDIR(void);
const char *get_dyn_SMB_PASSWD_FILE(void);
const char *set_dyn_SMB_PASSWD_FILE(const char *newpath);
+bool is_default_dyn_SMB_PASSWD_FILE(void);
const char *get_dyn_PRIVATE_DIR(void);
const char *set_dyn_PRIVATE_DIR(const char *newpath);
+bool is_default_dyn_PRIVATE_DIR(void);
const char *get_dyn_STATEDIR(void);
+const char *set_dyn_STATEDIR(const char *newpath);
+bool is_default_dyn_STATEDIR(void);
+
const char *get_dyn_CACHEDIR(void);
+const char *set_dyn_CACHEDIR(const char *newpath);
+bool is_default_dyn_CACHEDIR(bool);
#include <langinfo.h>
#endif
+#if HAVE_NETGROUP_H
+#include <netgroup.h>
+#endif
+
#if defined(HAVE_AIO_H) && defined(WITH_AIO)
#include <aio.h>
#endif
#define EVENTLOG_DATABASE_VERSION_V1 1
-/***********************************/
-
-typedef struct {
- uint16 unknown1;
- uint16 unknown2;
-} EVENTLOG_OPEN_UNKNOWN0;
-
-typedef struct {
- EVENTLOG_OPEN_UNKNOWN0 *unknown0;
- UNISTR4 logname;
- UNISTR4 servername;
- uint32 unknown1;
- uint32 unknown2;
-} EVENTLOG_Q_OPEN_EVENTLOG;
-
-typedef struct {
- POLICY_HND handle;
- NTSTATUS status;
-} EVENTLOG_R_OPEN_EVENTLOG;
-
-
-/***********************************/
-
-typedef struct {
- POLICY_HND handle;
-} EVENTLOG_Q_GET_NUM_RECORDS;
-
-typedef struct {
- uint32 num_records;
- NTSTATUS status;
-} EVENTLOG_R_GET_NUM_RECORDS;
-
-
-/***********************************/
-
-typedef struct {
- POLICY_HND handle;
-} EVENTLOG_Q_GET_OLDEST_ENTRY;
-
-typedef struct {
- uint32 oldest_entry;
- NTSTATUS status;
-} EVENTLOG_R_GET_OLDEST_ENTRY;
-
-
/***********************************/
typedef struct
NTSTATUS status;
} EVENTLOG_R_READ_EVENTLOG;
-
-/***********************************/
-
-typedef struct {
- POLICY_HND handle;
- UNISTR4 backupfile;
-} EVENTLOG_Q_CLEAR_EVENTLOG;
-
-typedef struct {
- NTSTATUS status;
-} EVENTLOG_R_CLEAR_EVENTLOG;
-
#endif /* _RPC_EVENTLOG_H */
POLICY_VIEW_LOCAL_INFORMATION |\
POLICY_LOOKUP_NAMES )
-/* LSA_Q_QUERY_SEC_OBJ - LSA query security */
-typedef struct lsa_query_sec_obj_info
-{
- POLICY_HND pol; /* policy handle */
- uint32 sec_info;
-
-} LSA_Q_QUERY_SEC_OBJ;
-
-/* LSA_R_QUERY_SEC_OBJ - probably an open */
-typedef struct r_lsa_query_sec_obj_info
-{
- uint32 ptr;
- SEC_DESC_BUF *buf;
-
- NTSTATUS status; /* return status */
-
-} LSA_R_QUERY_SEC_OBJ;
-
/* LSA_Q_QUERY_INFO - LSA query info policy */
typedef struct lsa_query_info
{
NTSTATUS status;
} LSA_R_REMOVEPRIVS;
-/*******************************************************/
-
-typedef struct {
- POLICY_HND handle;
-} LSA_Q_DELETE_OBJECT;
-
-typedef struct {
- NTSTATUS status;
-} LSA_R_DELETE_OBJECT;
-
#endif /* _RPC_LSA_H */
} SAM_USER_INFO_9;
-/****************************************************************************
-SAMR_Q_GET_USRDOM_PWINFO - a "set user info" occurs just after this
-*****************************************************************************/
-
-/* SAMR_Q_GET_USRDOM_PWINFO */
-typedef struct q_samr_usrdom_pwinfo_info
-{
- POLICY_HND user_pol; /* policy handle */
-
-} SAMR_Q_GET_USRDOM_PWINFO;
-
-
-/****************************************************************************
-SAMR_R_GET_USRDOM_PWINFO - a "set user info" occurs just after this
-*****************************************************************************/
-
-/* SAMR_R_GET_USRDOM_PWINFO */
-typedef struct r_samr_usrdom_pwinfo_info
-{
- uint16 min_pwd_length;
- uint16 unknown_1; /* 0x0016 or 0x0015 */
- uint32 password_properties;
- NTSTATUS status;
-
-} SAMR_R_GET_USRDOM_PWINFO;
-
-/****************************************************************************
-SAMR_Q_SET_SEC_OBJ - info level 4.
-*****************************************************************************/
-
-/* SAMR_Q_SET_SEC_OBJ - */
-typedef struct q_samr_set_sec_obj_info
-{
- POLICY_HND pol; /* policy handle */
- uint32 sec_info; /* xxxx_SECURITY_INFORMATION 0x0000 0004 */
- SEC_DESC_BUF *buf;
-
-} SAMR_Q_SET_SEC_OBJ;
-
-/* SAMR_R_SET_SEC_OBJ - */
-typedef struct r_samr_set_sec_obj_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_SET_SEC_OBJ;
-
-
-/****************************************************************************
-SAMR_Q_QUERY_SEC_OBJ - info level 4. returns SIDs.
-*****************************************************************************/
-
-/* SAMR_Q_QUERY_SEC_OBJ - probably get domain info... */
-typedef struct q_samr_query_sec_obj_info
-{
- POLICY_HND user_pol; /* policy handle */
- uint32 sec_info; /* xxxx_SECURITY_INFORMATION 0x0000 0004 */
-
-} SAMR_Q_QUERY_SEC_OBJ;
-
-/* SAMR_R_QUERY_SEC_OBJ - probably an open */
-typedef struct r_samr_query_sec_obj_info
-{
- uint32 ptr;
- SEC_DESC_BUF *buf;
-
- NTSTATUS status; /* return status */
-
-} SAMR_R_QUERY_SEC_OBJ;
-
-
-/****************************************************************************
-SAMR_Q_QUERY_DOMAIN_INFO - probably a query on domain group info.
-*****************************************************************************/
-
-/* SAMR_Q_QUERY_DOMAIN_INFO - */
-typedef struct q_samr_query_domain_info
-{
- POLICY_HND domain_pol; /* policy handle */
- uint16 switch_value; /* 0x0002, 0x0001 */
-
-} SAMR_Q_QUERY_DOMAIN_INFO;
-
typedef struct sam_unknown_info_1_inf
{
uint16 min_length_password;
} SAM_UNK_INFO_1;
-typedef struct sam_unknown_info_2_inf
-{
- NTTIME logout; /* whether users are forcibly disconnected when logon hours expire */
- UNIHDR hdr_comment; /* comment according to samba4 idl */
- UNIHDR hdr_domain; /* domain name unicode header */
- UNIHDR hdr_server; /* server name unicode header */
-
- /* put all the data in here, at the moment, including what the above
- pointer is referring to
- */
-
- uint64 seq_num;
-
- uint32 unknown_4; /* 0x0000 0001 */
- uint32 server_role;
- uint32 unknown_6; /* 0x0000 0001 */
- uint32 num_domain_usrs; /* number of users in domain */
- uint32 num_domain_grps; /* number of domain groups in domain */
- uint32 num_local_grps; /* number of local groups in domain */
-
- UNISTR2 uni_comment; /* comment unicode string */
- UNISTR2 uni_domain; /* domain name unicode string */
- UNISTR2 uni_server; /* server name unicode string */
-
-} SAM_UNK_INFO_2;
-
typedef struct sam_unknown_info_3_info
{
NTTIME logout;
} SAM_UNK_INFO_3;
-typedef struct sam_unknown_info_4_inf
-{
- UNIHDR hdr_comment; /* comment according to samba4 idl */
- UNISTR2 uni_comment; /* comment unicode string */
-
-} SAM_UNK_INFO_4;
-
-typedef struct sam_unknown_info_5_inf
-{
- UNIHDR hdr_domain; /* domain name unicode header */
- UNISTR2 uni_domain; /* domain name unicode string */
-
-} SAM_UNK_INFO_5;
-
-typedef struct sam_unknown_info_6_info
-{
- UNIHDR hdr_server; /* server name unicode header */
- UNISTR2 uni_server; /* server name unicode string */
-
-} SAM_UNK_INFO_6;
-
-typedef struct sam_unknown_info_7_info
-{
- uint16 server_role;
-
-} SAM_UNK_INFO_7;
-
-typedef struct sam_unknown_info_8_info
-{
- uint64 seq_num;
- NTTIME domain_create_time;
-
-} SAM_UNK_INFO_8;
-
-typedef struct sam_unknown_info_9_info
-{
- uint32 unknown;
-
-} SAM_UNK_INFO_9;
-
-typedef struct sam_unknown_info_12_inf
-{
- NTTIME duration;
- NTTIME reset_count;
- uint16 bad_attempt_lockout;
-
-} SAM_UNK_INFO_12;
-
-typedef struct sam_unknown_info_13_info
-{
- uint64 seq_num;
- NTTIME domain_create_time;
- uint32 unknown1;
- uint32 unknown2;
-
-} SAM_UNK_INFO_13;
-
-typedef struct sam_unknown_ctr_info
-{
- union
- {
- SAM_UNK_INFO_1 inf1;
- SAM_UNK_INFO_2 inf2;
- SAM_UNK_INFO_3 inf3;
- SAM_UNK_INFO_4 inf4;
- SAM_UNK_INFO_5 inf5;
- SAM_UNK_INFO_6 inf6;
- SAM_UNK_INFO_7 inf7;
- SAM_UNK_INFO_8 inf8;
- SAM_UNK_INFO_9 inf9;
- SAM_UNK_INFO_12 inf12;
- SAM_UNK_INFO_13 inf13;
-
- } info;
-
-} SAM_UNK_CTR;
-
-
-/* SAMR_R_QUERY_DOMAIN_INFO - */
-typedef struct r_samr_query_domain_info
-{
- uint32 ptr_0;
- uint16 switch_value; /* same as in query */
-
- SAM_UNK_CTR *ctr;
-
- NTSTATUS status; /* return status */
-
-} SAMR_R_QUERY_DOMAIN_INFO;
-
-
-/* SAMR_Q_LOOKUP_DOMAIN - obtain SID for a local domain */
-typedef struct q_samr_lookup_domain_info
-{
- POLICY_HND connect_pol;
-
- UNIHDR hdr_domain;
- UNISTR2 uni_domain;
-
-} SAMR_Q_LOOKUP_DOMAIN;
-
-
-/* SAMR_R_LOOKUP_DOMAIN */
-typedef struct r_samr_lookup_domain_info
-{
- uint32 ptr_sid;
- DOM_SID2 dom_sid;
-
- NTSTATUS status;
-
-} SAMR_R_LOOKUP_DOMAIN;
-
-
-/****************************************************************************
-SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
-
-0x0000 03f1 and a specific domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
-0x0000 0200 and a specific domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
-*****************************************************************************/
-
-/* SAMR_Q_OPEN_DOMAIN */
-typedef struct q_samr_open_domain_info
-{
- POLICY_HND pol; /* policy handle */
- uint32 flags; /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
- DOM_SID2 dom_sid; /* domain SID */
-
-} SAMR_Q_OPEN_DOMAIN;
-
-
-/* SAMR_R_OPEN_DOMAIN - probably an open */
-typedef struct r_samr_open_domain_info
-{
- POLICY_HND domain_pol; /* policy handle associated with the SID */
- NTSTATUS status; /* return status */
-
-} SAMR_R_OPEN_DOMAIN;
-
#define MAX_SAM_ENTRIES_W2K 0x400
#define MAX_SAM_ENTRIES_W95 50
/* The following should be the greater of the preceeding two. */
} SAMR_R_GET_DISPENUM_INDEX;
-/* SAMR_Q_DELETE_DOM_GROUP - delete domain group */
-typedef struct q_samr_delete_dom_group_info
-{
- POLICY_HND group_pol; /* policy handle */
-
-} SAMR_Q_DELETE_DOM_GROUP;
-
-
-/* SAMR_R_DELETE_DOM_GROUP - delete domain group */
-typedef struct r_samr_delete_dom_group_info
-{
- POLICY_HND pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_DELETE_DOM_GROUP;
-
-
-/* SAMR_Q_CREATE_DOM_GROUP - SAM create group */
-typedef struct q_samr_create_dom_group_info
-{
- POLICY_HND pol; /* policy handle */
-
- UNIHDR hdr_acct_desc;
- UNISTR2 uni_acct_desc;
-
- uint32 access_mask;
-
-} SAMR_Q_CREATE_DOM_GROUP;
-
-/* SAMR_R_CREATE_DOM_GROUP - SAM create group */
-typedef struct r_samr_create_dom_group_info
-{
- POLICY_HND pol; /* policy handle */
-
- uint32 rid;
- NTSTATUS status;
-
-} SAMR_R_CREATE_DOM_GROUP;
-
/* SAMR_Q_QUERY_GROUPINFO - SAM Group Info */
typedef struct q_samr_query_group_info
{
} SAMR_R_SET_GROUPINFO;
-/* SAMR_Q_DELETE_DOM_ALIAS - delete domain alias */
-typedef struct q_samr_delete_dom_alias_info
-{
- POLICY_HND alias_pol; /* policy handle */
-
-} SAMR_Q_DELETE_DOM_ALIAS;
-
-
-/* SAMR_R_DELETE_DOM_ALIAS - delete domain alias */
-typedef struct r_samr_delete_dom_alias_info
-{
- POLICY_HND pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_DELETE_DOM_ALIAS;
-
-
-/* SAMR_Q_CREATE_DOM_ALIAS - SAM create alias */
-typedef struct q_samr_create_dom_alias_info
-{
- POLICY_HND dom_pol; /* policy handle */
-
- UNIHDR hdr_acct_desc;
- UNISTR2 uni_acct_desc;
-
- uint32 access_mask; /* 0x001f000f */
-
-} SAMR_Q_CREATE_DOM_ALIAS;
-
-/* SAMR_R_CREATE_DOM_ALIAS - SAM create alias */
-typedef struct r_samr_create_dom_alias_info
-{
- POLICY_HND alias_pol; /* policy handle */
-
- uint32 rid;
- NTSTATUS status;
-
-} SAMR_R_CREATE_DOM_ALIAS;
-
-
/********************************************************/
typedef struct {
} SAMR_R_QUERY_USERINFO;
-/****************************************************************************
-SAMR_Q_QUERY_USERALIASES - do a conversion from name to RID.
-
-the policy handle allocated by an "samr open secret" call is associated
-with a SID. this policy handle is what is queried here, *not* the SID
-itself. the response to the lookup rids is relative to this SID.
-*****************************************************************************/
-/* SAMR_Q_QUERY_USERALIASES */
-typedef struct q_samr_query_useraliases_info
-{
- POLICY_HND pol; /* policy handle */
-
- uint32 num_sids1; /* number of rids being looked up */
- uint32 ptr; /* buffer pointer */
- uint32 num_sids2; /* number of rids being looked up */
-
- uint32 *ptr_sid; /* pointers to sids to be looked up */
- DOM_SID2 *sid ; /* sids to be looked up. */
-
-} SAMR_Q_QUERY_USERALIASES;
-
-
-/* SAMR_R_QUERY_USERALIASES */
-typedef struct r_samr_query_useraliases_info
-{
- uint32 num_entries;
- uint32 ptr; /* undocumented buffer pointer */
-
- uint32 num_entries2;
- uint32 *rid; /* domain RIDs being looked up */
-
- NTSTATUS status; /* return code */
-
-} SAMR_R_QUERY_USERALIASES;
-
-
/****************************************************************************
SAMR_Q_LOOKUP_NAMES - do a conversion from Names to RIDs+types.
*****************************************************************************/
} SAMR_R_LOOKUP_RIDS;
-/* SAMR_Q_OPEN_USER - probably an open */
-typedef struct q_samr_open_user_info
-{
- POLICY_HND domain_pol; /* policy handle */
- uint32 access_mask; /* 32 bit unknown - 0x02011b */
- uint32 user_rid; /* user RID */
-
-} SAMR_Q_OPEN_USER;
-
-
-/* SAMR_R_OPEN_USER - probably an open */
-typedef struct r_samr_open_user_info
-{
- POLICY_HND user_pol; /* policy handle associated with unknown id */
- NTSTATUS status; /* return status */
-
-} SAMR_R_OPEN_USER;
-
-
-/* SAMR_Q_CREATE_USER - probably a create */
-typedef struct q_samr_create_user_info
-{
- POLICY_HND domain_pol; /* policy handle */
-
- UNIHDR hdr_name; /* unicode account name header */
- UNISTR2 uni_name; /* unicode account name */
-
- uint32 acb_info; /* account control info */
- uint32 acct_flags; /* 0xe005 00b0 */
-
-} SAMR_Q_CREATE_USER;
-
-
-/* SAMR_R_CREATE_USER - probably a create */
-typedef struct r_samr_create_user_info
-{
- POLICY_HND user_pol; /* policy handle associated with user */
-
- uint32 access_granted;
- uint32 user_rid; /* user RID */
- NTSTATUS status; /* return status */
-
-} SAMR_R_CREATE_USER;
-
-
-/* SAMR_Q_DELETE_DOM_USER - delete domain user */
-typedef struct q_samr_delete_dom_user_info
-{
- POLICY_HND user_pol; /* policy handle */
-
-} SAMR_Q_DELETE_DOM_USER;
-
-
-/* SAMR_R_DELETE_DOM_USER - delete domain user */
-typedef struct r_samr_delete_dom_user_info
-{
- POLICY_HND pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_DELETE_DOM_USER;
-
-
-/* SAMR_Q_QUERY_GROUPMEM - query group members */
-typedef struct q_samr_query_groupmem_info
-{
- POLICY_HND group_pol; /* policy handle */
-
-} SAMR_Q_QUERY_GROUPMEM;
-
-
-/* SAMR_R_QUERY_GROUPMEM - query group members */
-typedef struct r_samr_query_groupmem_info
-{
- uint32 ptr;
- uint32 num_entries;
-
- uint32 ptr_rids;
- uint32 ptr_attrs;
-
- uint32 num_rids;
- uint32 *rid;
-
- uint32 num_attrs;
- uint32 *attr;
-
- NTSTATUS status;
-
-} SAMR_R_QUERY_GROUPMEM;
-
-
-/* SAMR_Q_DEL_GROUPMEM - probably an del group member */
-typedef struct q_samr_del_group_mem_info
-{
- POLICY_HND pol; /* policy handle */
- uint32 rid; /* rid */
-
-} SAMR_Q_DEL_GROUPMEM;
-
-
-/* SAMR_R_DEL_GROUPMEM - probably an del group member */
-typedef struct r_samr_del_group_mem_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_DEL_GROUPMEM;
-
-
-/* SAMR_Q_ADD_GROUPMEM - probably an add group member */
-typedef struct q_samr_add_group_mem_info
-{
- POLICY_HND pol; /* policy handle */
-
- uint32 rid; /* rid */
- uint32 unknown; /* 0x0000 0005 */
-
-} SAMR_Q_ADD_GROUPMEM;
-
-
-/* SAMR_R_ADD_GROUPMEM - probably an add group member */
-typedef struct r_samr_add_group_mem_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_ADD_GROUPMEM;
-
-
-/* SAMR_Q_OPEN_GROUP - probably an open */
-typedef struct q_samr_open_group_info
-{
- POLICY_HND domain_pol; /* policy handle */
- uint32 access_mask; /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
- uint32 rid_group; /* rid */
-
-} SAMR_Q_OPEN_GROUP;
-
-
-/* SAMR_R_OPEN_GROUP - probably an open */
-typedef struct r_samr_open_group_info
-{
- POLICY_HND pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_OPEN_GROUP;
-
-
-/* SAMR_Q_QUERY_ALIASMEM - query alias members */
-typedef struct q_samr_query_aliasmem_info
-{
- POLICY_HND alias_pol; /* policy handle */
-
-} SAMR_Q_QUERY_ALIASMEM;
-
-
-/* SAMR_R_QUERY_ALIASMEM - query alias members */
-typedef struct r_samr_query_aliasmem_info
-{
- uint32 num_sids;
- uint32 ptr;
- uint32 num_sids1;
-
- DOM_SID2 *sid;
-
- NTSTATUS status;
-
-} SAMR_R_QUERY_ALIASMEM;
-
-
-/* SAMR_Q_ADD_ALIASMEM - add alias member */
-typedef struct q_samr_add_alias_mem_info
-{
- POLICY_HND alias_pol; /* policy handle */
-
- DOM_SID2 sid; /* member sid to be added to the alias */
-
-} SAMR_Q_ADD_ALIASMEM;
-
-
-/* SAMR_R_ADD_ALIASMEM - add alias member */
-typedef struct r_samr_add_alias_mem_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_ADD_ALIASMEM;
-
-
-/* SAMR_Q_DEL_ALIASMEM - add an add alias member */
-typedef struct q_samr_del_alias_mem_info
-{
- POLICY_HND alias_pol; /* policy handle */
-
- DOM_SID2 sid; /* member sid to be added to alias */
-
-} SAMR_Q_DEL_ALIASMEM;
-
-
-/* SAMR_R_DEL_ALIASMEM - delete alias member */
-typedef struct r_samr_del_alias_mem_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_DEL_ALIASMEM;
-
-
-
-/* SAMR_Q_OPEN_ALIAS - probably an open */
-typedef struct q_samr_open_alias_info
-{
- POLICY_HND dom_pol;
-
- uint32 access_mask;
- uint32 rid_alias;
-
-} SAMR_Q_OPEN_ALIAS;
-
-
-/* SAMR_R_OPEN_ALIAS - probably an open */
-typedef struct r_samr_open_alias_info
-{
- POLICY_HND pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_OPEN_ALIAS;
-
-
-/* SAMR_Q_CONNECT_ANON - probably an open */
-typedef struct q_samr_connect_anon_info {
- uint32 ptr; /* ptr? */
- uint16 unknown_0; /* Only pushed if ptr is non-zero. */
- uint32 access_mask;
-} SAMR_Q_CONNECT_ANON;
-
-/* SAMR_R_CONNECT_ANON - probably an open */
-typedef struct r_samr_connect_anon_info
-{
- POLICY_HND connect_pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_CONNECT_ANON;
-
-/* SAMR_Q_CONNECT - probably an open */
-typedef struct q_samr_connect_info
-{
- uint32 ptr_srv_name; /* pointer (to server name?) */
- UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
-
- uint32 access_mask;
-
-} SAMR_Q_CONNECT;
-
-
-/* SAMR_R_CONNECT - probably an open */
-typedef struct r_samr_connect_info
-{
- POLICY_HND connect_pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_CONNECT;
-
-/* SAMR_Q_CONNECT4 */
-typedef struct q_samr_connect4_info
-{
- uint32 ptr_srv_name; /* pointer to server name */
- UNISTR2 uni_srv_name;
-
- uint32 unk_0; /* possible server name type, 1 for IP num, 2 for name */
- uint32 access_mask;
-} SAMR_Q_CONNECT4;
-
-/* SAMR_R_CONNECT4 - same format as connect */
-typedef struct r_samr_connect_info SAMR_R_CONNECT4;
-
-/* SAMR_Q_CONNECT5 */
-typedef struct q_samr_connect5_info
-{
- uint32 ptr_srv_name; /* pointer to server name */
- UNISTR2 uni_srv_name;
- uint32 access_mask;
- uint32 level;
- /* These following are acutally a level dependent
- value. Fudge it for now. JRA */
- uint32 info1_unk1;
- uint32 info1_unk2;
-} SAMR_Q_CONNECT5;
-
-/* SAMR_R_CONNECT5 */
-typedef struct r_samr_connect_info5
-{
- uint32 level;
- uint32 info1_unk1;
- uint32 info1_unk2;
- POLICY_HND connect_pol; /* policy handle */
- NTSTATUS status; /* return status */
-
-} SAMR_R_CONNECT5;
-
-
/* SAMR_ENC_PASSWD */
typedef struct enc_passwd_info
{
} SAMR_R_CHGPASSWD_USER3;
-
-/* SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN */
-typedef struct q_samr_remove_sid_foreign_domain_info
-{
- POLICY_HND dom_pol; /* policy handle */
- DOM_SID2 sid; /* SID */
-
-} SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN;
-
-
-/* SAMR_R_REMOVE_SID_FOREIGN_DOMAIN */
-typedef struct r_samr_remove_sid_foreign_domain_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_REMOVE_SID_FOREIGN_DOMAIN;
-
-
-
/* these are from the old rpc_samr.h - they are needed while the merge
is still going on */
#define MAX_SAM_SIDS 15
} DOM_SID3;
-/* SAMR_Q_QUERY_DOMAIN_INFO2 */
-typedef struct q_samr_query_domain_info2
-{
- POLICY_HND domain_pol; /* policy handle */
- uint16 switch_value;
-
-} SAMR_Q_QUERY_DOMAIN_INFO2;
-
-/* SAMR_R_QUERY_DOMAIN_INFO2 */
-typedef struct r_samr_query_domain_info2
-{
- uint32 ptr_0;
- uint16 switch_value;
- SAM_UNK_CTR *ctr;
- NTSTATUS status; /* return status */
-
-} SAMR_R_QUERY_DOMAIN_INFO2;
-
-/* SAMR_Q_SET_DOMAIN_INFO */
-typedef struct q_samr_set_domain_info
-{
- POLICY_HND domain_pol; /* policy handle */
- uint16 switch_value0;
- uint16 switch_value;
- SAM_UNK_CTR *ctr;
-
-} SAMR_Q_SET_DOMAIN_INFO;
-
-/* SAMR_R_SET_DOMAIN_INFO */
-typedef struct r_samr_set_domain_info
-{
- NTSTATUS status; /* return status */
-
-} SAMR_R_SET_DOMAIN_INFO;
-
#endif /* _RPC_SAMR_H */
size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void *dst, bool allow_bad_conv)
{
- size_t i_len, o_len, destlen = MAX(srclen, 512);
+ size_t i_len, o_len, destlen = (srclen * 3) / 2;
size_t retval;
const char *inbuf = (const char *)src;
char *outbuf = NULL, *ob = NULL;
convert:
- if ((destlen*2) < destlen) {
+ /* +2 is for ucs2 null termination. */
+ if ((destlen*2)+2 < destlen) {
/* wrapped ! abort. */
if (!conv_silent)
DEBUG(0, ("convert_string_allocate: destlen wrapped !\n"));
destlen = destlen * 2;
}
+ /* +2 is for ucs2 null termination. */
if (ctx) {
- ob = (char *)TALLOC_REALLOC(ctx, ob, destlen);
+ ob = (char *)TALLOC_REALLOC(ctx, ob, destlen + 2);
} else {
- ob = (char *)SMB_REALLOC(ob, destlen);
+ ob = (char *)SMB_REALLOC(ob, destlen + 2);
}
if (!ob) {
* reallocs *cost*. JRA.
*/
if (o_len > 1024) {
+ /* We're shrinking here so we know the +2 is safe from wrap. */
if (ctx) {
- ob = (char *)TALLOC_REALLOC(ctx,ob,destlen);
+ ob = (char *)TALLOC_REALLOC(ctx,ob,destlen + 2);
} else {
- ob = (char *)SMB_REALLOC(ob,destlen);
+ ob = (char *)SMB_REALLOC(ob,destlen + 2);
}
}
}
*dest = ob;
+
+ /* Must ucs2 null terminate in the extra space we allocated. */
+ ob[destlen] = '\0';
+ ob[destlen+1] = '\0';
+
return destlen;
use_as_is:
struct db_tdb_ctx *ctx = talloc_get_type_abort(rec->private_data,
struct db_tdb_ctx);
- return (tdb_delete(ctx->wtdb->tdb, rec->key) == 0) ?
- NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+ if (tdb_delete(ctx->wtdb->tdb, rec->key) == 0) {
+ return NT_STATUS_OK;
+ }
+
+ if (tdb_error(ctx->wtdb->tdb) == TDB_ERR_NOEXIST) {
+ return NT_STATUS_NOT_FOUND;
+ }
+
+ return NT_STATUS_UNSUCCESSFUL;
}
struct db_tdb_traverse_ctx {
if (AllowDebugChange == False)
return True;
- params = str_list_make(params_str, NULL);
+ params = str_list_make(talloc_tos(), params_str, NULL);
if (debug_parse_params(params)) {
debug_dump_status(5);
- str_list_free(¶ms);
+ TALLOC_FREE(params);
return True;
} else {
- str_list_free(¶ms);
+ TALLOC_FREE(params);
return False;
}
}
}
if (reason == POPT_CALLBACK_REASON_POST) {
- if (!PrintSambaVersionString) return;
- printf( "Version %s\n", SAMBA_VERSION_STRING);
- exit(0);
+ if (PrintSambaVersionString) {
+ printf( "Version %s\n", SAMBA_VERSION_STRING);
+ exit(0);
+ }
+
+ if (is_default_dyn_CONFIGFILE()) {
+ if(getenv("SMB_CONF_PATH")) {
+ set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH"));
+ }
+ }
+
+ /* Further 'every Samba program must do this' hooks here. */
return;
}
*linux*)
LIB_PATH_VAR=LD_LIBRARY_PATH
;;
+ *netbsd*)
+ LIB_PATH_VAR=LD_LIBRARY_PATH
+ ;;
*solaris*)
LIB_PATH_VAR=LD_LIBRARY_PATH
;;
#endif
#ifndef AI_ADDRCONFIG
+/*
+ * logic copied from AI_NUMERICHOST
+ */
+#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
+#define AI_ADDRCONFIG 0
+#else
#define AI_ADDRCONFIG 0x0020
#endif
+#endif
#ifndef AI_NUMERICSERV
/*
&hints,
ppres);
if (ret) {
- DEBUG(3,("interpret_string_addr_interal: getaddrinfo failed "
+ DEBUG(3,("interpret_string_addr_internal: getaddrinfo failed "
"for name %s [%s]\n",
str,
gai_strerror(ret) ));
time_out = timeout in milliseconds
****************************************************************************/
-ssize_t read_socket_with_timeout(int fd,
- char *buf,
- size_t mincnt,
- size_t maxcnt,
- unsigned int time_out,
- enum smb_read_errors *pre)
+NTSTATUS read_socket_with_timeout(int fd, char *buf,
+ size_t mincnt, size_t maxcnt,
+ unsigned int time_out,
+ size_t *size_ret)
{
fd_set fds;
int selrtn;
/* just checking .... */
if (maxcnt <= 0)
- return(0);
-
- set_smb_read_error(pre,SMB_READ_OK);
+ return NT_STATUS_OK;
/* Blocking read */
if (time_out == 0) {
if (readret == 0) {
DEBUG(5,("read_socket_with_timeout: "
"blocking read. EOF from client.\n"));
- set_smb_read_error(pre,SMB_READ_EOF);
- return -1;
+ return NT_STATUS_END_OF_FILE;
}
if (readret == -1) {
"read error = %s.\n",
strerror(errno) ));
}
- set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
+ return map_nt_error_from_unix(errno);
}
nread += readret;
}
- return((ssize_t)nread);
+ goto done;
}
/* Most difficult - timeout read */
"read. select error = %s.\n",
strerror(errno) ));
}
- set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
+ return map_nt_error_from_unix(errno);
}
/* Did we timeout ? */
if (selrtn == 0) {
DEBUG(10,("read_socket_with_timeout: timeout read. "
"select timed out.\n"));
- set_smb_read_error(pre,SMB_READ_TIMEOUT);
- return -1;
+ return NT_STATUS_IO_TIMEOUT;
}
readret = sys_read(fd, buf+nread, maxcnt-nread);
/* we got EOF on the file descriptor */
DEBUG(5,("read_socket_with_timeout: timeout read. "
"EOF from client.\n"));
- set_smb_read_error(pre,SMB_READ_EOF);
- return -1;
+ return NT_STATUS_END_OF_FILE;
}
if (readret == -1) {
"read. read error = %s.\n",
strerror(errno) ));
}
- set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
+ return map_nt_error_from_unix(errno);
}
nread += readret;
}
+ done:
/* Return the number we got */
- return (ssize_t)nread;
+ if (size_ret) {
+ *size_ret = nread;
+ }
+ return NT_STATUS_OK;
}
/****************************************************************************
Read data from the client, reading exactly N bytes.
****************************************************************************/
-ssize_t read_data(int fd,char *buffer,size_t N, enum smb_read_errors *pre)
+NTSTATUS read_data(int fd, char *buffer, size_t N)
{
- return read_socket_with_timeout(fd, buffer, N, N, 0, pre);
+ return read_socket_with_timeout(fd, buffer, N, N, 0, NULL);
}
/****************************************************************************
Timeout is in milliseconds.
****************************************************************************/
-ssize_t read_smb_length_return_keepalive(int fd,
- char *inbuf,
- unsigned int timeout,
- enum smb_read_errors *pre)
+NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
+ unsigned int timeout,
+ size_t *len)
{
- ssize_t len=0;
int msg_type;
+ NTSTATUS status;
- if (read_socket_with_timeout(fd, inbuf, 4, 4, timeout, pre) != 4) {
- return -1;
+ status = read_socket_with_timeout(fd, inbuf, 4, 4, timeout, NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- len = smb_len(inbuf);
+ *len = smb_len(inbuf);
msg_type = CVAL(inbuf,0);
if (msg_type == SMBkeepalive) {
DEBUG(5,("Got keepalive packet\n"));
}
- DEBUG(10,("got smb length of %lu\n",(unsigned long)len));
+ DEBUG(10,("got smb length of %lu\n",(unsigned long)(*len)));
- return len;
+ return NT_STATUS_OK;
}
/****************************************************************************
Timeout is in milliseconds.
****************************************************************************/
-ssize_t read_smb_length(int fd, char *inbuf, unsigned int timeout, enum smb_read_errors *pre)
+NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
+ size_t *len)
{
- ssize_t len;
uint8_t msgtype = SMBkeepalive;
while (msgtype == SMBkeepalive) {
- len = read_smb_length_return_keepalive(fd, inbuf, timeout,
- pre);
- if (len < 0) {
- return len;
+ NTSTATUS status;
+
+ status = read_smb_length_return_keepalive(fd, inbuf, timeout,
+ len);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
+
msgtype = CVAL(inbuf, 0);
}
DEBUG(10,("read_smb_length: got smb length of %lu\n",
(unsigned long)len));
- return len;
+ return NT_STATUS_OK;
}
/****************************************************************************
Doesn't check the MAC on signed packets.
****************************************************************************/
-ssize_t receive_smb_raw(int fd,
- char *buffer,
- unsigned int timeout,
- size_t maxlen,
- enum smb_read_errors *pre)
+NTSTATUS receive_smb_raw(int fd, char *buffer, unsigned int timeout,
+ size_t maxlen, size_t *p_len)
{
- ssize_t len,ret;
-
- set_smb_read_error(pre,SMB_READ_OK);
-
- len = read_smb_length_return_keepalive(fd,buffer,timeout,pre);
- if (len < 0) {
- DEBUG(10,("receive_smb_raw: length < 0!\n"));
+ size_t len;
+ NTSTATUS status;
- /*
- * Correct fix. smb_read_error may have already been
- * set. Only set it here if not already set. Global
- * variables still suck :-). JRA.
- */
+ status = read_smb_length_return_keepalive(fd,buffer,timeout,&len);
- cond_set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("receive_smb_raw: %s!\n", nt_errstr(status)));
+ return status;
}
/*
DEBUG(0,("Invalid packet length! (%lu bytes).\n",
(unsigned long)len));
if (len > BUFFER_SIZE + (SAFETY_MARGIN/2)) {
-
- /*
- * Correct fix. smb_read_error may have already been
- * set. Only set it here if not already set. Global
- * variables still suck :-). JRA.
- */
-
- cond_set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
+ return NT_STATUS_INVALID_PARAMETER;
}
}
len = MIN(len,maxlen);
}
- ret = read_socket_with_timeout(fd, buffer+4, len, len, timeout,
- pre);
+ status = read_socket_with_timeout(
+ fd, buffer+4, len, len, timeout, &len);
- if (ret != len) {
- cond_set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
/* not all of samba3 properly checks for packet-termination
SSVAL(buffer+4,len, 0);
}
- return len;
+ *p_len = len;
+ return NT_STATUS_OK;
}
/****************************************************************************
#define S_LIST_ABS 16 /* List Allocation Block Size */
-static char **str_list_make_internal(TALLOC_CTX *mem_ctx,
- const char *string,
- const char *sep)
+char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
{
- char **list, **rlist;
+ char **list;
const char *str;
char *s;
int num, lsize;
char *tok;
- TALLOC_CTX *frame = NULL;
if (!string || !*string)
return NULL;
- if (mem_ctx) {
- s = talloc_strdup(mem_ctx, string);
- } else {
- s = SMB_STRDUP(string);
+
+ list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1);
+ if (list == NULL) {
+ return NULL;
}
- if (!s) {
+ lsize = S_LIST_ABS;
+
+ s = talloc_strdup(list, string);
+ if (s == NULL) {
DEBUG(0,("str_list_make: Unable to allocate memory"));
+ TALLOC_FREE(list);
return NULL;
}
if (!sep) sep = LIST_SEP;
- num = lsize = 0;
- list = NULL;
-
+ num = 0;
str = s;
- frame = talloc_stackframe();
- while (next_token_talloc(frame, &str, &tok, sep)) {
+
+ while (next_token_talloc(list, &str, &tok, sep)) {
+
if (num == lsize) {
+ char **tmp;
+
lsize += S_LIST_ABS;
- if (mem_ctx) {
- rlist = TALLOC_REALLOC_ARRAY(mem_ctx, list,
- char *, lsize +1);
- } else {
- /* We need to keep the old list on
- * error so we can free the elements
- if the realloc fails. */
- rlist =SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(list,
- char *, lsize +1);
- }
- if (!rlist) {
+
+ tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *,
+ lsize + 1);
+ if (tmp == NULL) {
DEBUG(0,("str_list_make: "
"Unable to allocate memory"));
- str_list_free(&list);
- if (mem_ctx) {
- TALLOC_FREE(s);
- } else {
- SAFE_FREE(s);
- }
- TALLOC_FREE(frame);
+ TALLOC_FREE(list);
return NULL;
- } else {
- list = rlist;
}
- memset (&list[num], 0,
- ((sizeof(char**)) * (S_LIST_ABS +1)));
- }
- if (mem_ctx) {
- list[num] = talloc_strdup(mem_ctx, tok);
- } else {
- list[num] = SMB_STRDUP(tok);
- }
+ list = tmp;
- if (!list[num]) {
- DEBUG(0,("str_list_make: Unable to allocate memory"));
- str_list_free(&list);
- if (mem_ctx) {
- TALLOC_FREE(s);
- } else {
- SAFE_FREE(s);
- }
- TALLOC_FREE(frame);
- return NULL;
+ memset (&list[num], 0,
+ ((sizeof(char**)) * (S_LIST_ABS +1)));
}
- num++;
+ list[num] = tok;
+ num += 1;
}
- TALLOC_FREE(frame);
-
- if (mem_ctx) {
- TALLOC_FREE(s);
- } else {
- SAFE_FREE(s);
- }
+ list[num] = NULL;
+ TALLOC_FREE(s);
return list;
}
-char **str_list_make_talloc(TALLOC_CTX *mem_ctx,
- const char *string,
- const char *sep)
-{
- return str_list_make_internal(mem_ctx, string, sep);
-}
-
-char **str_list_make(const char *string, const char *sep)
-{
- return str_list_make_internal(NULL, string, sep);
-}
-
-bool str_list_copy(char ***dest, const char **src)
+bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src)
{
- char **list, **rlist;
- int num, lsize;
+ char **list;
+ int i, num;
*dest = NULL;
if (!src)
return false;
- num = lsize = 0;
- list = NULL;
+ num = 0;
+ while (src[num] != NULL) {
+ num += 1;
+ }
- while (src[num]) {
- if (num == lsize) {
- lsize += S_LIST_ABS;
- rlist = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(list,
- char *, lsize +1);
- if (!rlist) {
- DEBUG(0,("str_list_copy: "
- "Unable to re-allocate memory"));
- str_list_free(&list);
- return false;
- } else {
- list = rlist;
- }
- memset (&list[num], 0,
- ((sizeof(char **)) * (S_LIST_ABS +1)));
- }
+ list = TALLOC_ARRAY(mem_ctx, char *, num+1);
+ if (list == NULL) {
+ return false;
+ }
- list[num] = SMB_STRDUP(src[num]);
- if (!list[num]) {
- DEBUG(0,("str_list_copy: Unable to allocate memory"));
- str_list_free(&list);
+ for (i=0; i<num; i++) {
+ list[i] = talloc_strdup(list, src[i]);
+ if (list[i] == NULL) {
+ TALLOC_FREE(list);
return false;
}
-
- num++;
}
-
+ list[i] = NULL;
*dest = list;
return true;
}
return true;
}
-static void str_list_free_internal(TALLOC_CTX *mem_ctx, char ***list)
-{
- char **tlist;
-
- if (!list || !*list)
- return;
- tlist = *list;
- for(; *tlist; tlist++) {
- if (mem_ctx) {
- TALLOC_FREE(*tlist);
- } else {
- SAFE_FREE(*tlist);
- }
- }
- if (mem_ctx) {
- TALLOC_FREE(*tlist);
- } else {
- SAFE_FREE(*list);
- }
-}
-
-void str_list_free_talloc(TALLOC_CTX *mem_ctx, char ***list)
-{
- str_list_free_internal(mem_ctx, list);
-}
-
-void str_list_free(char ***list)
-{
- str_list_free_internal(NULL, list);
-}
-
/******************************************************************************
*****************************************************************************/
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(&search_attrs, attrs))) {
+ if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) {
rc = LDAP_NO_MEMORY;
goto done;
}
}
/* if/when we decide to utf8-encode attrs, take out this next line */
- str_list_free(&search_attrs);
+ TALLOC_FREE(search_attrs);
return ADS_ERROR(rc);
}
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(&search_attrs, attrs)))
+ if (!(str_list_copy(talloc_tos(), &search_attrs, attrs)))
{
DEBUG(1,("ads_do_search: str_list_copy() failed!"));
rc = LDAP_NO_MEMORY;
done:
talloc_destroy(ctx);
/* if/when we decide to utf8-encode attrs, take out this next line */
- str_list_free(&search_attrs);
+ TALLOC_FREE(search_attrs);
return ADS_ERROR(rc);
}
/**
goto parse_error;
}
- ext_list = str_list_make_talloc(mem_ctx, extension_raw, "]");
+ ext_list = str_list_make(mem_ctx, extension_raw, "]");
if (!ext_list) {
goto parse_error;
}
p++;
}
- ext_strings = str_list_make_talloc(mem_ctx, p, "}");
+ ext_strings = str_list_make(mem_ctx, p, "}");
if (ext_strings == NULL) {
goto parse_error;
}
ret = True;
parse_error:
- if (ext_list) {
- str_list_free_talloc(mem_ctx, &ext_list);
- }
- if (ext_strings) {
- str_list_free_talloc(mem_ctx, &ext_strings);
- }
+ TALLOC_FREE(ext_list);
+ TALLOC_FREE(ext_strings);
return ret;
}
DEBUG(10,("gpo_parse_gplink: gPLink: %s\n", gp_link_raw));
- link_list = str_list_make_talloc(mem_ctx, gp_link_raw, "]");
+ link_list = str_list_make(mem_ctx, gp_link_raw, "]");
if (!link_list) {
goto parse_error;
}
status = ADS_SUCCESS;
parse_error:
-
- if (link_list) {
- str_list_free_talloc(mem_ctx, &link_list);
- }
+ TALLOC_FREE(link_list);
return status;
}
#define LIBNET_UNJOIN_OUT_DUMP_CTX(ctx, r) \
LIBNET_UNJOIN_DUMP_CTX(ctx, r, NDR_OUT)
+static void init_lsa_String(struct lsa_String *name, const char *s)
+{
+ name->string = s;
+}
+
/****************************************************************
****************************************************************/
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
char *acct_name;
const char *const_acct_name;
+ struct lsa_String lsa_acct_name;
uint32 user_rid;
uint32 num_rids, *name_types, *user_rids;
uint32 flags = 0x3e8;
goto done;
}
- status = rpccli_samr_connect(pipe_hnd, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED, &sam_pol);
+ status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &sam_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- status = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &sam_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- r->out.domain_sid,
- &domain_pol);
+ status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &sam_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ r->out.domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
strlower_m(acct_name);
const_acct_name = acct_name;
+ init_lsa_String(&lsa_acct_name, acct_name);
+
if (r->in.join_flags & WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE) {
uint32_t acct_flags =
SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
SAMR_USER_ACCESS_SET_PASSWORD |
SAMR_USER_ACCESS_GET_ATTRIBUTES |
SAMR_USER_ACCESS_SET_ATTRIBUTES;
-
- status = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx,
- &domain_pol,
- acct_name, ACB_WSTRUST,
- acct_flags, &user_pol,
- &user_rid);
+ uint32_t access_granted = 0;
+
+ status = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &lsa_acct_name,
+ ACB_WSTRUST,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
if (!(r->in.join_flags &
WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED)) {
user_rid = user_rids[0];
- status = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED, user_rid,
- &user_pol);
+ status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
goto done;
}
- status = rpccli_samr_connect(pipe_hnd, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED, &sam_pol);
+ status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &sam_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- status = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &sam_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- r->in.domain_sid,
- &domain_pol);
+ status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &sam_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ r->in.domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
user_rid = user_rids[0];
- status = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- user_rid, &user_pol);
+ status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
NTSTATUS rpccli_eventlog_ClearEventLogW(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
- struct lsa_String *unknown)
+ struct lsa_String *backupfile)
{
struct eventlog_ClearEventLogW r;
NTSTATUS status;
/* In parameters */
r.in.handle = handle;
- r.in.unknown = unknown;
+ r.in.backupfile = backupfile;
if (DEBUGLEVEL >= 10) {
NDR_PRINT_IN_DEBUG(eventlog_ClearEventLogW, &r);
}
NTSTATUS rpccli_eventlog_GetOldestRecord(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx)
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t *oldest_entry)
{
struct eventlog_GetOldestRecord r;
NTSTATUS status;
/* In parameters */
+ r.in.handle = handle;
if (DEBUGLEVEL >= 10) {
NDR_PRINT_IN_DEBUG(eventlog_GetOldestRecord, &r);
}
/* Return variables */
+ *oldest_entry = *r.out.oldest_entry;
/* Return result */
return r.out.result;
NTSTATUS rpccli_eventlog_OpenEventLogW(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct eventlog_OpenUnknown0 *unknown0,
- struct lsa_String logname,
- struct lsa_String servername,
+ struct lsa_String *logname,
+ struct lsa_String *servername,
uint32_t unknown2,
uint32_t unknown3,
struct policy_handle *handle)
NTSTATUS rpccli_eventlog_ClearEventLogW(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
- struct lsa_String *unknown);
+ struct lsa_String *backupfile);
NTSTATUS rpccli_eventlog_BackupEventLogW(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx);
NTSTATUS rpccli_eventlog_CloseEventLog(struct rpc_pipe_client *cli,
struct policy_handle *handle,
uint32_t *number);
NTSTATUS rpccli_eventlog_GetOldestRecord(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx);
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t *oldest_entry);
NTSTATUS rpccli_eventlog_ChangeNotify(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx);
NTSTATUS rpccli_eventlog_OpenEventLogW(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct eventlog_OpenUnknown0 *unknown0,
- struct lsa_String logname,
- struct lsa_String servername,
+ struct lsa_String *logname,
+ struct lsa_String *servername,
uint32_t unknown2,
uint32_t unknown3,
struct policy_handle *handle);
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
uint32_t sec_info,
- struct sec_desc_buf *sdbuf)
+ struct sec_desc_buf **sdbuf)
{
struct lsa_QuerySecurity r;
NTSTATUS status;
}
/* Return variables */
- if (sdbuf && r.out.sdbuf) {
- *sdbuf = *r.out.sdbuf;
- }
+ *sdbuf = *r.out.sdbuf;
/* Return result */
return r.out.result;
}
NTSTATUS rpccli_lsa_SetSecObj(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx)
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t sec_info,
+ struct sec_desc_buf *sdbuf)
{
struct lsa_SetSecObj r;
NTSTATUS status;
/* In parameters */
+ r.in.handle = handle;
+ r.in.sec_info = sec_info;
+ r.in.sdbuf = sdbuf;
if (DEBUGLEVEL >= 10) {
NDR_PRINT_IN_DEBUG(lsa_SetSecObj, &r);
}
NTSTATUS rpccli_lsa_DeleteObject(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx)
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle **handle)
{
struct lsa_DeleteObject r;
NTSTATUS status;
/* In parameters */
+ r.in.handle = handle;
if (DEBUGLEVEL >= 10) {
NDR_PRINT_IN_DEBUG(lsa_DeleteObject, &r);
}
/* Return variables */
+ *handle = *r.out.handle;
/* Return result */
return r.out.result;
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
uint32_t sec_info,
- struct sec_desc_buf *sdbuf);
+ struct sec_desc_buf **sdbuf);
NTSTATUS rpccli_lsa_SetSecObj(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx);
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t sec_info,
+ struct sec_desc_buf *sdbuf);
NTSTATUS rpccli_lsa_ChangePassword(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx);
NTSTATUS rpccli_lsa_OpenPolicy(struct rpc_pipe_client *cli,
uint16_t *language_id,
uint16_t unknown);
NTSTATUS rpccli_lsa_DeleteObject(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx);
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle **handle);
NTSTATUS rpccli_lsa_EnumAccountsWithUserRight(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
uint32_t sec_info,
- struct sec_desc_buf *sdbuf)
+ struct sec_desc_buf **sdbuf)
{
struct samr_QuerySecurity r;
NTSTATUS status;
TALLOC_CTX *mem_ctx,
struct policy_handle *connect_handle,
struct lsa_String *domain_name,
- struct dom_sid2 *sid)
+ struct dom_sid2 **sid)
{
struct samr_LookupDomain r;
NTSTATUS status;
TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
uint16_t level,
- union samr_DomainInfo *info)
+ union samr_DomainInfo **info)
{
struct samr_QueryDomainInfo r;
NTSTATUS status;
NTSTATUS rpccli_samr_QueryGroupMember(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *group_handle,
- struct samr_RidTypeArray *rids)
+ struct samr_RidTypeArray **rids)
{
struct samr_QueryGroupMember r;
NTSTATUS status;
TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
uint16_t level,
- union samr_DomainInfo *info)
+ union samr_DomainInfo **info)
{
struct samr_QueryDomainInfo2 r;
NTSTATUS status;
NTSTATUS rpccli_samr_Connect4(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
const char *system_name,
- uint32_t unknown,
+ enum samr_ConnectVersion client_version,
uint32_t access_mask,
struct policy_handle *connect_handle)
{
/* In parameters */
r.in.system_name = system_name;
- r.in.unknown = unknown;
+ r.in.client_version = client_version;
r.in.access_mask = access_mask;
if (DEBUGLEVEL >= 10) {
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
uint32_t sec_info,
- struct sec_desc_buf *sdbuf);
+ struct sec_desc_buf **sdbuf);
NTSTATUS rpccli_samr_Shutdown(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *connect_handle);
TALLOC_CTX *mem_ctx,
struct policy_handle *connect_handle,
struct lsa_String *domain_name,
- struct dom_sid2 *sid);
+ struct dom_sid2 **sid);
NTSTATUS rpccli_samr_EnumDomains(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *connect_handle,
TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
uint16_t level,
- union samr_DomainInfo *info);
+ union samr_DomainInfo **info);
NTSTATUS rpccli_samr_SetDomainInfo(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
NTSTATUS rpccli_samr_QueryGroupMember(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *group_handle,
- struct samr_RidTypeArray *rids);
+ struct samr_RidTypeArray **rids);
NTSTATUS rpccli_samr_SetMemberAttributesOfGroup(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *group_handle,
TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
uint16_t level,
- union samr_DomainInfo *info);
+ union samr_DomainInfo **info);
NTSTATUS rpccli_samr_QueryUserInfo2(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *user_handle,
NTSTATUS rpccli_samr_Connect4(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
const char *system_name,
- uint32_t unknown,
+ enum samr_ConnectVersion client_version,
uint32_t access_mask,
struct policy_handle *connect_handle);
NTSTATUS rpccli_samr_ChangePasswordUser3(struct rpc_pipe_client *cli,
struct eventlog_ClearEventLogW {
struct {
struct policy_handle *handle;/* [ref] */
- struct lsa_String *unknown;/* [unique] */
+ struct lsa_String *backupfile;/* [unique] */
} in;
struct {
struct eventlog_GetOldestRecord {
struct {
+ struct policy_handle *handle;/* [ref] */
+ } in;
+
+ struct {
+ uint32_t *oldest_entry;/* [ref] */
NTSTATUS result;
} out;
struct eventlog_OpenEventLogW {
struct {
struct eventlog_OpenUnknown0 *unknown0;/* [unique] */
- struct lsa_String logname;
- struct lsa_String servername;
+ struct lsa_String *logname;/* [ref] */
+ struct lsa_String *servername;/* [ref] */
uint32_t unknown2;
uint32_t unknown3;
} in;
struct policy_handle *handle;/* [ref] */
uint32_t flags;
uint32_t offset;
- uint32_t number_of_bytes;
+ uint32_t number_of_bytes;/* [range(0,0x7FFFF)] */
} in;
struct {
};
struct lsa_SidArray {
- uint32_t num_sids;/* [range(0 1000)] */
+ uint32_t num_sids;/* [range(0,1000)] */
struct lsa_SidPtr *sids;/* [unique,size_is(num_sids)] */
}/* [public] */;
};
struct lsa_TransSidArray {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
struct lsa_TranslatedSid *sids;/* [unique,size_is(count)] */
};
struct lsa_RefDomainList {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
struct lsa_DomainInfo *domains;/* [unique,size_is(count)] */
uint32_t max_size;
};
};
struct lsa_TransNameArray {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
struct lsa_TranslatedName *names;/* [unique,size_is(count)] */
};
};
struct lsa_PrivilegeSet {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
uint32_t unknown;
struct lsa_LUIDAttribute *set;/* [size_is(count)] */
};
}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */;
struct lsa_DATA_BUF2 {
- uint32_t size;/* [range(0 65536)] */
+ uint32_t size;/* [range(0,65536)] */
uint8_t *data;/* [unique,size_is(size)] */
}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */;
};
struct lsa_TransNameArray2 {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
struct lsa_TranslatedName2 *names;/* [unique,size_is(count)] */
};
};
struct lsa_TransSidArray2 {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
struct lsa_TranslatedSid2 *sids;/* [unique,size_is(count)] */
};
};
struct lsa_TransSidArray3 {
- uint32_t count;/* [range(0 1000)] */
+ uint32_t count;/* [range(0,1000)] */
struct lsa_TranslatedSid3 *sids;/* [unique,size_is(count)] */
};
struct lsa_ForestTrustBinaryData {
- uint32_t length;/* [range(0 131072)] */
+ uint32_t length;/* [range(0,131072)] */
uint8_t *data;/* [unique,size_is(length)] */
};
};
struct lsa_ForestTrustInformation {
- uint32_t count;/* [range(0 4000)] */
+ uint32_t count;/* [range(0,4000)] */
struct lsa_ForestTrustRecord **entries;/* [unique,size_is(count)] */
}/* [public] */;
} in;
struct {
- struct sec_desc_buf *sdbuf;/* [unique] */
+ struct sec_desc_buf **sdbuf;/* [ref] */
NTSTATUS result;
} out;
struct lsa_SetSecObj {
+ struct {
+ struct policy_handle *handle;/* [ref] */
+ uint32_t sec_info;
+ struct sec_desc_buf *sdbuf;/* [ref] */
+ } in;
+
struct {
NTSTATUS result;
} out;
struct lsa_EnumAccounts {
struct {
struct policy_handle *handle;/* [ref] */
- uint32_t num_entries;/* [range(0 8192)] */
+ uint32_t num_entries;/* [range(0,8192)] */
uint32_t *resume_handle;/* [ref] */
} in;
struct lsa_LookupNames {
struct {
struct policy_handle *handle;/* [ref] */
- uint32_t num_names;/* [range(0 1000)] */
+ uint32_t num_names;/* [range(0,1000)] */
struct lsa_String *names;/* [size_is(num_names)] */
enum lsa_LookupNamesLevel level;
struct lsa_TransSidArray *sids;/* [ref] */
struct lsa_DeleteObject {
struct {
+ struct policy_handle **handle;/* [ref] */
+ } in;
+
+ struct {
+ struct policy_handle **handle;/* [ref] */
NTSTATUS result;
} out;
struct lsa_LookupNames2 {
struct {
struct policy_handle *handle;/* [ref] */
- uint32_t num_names;/* [range(0 1000)] */
+ uint32_t num_names;/* [range(0,1000)] */
struct lsa_String *names;/* [size_is(num_names)] */
enum lsa_LookupNamesLevel level;
uint32_t unknown1;
struct lsa_LookupNames3 {
struct {
struct policy_handle *handle;/* [ref] */
- uint32_t num_names;/* [range(0 1000)] */
+ uint32_t num_names;/* [range(0,1000)] */
struct lsa_String *names;/* [size_is(num_names)] */
enum lsa_LookupNamesLevel level;
uint32_t unknown1;
struct lsa_LookupNames4 {
struct {
- uint32_t num_names;/* [range(0 1000)] */
+ uint32_t num_names;/* [range(0,1000)] */
struct lsa_String *names;/* [size_is(num_names)] */
enum lsa_LookupNamesLevel level;
uint32_t unknown1;
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->forest, CH_UTF16)));
NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->forest, ndr_charset_length(r->forest, CH_UTF16), sizeof(uint16_t), CH_UTF16));
}
- NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_guid));
}
return NDR_ERR_SUCCESS;
}
NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->forest, ndr_get_array_length(ndr, &r->forest), sizeof(uint16_t), CH_UTF16));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_forest_0, 0);
}
- NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_guid));
}
return NDR_ERR_SUCCESS;
}
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
NDR_PULL_ALLOC_N(ndr, r->strings, r->num_of_strings);
_mem_save_strings_0 = NDR_PULL_GET_MEM_CTX(ndr);
- NDR_PULL_SET_MEM_CTX(ndr, *r->strings, 0);
+ NDR_PULL_SET_MEM_CTX(ndr, r->strings, 0);
for (cntr_strings_0 = 0; cntr_strings_0 < r->num_of_strings; cntr_strings_0++) {
NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->strings[cntr_strings_0]));
}
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
- NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.unknown));
- if (r->in.unknown) {
- NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.unknown));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.backupfile));
+ if (r->in.backupfile) {
+ NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.backupfile));
}
}
if (flags & NDR_OUT) {
static enum ndr_err_code ndr_pull_eventlog_ClearEventLogW(struct ndr_pull *ndr, int flags, struct eventlog_ClearEventLogW *r)
{
- uint32_t _ptr_unknown;
+ uint32_t _ptr_backupfile;
TALLOC_CTX *_mem_save_handle_0;
- TALLOC_CTX *_mem_save_unknown_0;
+ TALLOC_CTX *_mem_save_backupfile_0;
if (flags & NDR_IN) {
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
NDR_PULL_ALLOC(ndr, r->in.handle);
NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
- NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_unknown));
- if (_ptr_unknown) {
- NDR_PULL_ALLOC(ndr, r->in.unknown);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_backupfile));
+ if (_ptr_backupfile) {
+ NDR_PULL_ALLOC(ndr, r->in.backupfile);
} else {
- r->in.unknown = NULL;
+ r->in.backupfile = NULL;
}
- if (r->in.unknown) {
- _mem_save_unknown_0 = NDR_PULL_GET_MEM_CTX(ndr);
- NDR_PULL_SET_MEM_CTX(ndr, r->in.unknown, 0);
- NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.unknown));
- NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown_0, 0);
+ if (r->in.backupfile) {
+ _mem_save_backupfile_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.backupfile, 0);
+ NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.backupfile));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_backupfile_0, 0);
}
}
if (flags & NDR_OUT) {
ndr->depth++;
ndr_print_policy_handle(ndr, "handle", r->in.handle);
ndr->depth--;
- ndr_print_ptr(ndr, "unknown", r->in.unknown);
+ ndr_print_ptr(ndr, "backupfile", r->in.backupfile);
ndr->depth++;
- if (r->in.unknown) {
- ndr_print_lsa_String(ndr, "unknown", r->in.unknown);
+ if (r->in.backupfile) {
+ ndr_print_lsa_String(ndr, "backupfile", r->in.backupfile);
}
ndr->depth--;
ndr->depth--;
static enum ndr_err_code ndr_push_eventlog_GetOldestRecord(struct ndr_push *ndr, int flags, const struct eventlog_GetOldestRecord *r)
{
if (flags & NDR_IN) {
+ if (r->in.handle == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
}
if (flags & NDR_OUT) {
+ if (r->out.oldest_entry == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.oldest_entry));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_eventlog_GetOldestRecord(struct ndr_pull *ndr, int flags, struct eventlog_GetOldestRecord *r)
{
+ TALLOC_CTX *_mem_save_handle_0;
+ TALLOC_CTX *_mem_save_oldest_entry_0;
if (flags & NDR_IN) {
+ ZERO_STRUCT(r->out);
+
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->in.handle);
+ }
+ _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
+ NDR_PULL_ALLOC(ndr, r->out.oldest_entry);
+ ZERO_STRUCTP(r->out.oldest_entry);
}
if (flags & NDR_OUT) {
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->out.oldest_entry);
+ }
+ _mem_save_oldest_entry_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out.oldest_entry, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.oldest_entry));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_oldest_entry_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
return NDR_ERR_SUCCESS;
if (flags & NDR_IN) {
ndr_print_struct(ndr, "in", "eventlog_GetOldestRecord");
ndr->depth++;
+ ndr_print_ptr(ndr, "handle", r->in.handle);
+ ndr->depth++;
+ ndr_print_policy_handle(ndr, "handle", r->in.handle);
+ ndr->depth--;
ndr->depth--;
}
if (flags & NDR_OUT) {
ndr_print_struct(ndr, "out", "eventlog_GetOldestRecord");
ndr->depth++;
+ ndr_print_ptr(ndr, "oldest_entry", r->out.oldest_entry);
+ ndr->depth++;
+ ndr_print_uint32(ndr, "oldest_entry", *r->out.oldest_entry);
+ ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
}
if (r->in.unknown0) {
NDR_CHECK(ndr_push_eventlog_OpenUnknown0(ndr, NDR_SCALARS, r->in.unknown0));
}
- NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logname));
- NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.servername));
+ if (r->in.logname == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logname));
+ if (r->in.servername == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.servername));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown3));
}
{
uint32_t _ptr_unknown0;
TALLOC_CTX *_mem_save_unknown0_0;
+ TALLOC_CTX *_mem_save_logname_0;
+ TALLOC_CTX *_mem_save_servername_0;
TALLOC_CTX *_mem_save_handle_0;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
NDR_CHECK(ndr_pull_eventlog_OpenUnknown0(ndr, NDR_SCALARS, r->in.unknown0));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown0_0, 0);
}
- NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logname));
- NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.servername));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->in.logname);
+ }
+ _mem_save_logname_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.logname, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logname));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_logname_0, LIBNDR_FLAG_REF_ALLOC);
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->in.servername);
+ }
+ _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.servername, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.servername));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown3));
NDR_PULL_ALLOC(ndr, r->out.handle);
ndr_print_eventlog_OpenUnknown0(ndr, "unknown0", r->in.unknown0);
}
ndr->depth--;
- ndr_print_lsa_String(ndr, "logname", &r->in.logname);
- ndr_print_lsa_String(ndr, "servername", &r->in.servername);
+ ndr_print_ptr(ndr, "logname", r->in.logname);
+ ndr->depth++;
+ ndr_print_lsa_String(ndr, "logname", r->in.logname);
+ ndr->depth--;
+ ndr_print_ptr(ndr, "servername", r->in.servername);
+ ndr->depth++;
+ ndr_print_lsa_String(ndr, "servername", r->in.servername);
+ ndr->depth--;
ndr_print_uint32(ndr, "unknown2", r->in.unknown2);
ndr_print_uint32(ndr, "unknown3", r->in.unknown3);
ndr->depth--;
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offset));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.number_of_bytes));
+ if (r->in.number_of_bytes < 0 || r->in.number_of_bytes > 0x7FFFF) {
+ return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
+ }
NDR_PULL_ALLOC_N(ndr, r->out.data, r->in.number_of_bytes);
memset(r->out.data, 0, r->in.number_of_bytes * sizeof(*r->out.data));
NDR_PULL_ALLOC(ndr, r->out.sent_size);
NDR_CHECK(ndr_push_security_secinfo(ndr, NDR_SCALARS, r->in.sec_info));
}
if (flags & NDR_OUT) {
- NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.sdbuf));
- if (r->out.sdbuf) {
- NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sdbuf));
+ if (r->out.sdbuf == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ if (*r->out.sdbuf == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sdbuf));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
uint32_t _ptr_sdbuf;
TALLOC_CTX *_mem_save_handle_0;
TALLOC_CTX *_mem_save_sdbuf_0;
+ TALLOC_CTX *_mem_save_sdbuf_1;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_security_secinfo(ndr, NDR_SCALARS, &r->in.sec_info));
+ NDR_PULL_ALLOC(ndr, r->out.sdbuf);
+ ZERO_STRUCTP(r->out.sdbuf);
}
if (flags & NDR_OUT) {
- NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sdbuf));
- if (_ptr_sdbuf) {
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
NDR_PULL_ALLOC(ndr, r->out.sdbuf);
- } else {
- r->out.sdbuf = NULL;
}
- if (r->out.sdbuf) {
- _mem_save_sdbuf_0 = NDR_PULL_GET_MEM_CTX(ndr);
- NDR_PULL_SET_MEM_CTX(ndr, r->out.sdbuf, 0);
- NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sdbuf));
- NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sdbuf_0, 0);
+ _mem_save_sdbuf_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out.sdbuf, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_sdbuf));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.sdbuf);
}
+ _mem_save_sdbuf_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.sdbuf, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sdbuf));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sdbuf_1, LIBNDR_FLAG_REF_ALLOC);
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sdbuf_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
return NDR_ERR_SUCCESS;
ndr->depth++;
ndr_print_ptr(ndr, "sdbuf", r->out.sdbuf);
ndr->depth++;
- if (r->out.sdbuf) {
- ndr_print_sec_desc_buf(ndr, "sdbuf", r->out.sdbuf);
- }
+ ndr_print_ptr(ndr, "sdbuf", *r->out.sdbuf);
+ ndr->depth++;
+ ndr_print_sec_desc_buf(ndr, "sdbuf", *r->out.sdbuf);
+ ndr->depth--;
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
static enum ndr_err_code ndr_push_lsa_SetSecObj(struct ndr_push *ndr, int flags, const struct lsa_SetSecObj *r)
{
if (flags & NDR_IN) {
+ if (r->in.handle == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
+ NDR_CHECK(ndr_push_security_secinfo(ndr, NDR_SCALARS, r->in.sec_info));
+ if (r->in.sdbuf == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sdbuf));
}
if (flags & NDR_OUT) {
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
static enum ndr_err_code ndr_pull_lsa_SetSecObj(struct ndr_pull *ndr, int flags, struct lsa_SetSecObj *r)
{
+ TALLOC_CTX *_mem_save_handle_0;
+ TALLOC_CTX *_mem_save_sdbuf_0;
if (flags & NDR_IN) {
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->in.handle);
+ }
+ _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_security_secinfo(ndr, NDR_SCALARS, &r->in.sec_info));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->in.sdbuf);
+ }
+ _mem_save_sdbuf_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.sdbuf, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sdbuf));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sdbuf_0, LIBNDR_FLAG_REF_ALLOC);
}
if (flags & NDR_OUT) {
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
if (flags & NDR_IN) {
ndr_print_struct(ndr, "in", "lsa_SetSecObj");
ndr->depth++;
+ ndr_print_ptr(ndr, "handle", r->in.handle);
+ ndr->depth++;
+ ndr_print_policy_handle(ndr, "handle", r->in.handle);
+ ndr->depth--;
+ ndr_print_security_secinfo(ndr, "sec_info", r->in.sec_info);
+ ndr_print_ptr(ndr, "sdbuf", r->in.sdbuf);
+ ndr->depth++;
+ ndr_print_sec_desc_buf(ndr, "sdbuf", r->in.sdbuf);
+ ndr->depth--;
ndr->depth--;
}
if (flags & NDR_OUT) {
static enum ndr_err_code ndr_push_lsa_DeleteObject(struct ndr_push *ndr, int flags, const struct lsa_DeleteObject *r)
{
if (flags & NDR_IN) {
+ if (r->in.handle == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ if (*r->in.handle == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.handle));
}
if (flags & NDR_OUT) {
+ if (r->out.handle == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ if (*r->out.handle == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.handle));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_lsa_DeleteObject(struct ndr_pull *ndr, int flags, struct lsa_DeleteObject *r)
{
+ uint32_t _ptr_handle;
+ TALLOC_CTX *_mem_save_handle_0;
+ TALLOC_CTX *_mem_save_handle_1;
if (flags & NDR_IN) {
+ ZERO_STRUCT(r->out);
+
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->in.handle);
+ }
+ _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_handle));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->in.handle);
+ }
+ _mem_save_handle_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->in.handle, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, *r->in.handle));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_1, LIBNDR_FLAG_REF_ALLOC);
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
+ NDR_PULL_ALLOC(ndr, r->out.handle);
+ *r->out.handle = *r->in.handle;
}
if (flags & NDR_OUT) {
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->out.handle);
+ }
+ _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_handle));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.handle);
+ }
+ _mem_save_handle_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.handle, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.handle));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_1, LIBNDR_FLAG_REF_ALLOC);
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
return NDR_ERR_SUCCESS;
if (flags & NDR_IN) {
ndr_print_struct(ndr, "in", "lsa_DeleteObject");
ndr->depth++;
+ ndr_print_ptr(ndr, "handle", r->in.handle);
+ ndr->depth++;
+ ndr_print_ptr(ndr, "handle", *r->in.handle);
+ ndr->depth++;
+ ndr_print_policy_handle(ndr, "handle", *r->in.handle);
+ ndr->depth--;
+ ndr->depth--;
ndr->depth--;
}
if (flags & NDR_OUT) {
ndr_print_struct(ndr, "out", "lsa_DeleteObject");
ndr->depth++;
+ ndr_print_ptr(ndr, "handle", r->out.handle);
+ ndr->depth++;
+ ndr_print_ptr(ndr, "handle", *r->out.handle);
+ ndr->depth++;
+ ndr_print_policy_handle(ndr, "handle", *r->out.handle);
+ ndr->depth--;
+ ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
}
ndr->depth--;
}
+static enum ndr_err_code ndr_push_samr_ConnectVersion(struct ndr_push *ndr, int ndr_flags, enum samr_ConnectVersion r)
+{
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_samr_ConnectVersion(struct ndr_pull *ndr, int ndr_flags, enum samr_ConnectVersion *r)
+{
+ uint16_t v;
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_samr_ConnectVersion(struct ndr_print *ndr, const char *name, enum samr_ConnectVersion r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case SAMR_CONNECT_PRE_W2K: val = "SAMR_CONNECT_PRE_W2K"; break;
+ case SAMR_CONNECT_W2K: val = "SAMR_CONNECT_W2K"; break;
+ case SAMR_CONNECT_AFTER_W2K: val = "SAMR_CONNECT_AFTER_W2K"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
static enum ndr_err_code ndr_push_samr_ChangeReject(struct ndr_push *ndr, int ndr_flags, const struct samr_ChangeReject *r)
{
if (ndr_flags & NDR_SCALARS) {
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown1));
+ NDR_CHECK(ndr_push_samr_ConnectVersion(ndr, NDR_SCALARS, r->client_version));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2));
}
if (ndr_flags & NDR_BUFFERS) {
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_pull_align(ndr, 4));
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1));
+ NDR_CHECK(ndr_pull_samr_ConnectVersion(ndr, NDR_SCALARS, &r->client_version));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2));
}
if (ndr_flags & NDR_BUFFERS) {
{
ndr_print_struct(ndr, name, "samr_ConnectInfo1");
ndr->depth++;
- ndr_print_uint32(ndr, "unknown1", r->unknown1);
+ ndr_print_samr_ConnectVersion(ndr, "client_version", r->client_version);
ndr_print_uint32(ndr, "unknown2", r->unknown2);
ndr->depth--;
}
if (r->out.sdbuf == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
- NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sdbuf));
+ if (*r->out.sdbuf == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sdbuf));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_samr_QuerySecurity(struct ndr_pull *ndr, int flags, struct samr_QuerySecurity *r)
{
+ uint32_t _ptr_sdbuf;
TALLOC_CTX *_mem_save_handle_0;
TALLOC_CTX *_mem_save_sdbuf_0;
+ TALLOC_CTX *_mem_save_sdbuf_1;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
}
_mem_save_sdbuf_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->out.sdbuf, LIBNDR_FLAG_REF_ALLOC);
- NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sdbuf));
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_sdbuf));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.sdbuf);
+ }
+ _mem_save_sdbuf_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.sdbuf, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sdbuf));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sdbuf_1, LIBNDR_FLAG_REF_ALLOC);
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sdbuf_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
ndr->depth++;
ndr_print_ptr(ndr, "sdbuf", r->out.sdbuf);
ndr->depth++;
- ndr_print_sec_desc_buf(ndr, "sdbuf", r->out.sdbuf);
+ ndr_print_ptr(ndr, "sdbuf", *r->out.sdbuf);
+ ndr->depth++;
+ ndr_print_sec_desc_buf(ndr, "sdbuf", *r->out.sdbuf);
+ ndr->depth--;
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
if (r->out.sid == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
- NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sid));
+ if (*r->out.sid == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sid));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_samr_LookupDomain(struct ndr_pull *ndr, int flags, struct samr_LookupDomain *r)
{
+ uint32_t _ptr_sid;
TALLOC_CTX *_mem_save_connect_handle_0;
TALLOC_CTX *_mem_save_domain_name_0;
TALLOC_CTX *_mem_save_sid_0;
+ TALLOC_CTX *_mem_save_sid_1;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
}
_mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->out.sid, LIBNDR_FLAG_REF_ALLOC);
- NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sid));
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_sid));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.sid);
+ }
+ _mem_save_sid_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.sid, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sid));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_1, LIBNDR_FLAG_REF_ALLOC);
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
ndr->depth++;
ndr_print_ptr(ndr, "sid", r->out.sid);
ndr->depth++;
- ndr_print_dom_sid2(ndr, "sid", r->out.sid);
+ ndr_print_ptr(ndr, "sid", *r->out.sid);
+ ndr->depth++;
+ ndr_print_dom_sid2(ndr, "sid", *r->out.sid);
+ ndr->depth--;
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
if (r->out.info == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
- NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.info, r->in.level));
- NDR_CHECK(ndr_push_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ if (*r->out.info == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, *r->out.info, r->in.level));
+ NDR_CHECK(ndr_push_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_samr_QueryDomainInfo(struct ndr_pull *ndr, int flags, struct samr_QueryDomainInfo *r)
{
+ uint32_t _ptr_info;
TALLOC_CTX *_mem_save_domain_handle_0;
TALLOC_CTX *_mem_save_info_0;
+ TALLOC_CTX *_mem_save_info_1;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
}
_mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC);
- NDR_CHECK(ndr_pull_set_switch_value(ndr, r->out.info, r->in.level));
- NDR_CHECK(ndr_pull_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_info));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.info);
+ }
+ _mem_save_info_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.info, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, *r->out.info, r->in.level));
+ NDR_CHECK(ndr_pull_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_1, LIBNDR_FLAG_REF_ALLOC);
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
ndr->depth++;
ndr_print_ptr(ndr, "info", r->out.info);
ndr->depth++;
- ndr_print_set_switch_value(ndr, r->out.info, r->in.level);
- ndr_print_samr_DomainInfo(ndr, "info", r->out.info);
+ ndr_print_ptr(ndr, "info", *r->out.info);
+ ndr->depth++;
+ ndr_print_set_switch_value(ndr, *r->out.info, r->in.level);
+ ndr_print_samr_DomainInfo(ndr, "info", *r->out.info);
+ ndr->depth--;
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
if (r->out.rids == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
- NDR_CHECK(ndr_push_samr_RidTypeArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.rids));
+ if (*r->out.rids == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_samr_RidTypeArray(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.rids));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_samr_QueryGroupMember(struct ndr_pull *ndr, int flags, struct samr_QueryGroupMember *r)
{
+ uint32_t _ptr_rids;
TALLOC_CTX *_mem_save_group_handle_0;
TALLOC_CTX *_mem_save_rids_0;
+ TALLOC_CTX *_mem_save_rids_1;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
}
_mem_save_rids_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->out.rids, LIBNDR_FLAG_REF_ALLOC);
- NDR_CHECK(ndr_pull_samr_RidTypeArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.rids));
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_rids));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.rids);
+ }
+ _mem_save_rids_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.rids, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_samr_RidTypeArray(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.rids));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rids_1, LIBNDR_FLAG_REF_ALLOC);
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rids_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
ndr->depth++;
ndr_print_ptr(ndr, "rids", r->out.rids);
ndr->depth++;
- ndr_print_samr_RidTypeArray(ndr, "rids", r->out.rids);
+ ndr_print_ptr(ndr, "rids", *r->out.rids);
+ ndr->depth++;
+ ndr_print_samr_RidTypeArray(ndr, "rids", *r->out.rids);
+ ndr->depth--;
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
if (r->out.info == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
}
- NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.info, r->in.level));
- NDR_CHECK(ndr_push_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ if (*r->out.info == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_ref_ptr(ndr));
+ NDR_CHECK(ndr_push_set_switch_value(ndr, *r->out.info, r->in.level));
+ NDR_CHECK(ndr_push_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info));
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
}
return NDR_ERR_SUCCESS;
static enum ndr_err_code ndr_pull_samr_QueryDomainInfo2(struct ndr_pull *ndr, int flags, struct samr_QueryDomainInfo2 *r)
{
+ uint32_t _ptr_info;
TALLOC_CTX *_mem_save_domain_handle_0;
TALLOC_CTX *_mem_save_info_0;
+ TALLOC_CTX *_mem_save_info_1;
if (flags & NDR_IN) {
ZERO_STRUCT(r->out);
}
_mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC);
- NDR_CHECK(ndr_pull_set_switch_value(ndr, r->out.info, r->in.level));
- NDR_CHECK(ndr_pull_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_info));
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, *r->out.info);
+ }
+ _mem_save_info_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.info, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, *r->out.info, r->in.level));
+ NDR_CHECK(ndr_pull_samr_DomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_1, LIBNDR_FLAG_REF_ALLOC);
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC);
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
}
ndr->depth++;
ndr_print_ptr(ndr, "info", r->out.info);
ndr->depth++;
- ndr_print_set_switch_value(ndr, r->out.info, r->in.level);
- ndr_print_samr_DomainInfo(ndr, "info", r->out.info);
+ ndr_print_ptr(ndr, "info", *r->out.info);
+ ndr->depth++;
+ ndr_print_set_switch_value(ndr, *r->out.info, r->in.level);
+ ndr_print_samr_DomainInfo(ndr, "info", *r->out.info);
+ ndr->depth--;
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", r->out.result);
ndr->depth--;
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.system_name, CH_UTF16)));
NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.system_name, ndr_charset_length(r->in.system_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
}
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown));
+ NDR_CHECK(ndr_push_samr_ConnectVersion(ndr, NDR_SCALARS, r->in.client_version));
NDR_CHECK(ndr_push_samr_ConnectAccessMask(ndr, NDR_SCALARS, r->in.access_mask));
}
if (flags & NDR_OUT) {
NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.system_name, ndr_get_array_length(ndr, &r->in.system_name), sizeof(uint16_t), CH_UTF16));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_system_name_0, 0);
}
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown));
+ NDR_CHECK(ndr_pull_samr_ConnectVersion(ndr, NDR_SCALARS, &r->in.client_version));
NDR_CHECK(ndr_pull_samr_ConnectAccessMask(ndr, NDR_SCALARS, &r->in.access_mask));
NDR_PULL_ALLOC(ndr, r->out.connect_handle);
ZERO_STRUCTP(r->out.connect_handle);
ndr_print_string(ndr, "system_name", r->in.system_name);
}
ndr->depth--;
- ndr_print_uint32(ndr, "unknown", r->in.unknown);
+ ndr_print_samr_ConnectVersion(ndr, "client_version", r->in.client_version);
ndr_print_samr_ConnectAccessMask(ndr, "access_mask", r->in.access_mask);
ndr->depth--;
}
void ndr_print_samr_DispInfoAscii(struct ndr_print *ndr, const char *name, const struct samr_DispInfoAscii *r);
void ndr_print_samr_DispInfo(struct ndr_print *ndr, const char *name, const union samr_DispInfo *r);
void ndr_print_samr_PwInfo(struct ndr_print *ndr, const char *name, const struct samr_PwInfo *r);
+void ndr_print_samr_ConnectVersion(struct ndr_print *ndr, const char *name, enum samr_ConnectVersion r);
void ndr_print_samr_ChangeReject(struct ndr_print *ndr, const char *name, const struct samr_ChangeReject *r);
void ndr_print_samr_ConnectInfo1(struct ndr_print *ndr, const char *name, const struct samr_ConnectInfo1 *r);
void ndr_print_samr_ConnectInfo(struct ndr_print *ndr, const char *name, const union samr_ConnectInfo *r);
struct netr_DsRAddressToSitenamesW {
struct {
const char *server_name;/* [unique,charset(UTF16)] */
- uint32_t count;/* [range(0 32000)] */
+ uint32_t count;/* [range(0,32000)] */
struct netr_DsRAddress *addresses;/* [ref,size_is(count)] */
} in;
struct netr_DsRAddressToSitenamesExW {
struct {
const char *server_name;/* [unique,charset(UTF16)] */
- uint32_t count;/* [range(0 32000)] */
+ uint32_t count;/* [range(0,32000)] */
struct netr_DsRAddress *addresses;/* [ref,size_is(count)] */
} in;
}/* [switch_type(uint16)] */;
struct samr_Ids {
- uint32_t count;/* [range(0 1024)] */
+ uint32_t count;/* [range(0,1024)] */
uint32_t *ids;/* [unique,size_is(count)] */
};
uint32_t password_properties;
};
+enum samr_ConnectVersion
+#ifndef USE_UINT_ENUMS
+ {
+ SAMR_CONNECT_PRE_W2K=1,
+ SAMR_CONNECT_W2K=2,
+ SAMR_CONNECT_AFTER_W2K=3
+}
+#else
+ { __donnot_use_enum_samr_ConnectVersion=0x7FFFFFFF}
+#define SAMR_CONNECT_PRE_W2K ( 1 )
+#define SAMR_CONNECT_W2K ( 2 )
+#define SAMR_CONNECT_AFTER_W2K ( 3 )
+#endif
+;
+
enum samr_RejectReason;
struct samr_ChangeReject {
};
struct samr_ConnectInfo1 {
- uint32_t unknown1;
+ enum samr_ConnectVersion client_version;
uint32_t unknown2;
};
} in;
struct {
- struct sec_desc_buf *sdbuf;/* [ref] */
+ struct sec_desc_buf **sdbuf;/* [ref] */
NTSTATUS result;
} out;
} in;
struct {
- struct dom_sid2 *sid;/* [ref] */
+ struct dom_sid2 **sid;/* [ref] */
NTSTATUS result;
} out;
} in;
struct {
- union samr_DomainInfo *info;/* [ref,switch_is(level)] */
+ union samr_DomainInfo **info;/* [ref,switch_is(level)] */
NTSTATUS result;
} out;
struct samr_LookupNames {
struct {
struct policy_handle *domain_handle;/* [ref] */
- uint32_t num_names;/* [range(0 1000)] */
+ uint32_t num_names;/* [range(0,1000)] */
struct lsa_String *names;/* [length_is(num_names),size_is(1000)] */
} in;
struct samr_LookupRids {
struct {
struct policy_handle *domain_handle;/* [ref] */
- uint32_t num_rids;/* [range(0 1000)] */
+ uint32_t num_rids;/* [range(0,1000)] */
uint32_t *rids;/* [length_is(num_rids),size_is(1000)] */
} in;
} in;
struct {
- struct samr_RidTypeArray *rids;/* [ref] */
+ struct samr_RidTypeArray **rids;/* [ref] */
NTSTATUS result;
} out;
} in;
struct {
- union samr_DomainInfo *info;/* [ref,switch_is(level)] */
+ union samr_DomainInfo **info;/* [ref,switch_is(level)] */
NTSTATUS result;
} out;
struct samr_Connect4 {
struct {
const char *system_name;/* [unique,charset(UTF16)] */
- uint32_t unknown;
+ enum samr_ConnectVersion client_version;
uint32_t access_mask;
} in;
struct security_acl {
enum security_acl_revision revision;
uint16_t size;/* [value(ndr_size_security_acl(r,ndr->flags))] */
- uint32_t num_aces;/* [range(0 1000)] */
+ uint32_t num_aces;/* [range(0,1000)] */
struct security_ace *aces;
}/* [gensize,public,nosize] */;
}/* [gensize,public,flag(LIBNDR_FLAG_LITTLE_ENDIAN),nosize] */;
struct sec_desc_buf {
- uint32_t sd_size;/* [value(ndr_size_security_descriptor(sd,ndr->flags)),range(0 0x40000)] */
+ uint32_t sd_size;/* [value(ndr_size_security_descriptor(sd,ndr->flags)),range(0,0x40000)] */
struct security_descriptor *sd;/* [unique,subcontext(4)] */
}/* [public] */;
NDR_PRINT_IN_DEBUG(eventlog_GetOldestRecord, r);
}
+ ZERO_STRUCT(r->out);
+ r->out.oldest_entry = talloc_zero(r, uint32_t);
+ if (r->out.oldest_entry == NULL) {
+ talloc_free(r);
+ return false;
+ }
+
r->out.result = _eventlog_GetOldestRecord(p, r);
if (p->rng_fault_state) {
}
ZERO_STRUCT(r->out);
- r->out.sdbuf = talloc_zero(r, struct sec_desc_buf);
+ r->out.sdbuf = talloc_zero(r, struct sec_desc_buf *);
if (r->out.sdbuf == NULL) {
talloc_free(r);
return false;
NDR_PRINT_IN_DEBUG(lsa_DeleteObject, r);
}
+ ZERO_STRUCT(r->out);
+ r->out.handle = r->in.handle;
r->out.result = _lsa_DeleteObject(p, r);
if (p->rng_fault_state) {
}
ZERO_STRUCT(r->out);
- r->out.sdbuf = talloc_zero(r, struct sec_desc_buf);
+ r->out.sdbuf = talloc_zero(r, struct sec_desc_buf *);
if (r->out.sdbuf == NULL) {
talloc_free(r);
return false;
}
ZERO_STRUCT(r->out);
- r->out.sid = talloc_zero(r, struct dom_sid2);
+ r->out.sid = talloc_zero(r, struct dom_sid2 *);
if (r->out.sid == NULL) {
talloc_free(r);
return false;
}
ZERO_STRUCT(r->out);
- r->out.info = talloc_zero(r, union samr_DomainInfo);
+ r->out.info = talloc_zero(r, union samr_DomainInfo *);
if (r->out.info == NULL) {
talloc_free(r);
return false;
}
ZERO_STRUCT(r->out);
- r->out.rids = talloc_zero(r, struct samr_RidTypeArray);
+ r->out.rids = talloc_zero(r, struct samr_RidTypeArray *);
if (r->out.rids == NULL) {
talloc_free(r);
return false;
}
ZERO_STRUCT(r->out);
- r->out.info = talloc_zero(r, union samr_DomainInfo);
+ r->out.info = talloc_zero(r, union samr_DomainInfo *);
if (r->out.info == NULL) {
talloc_free(r);
return false;
struct unixinfo_GetPWUid {
struct {
uint64_t *uids;/* [size_is(*count)] */
- uint32_t *count;/* [ref,range(0 1023)] */
+ uint32_t *count;/* [ref,range(0,1023)] */
} in;
struct {
struct unixinfo_GetPWUidInfo *infos;/* [size_is(*count)] */
- uint32_t *count;/* [ref,range(0 1023)] */
+ uint32_t *count;/* [ref,range(0,1023)] */
NTSTATUS result;
} out;
[ uuid("82273fdc-e32a-18c3-3f78-827929dc23ea"),
version(0.0),
- pointer_default(unique),
helpstring("Event Logger")
] interface eventlog
{
/* Function: 0x00 */
NTSTATUS eventlog_ClearEventLogW(
[in] policy_handle *handle,
- [in,unique] lsa_String *unknown
+ [in,unique] lsa_String *backupfile
);
/******************/
/******************/
/* Function: 0x05 */
- NTSTATUS eventlog_GetOldestRecord();
+ NTSTATUS eventlog_GetOldestRecord(
+ [in] policy_handle *handle,
+ [out,ref] uint32 *oldest_entry
+ );
/******************/
/* Function: 0x06 */
/* Function: 0x07 */
NTSTATUS eventlog_OpenEventLogW(
[in,unique] eventlog_OpenUnknown0 *unknown0,
- [in] lsa_String logname,
- [in] lsa_String servername,
+ [in,ref] lsa_String *logname,
+ [in,ref] lsa_String *servername,
[in] uint32 unknown2,
[in] uint32 unknown3,
[out] policy_handle *handle
[in] policy_handle *handle,
[in] uint32 flags,
[in] uint32 offset,
- [in] uint32 number_of_bytes,
- [out,size_is(number_of_bytes)] uint8 *data,
- [out] uint32 *sent_size,
- [out] uint32 *real_size
+ [in] [range(0,0x7FFFF)] uint32 number_of_bytes,
+ [out,ref,size_is(number_of_bytes)] uint8 *data,
+ [out,ref] uint32 *sent_size,
+ [out,ref] uint32 *real_size
);
/*****************/
NTSTATUS lsa_QuerySecurity (
[in] policy_handle *handle,
[in] security_secinfo sec_info,
- [out,unique] sec_desc_buf *sdbuf
+ [out,ref] sec_desc_buf **sdbuf
);
/******************/
/* Function: 0x04 */
- NTSTATUS lsa_SetSecObj ();
-
+ NTSTATUS lsa_SetSecObj(
+ [in] policy_handle *handle,
+ [in] security_secinfo sec_info,
+ [in,ref] sec_desc_buf *sdbuf
+ );
/******************/
/* Function: 0x05 */
);
/* Function: 0x22 */
- NTSTATUS lsa_DeleteObject();
+ NTSTATUS lsa_DeleteObject(
+ [in,out] policy_handle **handle
+ );
-
/*******************/
/* Function: 0x23 */
NTSTATUS lsa_EnumAccountsWithUserRight (
uuid("12345678-1234-abcd-ef00-01234567cffb"),
version(1.0),
endpoint("ncacn_np:[\\pipe\\netlogon]","ncacn_ip_tcp:","ncalrpc:"),
- pointer_default(unique),
- pointer_default_top(unique)
+ pointer_default(unique)
]
interface netlogon
} netr_UasInfo;
WERROR netr_LogonUasLogon(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] [string,charset(UTF16)] uint16 workstation[],
[out,ref] netr_UasInfo *info
} netr_UasLogoffInfo;
WERROR netr_LogonUasLogoff(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] [string,charset(UTF16)] uint16 workstation[],
[out,ref] netr_UasLogoffInfo *info
} netr_Authenticator;
NTSTATUS netr_LogonSamLogon(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *computer_name,
- [in] netr_Authenticator *credential,
- [in][out] netr_Authenticator *return_authenticator,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+ [in,unique] netr_Authenticator *credential,
+ [in,out,unique] netr_Authenticator *return_authenticator,
[in] uint16 logon_level,
[in] [switch_is(logon_level)] netr_LogonLevel logon,
[in] uint16 validation_level,
/* Function 0x03 */
NTSTATUS netr_LogonSamLogoff(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *computer_name,
- [in] netr_Authenticator *credential,
- [in][out] netr_Authenticator *return_authenticator,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+ [in,unique] netr_Authenticator *credential,
+ [in,out,unique] netr_Authenticator *return_authenticator,
[in] uint16 logon_level,
[in] [switch_is(logon_level)] netr_LogonLevel logon
);
/* Function 0x04 */
NTSTATUS netr_ServerReqChallenge(
- [in,string,charset(UTF16)] uint16 *server_name,
+ [in,unique,string,charset(UTF16)] uint16 *server_name,
[in,string,charset(UTF16)] uint16 computer_name[],
[in,out,ref] netr_Credential *credentials
);
typedef enum netr_SchannelType netr_SchannelType;
NTSTATUS netr_ServerAuthenticate(
- [in,string,charset(UTF16)] uint16 *server_name,
+ [in,unique,string,charset(UTF16)] uint16 *server_name,
[in,string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in,string,charset(UTF16)] uint16 computer_name[],
/* Function 0x06 */
NTSTATUS netr_ServerPasswordSet(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in] [string,charset(UTF16)] uint16 computer_name[],
} netr_AccountBuffer;
NTSTATUS netr_AccountDeltas(
- [in] [string,charset(UTF16)] uint16 *logon_server,
+ [in,unique] [string,charset(UTF16)] uint16 *logon_server,
[in] [string,charset(UTF16)] uint16 computername[],
[in] netr_Authenticator credential,
[in,out,ref] netr_Authenticator *return_authenticator,
/* Function 0x0A */
NTSTATUS netr_AccountSync(
- [in] [string,charset(UTF16)] uint16 *logon_server,
+ [in,unique] [string,charset(UTF16)] uint16 *logon_server,
[in] [string,charset(UTF16)] uint16 computername[],
[in] netr_Authenticator credential,
[in,out,ref] netr_Authenticator *return_authenticator,
WERROR netr_GetDcName(
[in] [string,charset(UTF16)] uint16 logon_server[],
- [in] [string,charset(UTF16)] uint16 *domainname,
+ [in,unique] [string,charset(UTF16)] uint16 *domainname,
[out,ref] [string,charset(UTF16)] uint16 **dcname
);
} netr_LogonControlCode;
WERROR netr_LogonControl(
- [in] [string,charset(UTF16)] uint16 *logon_server,
+ [in,unique] [string,charset(UTF16)] uint16 *logon_server,
[in] netr_LogonControlCode function_code,
[in] uint32 level,
[out,ref,switch_is(level)] netr_CONTROL_QUERY_INFORMATION *info
/* Function 0x0D */
WERROR netr_GetAnyDCName(
- [in] [string,charset(UTF16)] uint16 *logon_server,
- [in] [string,charset(UTF16)] uint16 *domainname,
+ [in,unique] [string,charset(UTF16)] uint16 *logon_server,
+ [in,unique] [string,charset(UTF16)] uint16 *domainname,
[out,ref] [string,charset(UTF16)] uint16 **dcname
);
} netr_CONTROL_DATA_INFORMATION;
WERROR netr_LogonControl2(
- [in] [string,charset(UTF16)] uint16 *logon_server,
+ [in,unique] [string,charset(UTF16)] uint16 *logon_server,
[in] uint32 function_code,
[in] uint32 level,
[in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION data,
/* Function 0x0F */
NTSTATUS netr_ServerAuthenticate2(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in] [string,charset(UTF16)] uint16 computer_name[],
[in] [string,charset(UTF16)] uint16 computername[],
[in] netr_Authenticator credential,
[in,out,ref] netr_Authenticator *return_authenticator,
- [in][size_is(change_log_entry_size)] uint8 *change_log_entry,
+ [in,unique][size_is(change_log_entry_size)] uint8 *change_log_entry,
[in] uint32 change_log_entry_size,
[out,ref] netr_DELTA_ENUM_ARRAY *delta_enum_array
);
/* Function 0x12 */
WERROR netr_LogonControl2Ex(
- [in] [string,charset(UTF16)] uint16 *logon_server,
+ [in,unique] [string,charset(UTF16)] uint16 *logon_server,
[in] uint32 function_code,
[in] uint32 level,
[in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION data,
} netr_Blob;
WERROR netr_NetrEnumerateTrustedDomains(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[out,ref] netr_Blob *trusted_domains_blob
);
} netr_DsRGetDCNameInfo;
WERROR netr_DsRGetDCName(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *domain_name,
- [in] GUID *domain_guid,
- [in] GUID *site_guid,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+ [in,unique] GUID *domain_guid,
+ [in,unique] GUID *site_guid,
[in] netr_DsRGetDCName_flags flags,
[out,ref] netr_DsRGetDCNameInfo *info
);
/****************/
/* Function 0x17 */
WERROR netr_LogonGetTrustRid(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *domain_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *domain_name,
[out,ref] uint32 *rid
);
/****************/
/* Function 0x1a */
NTSTATUS netr_ServerAuthenticate3(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in] [string,charset(UTF16)] uint16 computer_name[],
/* Function 0x1b */
WERROR netr_DsRGetDCNameEx(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *domain_name,
- [in] GUID *domain_guid,
- [in] [string,charset(UTF16)] uint16 *site_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+ [in,unique] GUID *domain_guid,
+ [in,unique] [string,charset(UTF16)] uint16 *site_name,
[in] netr_DsRGetDCName_flags flags,
[out,ref] netr_DsRGetDCNameInfo **info
);
/****************/
/* Function 0x1c */
WERROR netr_DsRGetSiteName(
- [in] [string,charset(UTF16)] uint16 *computer_name,
+ [in,unique] [string,charset(UTF16)] uint16 *computer_name,
[out,ref] [string,charset(UTF16)] uint16 **site
);
NTSTATUS netr_LogonGetDomainInfo(
[in] [string,charset(UTF16)] uint16 server_name[],
- [in] [string,charset(UTF16)] uint16 *computer_name,
+ [in,unique] [string,charset(UTF16)] uint16 *computer_name,
[in,ref] netr_Authenticator *credential,
[in,out,ref] netr_Authenticator *return_authenticator,
[in] uint32 level,
/*****************/
/* Function 0x1e */
NTSTATUS netr_ServerPasswordSet2(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in] [string,charset(UTF16)] uint16 computer_name[],
/****************/
/* Function 0x1f */
WERROR netr_ServerPasswordGet(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in] [string,charset(UTF16)] uint16 computer_name[],
} netr_DsRAddress;
WERROR netr_DsRAddressToSitenamesW(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [range(0,32000)] uint32 count,
[in] [size_is(count)] [ref] netr_DsRAddress *addresses,
[out] [ref] netr_DsRAddressToSitenamesWCtr **ctr
/****************/
/* Function 0x22 */
WERROR netr_DsRGetDCNameEx2(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *client_account,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *client_account,
[in] samr_AcctFlags mask,
- [in] [string,charset(UTF16)] uint16 *domain_name,
- [in] GUID *domain_guid,
- [in] [string,charset(UTF16)] uint16 *site_name,
+ [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+ [in,unique] GUID *domain_guid,
+ [in,unique] [string,charset(UTF16)] uint16 *site_name,
[in] netr_DsRGetDCName_flags flags,
[out,ref] netr_DsRGetDCNameInfo **info
);
} netr_DomainTrustList;
WERROR netr_NetrEnumerateTrustedDomainsEx(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[out,ref] netr_DomainTrustList *dom_trust_list
);
} netr_DsRAddressToSitenamesExWCtr;
WERROR netr_DsRAddressToSitenamesExW(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [range(0,32000)] uint32 count,
[in] [size_is(count)] [ref] netr_DsRAddress *addresses,
[out] [ref] netr_DsRAddressToSitenamesExWCtr **ctr
} DcSitesCtr;
WERROR netr_DsrGetDcSiteCoverageW(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[out,ref] DcSitesCtr *ctr
);
/****************/
/* Function 0x27 */
NTSTATUS netr_LogonSamLogonEx(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *computer_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *computer_name,
[in] uint16 logon_level,
[in] [switch_is(logon_level)] netr_LogonLevel logon,
[in] uint16 validation_level,
/* Function 0x28 */
WERROR netr_DsrEnumerateDomainTrusts(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] netr_TrustFlags trust_flags,
[out,ref] netr_DomainTrustList *trusts
);
/****************/
/* Function 0x29 */
WERROR netr_DsrDeregisterDNSHostRecords(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *domain,
- [in] GUID *domain_guid,
- [in] GUID *dsa_guid,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *domain,
+ [in,unique] GUID *domain_guid,
+ [in,unique] GUID *dsa_guid,
[in,ref] [string,charset(UTF16)] uint16 *dns_host
);
/****************/
/* Function 0x2a */
NTSTATUS netr_ServerTrustPasswordsGet(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] [string,charset(UTF16)] uint16 account_name[],
[in] netr_SchannelType secure_channel_type,
[in] [string,charset(UTF16)] uint16 computer_name[],
const int DS_GFTI_UPDATE_TDO = 0x1;
WERROR netr_DsRGetForestTrustInformation(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *trusted_domain_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *trusted_domain_name,
[in] uint32 flags,
[out,ref] lsa_ForestTrustInformation **forest_trust_info
);
/****************/
/* Function 0x2c */
WERROR netr_GetForestTrustInformation(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *trusted_domain_name,
[in,ref] netr_Authenticator *credential,
[out,ref] netr_Authenticator *return_authenticator,
/* this is the ADS varient. I don't yet know what the "flags" are for */
NTSTATUS netr_LogonSamLogonWithFlags(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *computer_name,
- [in] netr_Authenticator *credential,
- [in][out] netr_Authenticator *return_authenticator,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+ [in,unique] netr_Authenticator *credential,
+ [in,out,unique] netr_Authenticator *return_authenticator,
[in] uint16 logon_level,
[in] [switch_is(logon_level)] netr_LogonLevel logon,
[in] uint16 validation_level,
[ uuid("12345778-1234-abcd-ef00-0123456789ac"),
version(1.0),
endpoint("ncacn_np:[\\pipe\\samr]","ncacn_ip_tcp:", "ncalrpc:"),
- pointer_default(unique),
- pointer_default_top(unique)
+ pointer_default(unique)
] interface samr
{
typedef bitmap security_secinfo security_secinfo;
/* Function: 0x00 */
NTSTATUS samr_Connect (
/* notice the lack of [string] */
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] samr_ConnectAccessMask access_mask,
[out,ref] policy_handle *connect_handle
);
NTSTATUS samr_QuerySecurity (
[in,ref] policy_handle *handle,
[in] security_secinfo sec_info,
- [out,ref] sec_desc_buf *sdbuf
+ [out,ref] sec_desc_buf **sdbuf
);
/******************/
/******************/
/* Function: 0x05 */
NTSTATUS samr_LookupDomain (
- [in,ref] policy_handle *connect_handle,
+ [in,ref] policy_handle *connect_handle,
[in,ref] lsa_String *domain_name,
- [out,ref] dom_sid2 *sid
+ [out,ref] dom_sid2 **sid
);
NTSTATUS samr_QueryDomainInfo(
[in,ref] policy_handle *domain_handle,
[in] uint16 level,
- [out,ref,switch_is(level)] samr_DomainInfo *info
+ [out,ref,switch_is(level)] samr_DomainInfo **info
);
/************************/
[in,out,ref] uint32 *resume_handle,
[in] samr_AcctFlags acct_flags,
[in] uint32 max_size,
- [out] samr_SamArray *sam,
+ [out,unique] samr_SamArray *sam,
[out,ref] uint32 *num_entries
);
NTSTATUS samr_QueryGroupMember(
[in,ref] policy_handle *group_handle,
- [out,ref] samr_RidTypeArray *rids
+ [out,ref] samr_RidTypeArray **rids
);
NTSTATUS samr_ChangePasswordUser(
[in,ref] policy_handle *user_handle,
[in] boolean8 lm_present,
- [in] samr_Password *old_lm_crypted,
- [in] samr_Password *new_lm_crypted,
+ [in,unique] samr_Password *old_lm_crypted,
+ [in,unique] samr_Password *new_lm_crypted,
[in] boolean8 nt_present,
- [in] samr_Password *old_nt_crypted,
- [in] samr_Password *new_nt_crypted,
+ [in,unique] samr_Password *old_nt_crypted,
+ [in,unique] samr_Password *new_nt_crypted,
[in] boolean8 cross1_present,
- [in] samr_Password *nt_cross,
+ [in,unique] samr_Password *nt_cross,
[in] boolean8 cross2_present,
- [in] samr_Password *lm_cross
+ [in,unique] samr_Password *lm_cross
);
/************************/
NTSTATUS samr_QueryDomainInfo2(
[in,ref] policy_handle *domain_handle,
[in] uint16 level,
- [out,ref,switch_is(level)] samr_DomainInfo *info
+ [out,ref,switch_is(level)] samr_DomainInfo **info
);
/************************/
/* Function 0x36 */
NTSTATUS samr_OemChangePasswordUser2(
- [in] lsa_AsciiString *server,
+ [in,unique] lsa_AsciiString *server,
[in,ref] lsa_AsciiString *account,
- [in] samr_CryptPassword *password,
- [in] samr_Password *hash
+ [in,unique] samr_CryptPassword *password,
+ [in,unique] samr_Password *hash
);
/************************/
/* Function 0x37 */
NTSTATUS samr_ChangePasswordUser2(
- [in] lsa_String *server,
+ [in,unique] lsa_String *server,
[in,ref] lsa_String *account,
- [in] samr_CryptPassword *nt_password,
- [in] samr_Password *nt_verifier,
+ [in,unique] samr_CryptPassword *nt_password,
+ [in,unique] samr_Password *nt_verifier,
[in] boolean8 lm_change,
- [in] samr_CryptPassword *lm_password,
- [in] samr_Password *lm_verifier
+ [in,unique] samr_CryptPassword *lm_password,
+ [in,unique] samr_Password *lm_verifier
);
/************************/
/* Function 0x38 */
NTSTATUS samr_GetDomPwInfo(
- [in] lsa_String *domain_name,
+ [in,unique] lsa_String *domain_name,
[out,ref] samr_PwInfo *info
);
/************************/
/* Function 0x39 */
NTSTATUS samr_Connect2(
- [in,string,charset(UTF16)] uint16 *system_name,
+ [in,unique,string,charset(UTF16)] uint16 *system_name,
[in] samr_ConnectAccessMask access_mask,
[out,ref] policy_handle *connect_handle
);
/************************/
/* Function 0x3d */
NTSTATUS samr_Connect3(
- [in,string,charset(UTF16)] uint16 *system_name,
+ [in,unique,string,charset(UTF16)] uint16 *system_name,
/* this unknown value seems to be completely ignored by w2k3 */
[in] uint32 unknown,
[in] samr_ConnectAccessMask access_mask,
/************************/
/* Function 0x3e */
+
+ typedef enum {
+ SAMR_CONNECT_PRE_W2K = 1,
+ SAMR_CONNECT_W2K = 2,
+ SAMR_CONNECT_AFTER_W2K = 3
+ } samr_ConnectVersion;
+
NTSTATUS samr_Connect4(
- [in,string,charset(UTF16)] uint16 *system_name,
- [in] uint32 unknown,
+ [in,unique,string,charset(UTF16)] uint16 *system_name,
+ [in] samr_ConnectVersion client_version,
[in] samr_ConnectAccessMask access_mask,
[out,ref] policy_handle *connect_handle
);
} samr_ChangeReject;
NTSTATUS samr_ChangePasswordUser3(
- [in] lsa_String *server,
+ [in,unique] lsa_String *server,
[in,ref] lsa_String *account,
- [in] samr_CryptPassword *nt_password,
- [in] samr_Password *nt_verifier,
+ [in,unique] samr_CryptPassword *nt_password,
+ [in,unique] samr_Password *nt_verifier,
[in] boolean8 lm_change,
- [in] samr_CryptPassword *lm_password,
- [in] samr_Password *lm_verifier,
- [in] samr_CryptPassword *password3,
+ [in,unique] samr_CryptPassword *lm_password,
+ [in,unique] samr_Password *lm_verifier,
+ [in,unique] samr_CryptPassword *password3,
[out,ref] samr_DomInfo1 *dominfo,
[out,ref] samr_ChangeReject *reject
);
/* Function 0x40 */
typedef struct {
- uint32 unknown1; /* w2k3 gives 3 */
+ samr_ConnectVersion client_version; /* w2k3 gives 3 */
uint32 unknown2; /* w2k3 gives 0 */
} samr_ConnectInfo1;
} samr_ConnectInfo;
[public] NTSTATUS samr_Connect5(
- [in,string,charset(UTF16)] uint16 *system_name,
+ [in,unique,string,charset(UTF16)] uint16 *system_name,
[in] samr_ConnectAccessMask access_mask,
[in] uint32 level_in,
[in,ref,switch_is(level_in)] samr_ConnectInfo *info_in,
*/
NTSTATUS samr_SetDsrmPassword(
- [in] lsa_String *name,
+ [in,unique] lsa_String *name,
[in] uint32 unknown,
- [in] samr_Password *hash
+ [in,unique] samr_Password *hash
);
version(1.0),
endpoint("ncacn_np:[\\pipe\\spoolss]"),
pointer_default(unique),
- pointer_default_top(unique),
helpstring("Spooler SubSystem"),
depends(security),
helper("librpc/ndr/ndr_spoolss_buf.h")
version(3.0),
endpoint("ncacn_np:[\\pipe\\srvsvc]", "ncacn_ip_tcp:", "ncalrpc:"),
pointer_default(unique),
- pointer_default_top(unique),
helpstring("Server Service")
] interface srvsvc
{
/******************/
/* Function: 0x00 */
WERROR srvsvc_NetCharDevEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in,out,ref] uint32 *level,
[in,out,ref,switch_is(*level)] srvsvc_NetCharDevCtr *ctr,
[in] uint32 max_buffer,
/******************/
/* Function: 0x01 */
WERROR srvsvc_NetCharDevGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 device_name[],
[in] uint32 level,
[out,ref,switch_is(level)] srvsvc_NetCharDevInfo *info
/******************/
/* Function: 0x02 */
WERROR srvsvc_NetCharDevControl(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 device_name[],
[in] uint32 opcode
);
/******************/
/* Function: 0x03 */
WERROR srvsvc_NetCharDevQEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *user,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *user,
[in,out,ref] uint32 *level,
[in,out,switch_is(*level),ref] srvsvc_NetCharDevQCtr *ctr,
[in] uint32 max_buffer,
[out,ref] uint32 *totalentries,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/******************/
/* Function: 0x04 */
WERROR srvsvc_NetCharDevQGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 queue_name[],
[in] [string,charset(UTF16)] uint16 user[],
[in] uint32 level,
/******************/
/* Function: 0x05 */
WERROR srvsvc_NetCharDevQSetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 queue_name[],
[in] uint32 level,
[in,switch_is(level)] srvsvc_NetCharDevQInfo info,
- [in,out] uint32 *parm_error
+ [in,out,unique] uint32 *parm_error
);
/******************/
/* Function: 0x06 */
WERROR srvsvc_NetCharDevQPurge(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 queue_name[]
);
/******************/
/* Function: 0x07 */
WERROR srvsvc_NetCharDevQPurgeSelf(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 queue_name[],
[in] [string,charset(UTF16)] uint16 computer_name[]
);
/******************/
/* Function: 0x08 */
WERROR srvsvc_NetConnEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *path,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *path,
[in,out,ref] uint32 *level,
[in,out,switch_is(*level),ref] srvsvc_NetConnCtr *ctr,
[in] uint32 max_buffer,
/******************/
/* Function: 0x09 */
WERROR srvsvc_NetFileEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *path,
- [in] [string,charset(UTF16)] uint16 *user,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *path,
+ [in,unique] [string,charset(UTF16)] uint16 *user,
[in,out,ref] uint32 *level,
[in,out,switch_is(*level),ref] srvsvc_NetFileCtr *ctr,
[in] uint32 max_buffer,
/******************/
/* Function: 0x0a */
WERROR srvsvc_NetFileGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 fid,
[in] uint32 level,
[out,switch_is(level),ref] srvsvc_NetFileInfo *info
/******************/
/* Function: 0x0b */
WERROR srvsvc_NetFileClose(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 fid
);
/******************/
/* Function: 0x0c */
WERROR srvsvc_NetSessEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *client,
- [in] [string,charset(UTF16)] uint16 *user,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *client,
+ [in,unique] [string,charset(UTF16)] uint16 *user,
[in,out,ref] uint32 *level,
[in,out,switch_is(*level),ref] srvsvc_NetSessCtr *ctr,
[in] uint32 max_buffer,
/******************/
/* Function: 0x0d */
WERROR srvsvc_NetSessDel(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *client,
- [in] [string,charset(UTF16)] uint16 *user
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *client,
+ [in,unique] [string,charset(UTF16)] uint16 *user
);
/**************************/
/******************/
/* Function: 0x0e */
WERROR srvsvc_NetShareAdd(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 level,
[in,switch_is(level)] srvsvc_NetShareInfo info,
- [in,out] uint32 *parm_error
+ [in,out,unique] uint32 *parm_error
);
/******************/
/* Function: 0x0f */
WERROR srvsvc_NetShareEnumAll (
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in,out,ref] uint32 *level,
[in,out,ref,switch_is(*level)] srvsvc_NetShareCtr *ctr,
[in] uint32 max_buffer,
[out,ref] uint32 *totalentries,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/******************/
/* Function: 0x10 */
WERROR srvsvc_NetShareGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 share_name[],
[in] uint32 level,
[out,ref,switch_is(level)] srvsvc_NetShareInfo *info
/******************/
/* Function: 0x11 */
WERROR srvsvc_NetShareSetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 share_name[],
[in] uint32 level,
[in,switch_is(level)] srvsvc_NetShareInfo info,
- [in,out] uint32 *parm_error
+ [in,out,unique] uint32 *parm_error
);
/******************/
/* Function: 0x12 */
WERROR srvsvc_NetShareDel(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 share_name[],
[in] uint32 reserved
);
/******************/
/* Function: 0x13 */
WERROR srvsvc_NetShareDelSticky(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 share_name[],
[in] uint32 reserved
);
/******************/
/* Function: 0x14 */
WERROR srvsvc_NetShareCheck(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 device_name[],
[out,ref] srvsvc_ShareType *type
);
/******************/
/* Function: 0x15 */
WERROR srvsvc_NetSrvGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 level,
[out,ref,switch_is(level)] srvsvc_NetSrvInfo *info
);
/******************/
/* Function: 0x16 */
WERROR srvsvc_NetSrvSetInfo(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 level,
[in,switch_is(level)] srvsvc_NetSrvInfo info,
- [in,out] uint32 *parm_error
+ [in,out,unique] uint32 *parm_error
);
/**************************/
/******************/
/* Function: 0x17 */
WERROR srvsvc_NetDiskEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 level,
[in,out,ref] srvsvc_NetDiskInfo *info,
[in] uint32 maxlen,
[out,ref] uint32 *totalentries,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/**************************/
/******************/
/* Function: 0x18 */
WERROR srvsvc_NetServerStatisticsGet(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *service,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *service,
[in] uint32 level,
[in] uint32 options,
[out,ref] srvsvc_Statistics *stats
/******************/
/* Function: 0x19 */
WERROR srvsvc_NetTransportAdd(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 level,
[in,switch_is(level)] srvsvc_NetTransportInfo info
);
/******************/
/* Function: 0x1a */
WERROR srvsvc_NetTransportEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in,out,ref] uint32 *level,
[in,out,ref,switch_is(*level)] srvsvc_NetTransportCtr *transports,
[in] uint32 max_buffer,
/******************/
/* Function: 0x1b */
WERROR srvsvc_NetTransportDel(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 unknown,
[in] srvsvc_NetTransportInfo0 transport
);
/******************/
/* Function: 0x1c */
WERROR srvsvc_NetRemoteTOD(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [out] srvsvc_NetRemoteTODInfo *info
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [out,unique] srvsvc_NetRemoteTODInfo *info
);
/**************************/
/******************/
/* Function: 0x1d */
WERROR srvsvc_NetSetServiceBits(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *transport,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *transport,
[in] uint32 servicebits,
[in] uint32 updateimmediately
);
/******************/
/* Function: 0x1e */
WERROR srvsvc_NetPathType(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 path[],
[in] uint32 pathflags,
[out,ref] uint32 *pathtype
/******************/
/* Function: 0x1f */
WERROR srvsvc_NetPathCanonicalize(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 path[],
[out] [size_is(maxbuf)] uint8 can_path[],
[in] uint32 maxbuf,
/******************/
/* Function: 0x20 */
WERROR srvsvc_NetPathCompare(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 path1[],
[in] [string,charset(UTF16)] uint16 path2[],
[in] uint32 pathtype,
/******************/
/* Function: 0x21 */
WERROR srvsvc_NetNameValidate(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 name[],
[in] uint32 name_type,
[in] uint32 flags
/******************/
/* Function: 0x23 */
WERROR srvsvc_NetPRNameCompare(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 name1[],
[in] [string,charset(UTF16)] uint16 name2[],
[in] uint32 name_type,
/* Note, there must be some way to return entries read vs
total entries ... */
WERROR srvsvc_NetShareEnum(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in,out,ref] uint32 *level,
[in,out,ref,switch_is(*level)] srvsvc_NetShareCtr *ctr,
[in] uint32 max_buffer,
/******************/
/* Function: 0x25 */
WERROR srvsvc_NetShareDelStart(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] [string,charset(UTF16)] uint16 share[],
[in] uint32 reserved,
- [out] policy_handle *hnd
+ [out,unique] policy_handle *hnd
);
/******************/
/* Function: 0x26 */
WERROR srvsvc_NetShareDelCommit(
- [in, out] policy_handle *hnd
+ [in, out,unique] policy_handle *hnd
);
/******************/
/* Function: 0x27 */
WERROR srvsvc_NetGetFileSecurity(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *share,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *share,
[in] [string,charset(UTF16)] uint16 file[],
[in] security_secinfo securityinformation,
- [out] sec_desc_buf *sd_buf
+ [out,unique] sec_desc_buf *sd_buf
);
/******************/
/* Function: 0x28 */
WERROR srvsvc_NetSetFileSecurity(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *share,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *share,
[in] [string,charset(UTF16)] uint16 file[],
[in] security_secinfo securityinformation,
[in] sec_desc_buf sd_buf
/******************/
/* Function: 0x29 */
WERROR srvsvc_NetServerTransportAddEx(
- [in] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
[in] uint32 level,
[in,switch_is(level)] srvsvc_NetTransportInfo info
);
/******************/
/* Function: 0x2a */
WERROR srvsvc_NetServerSetServiceBitsEx(
- [in] [string,charset(UTF16)] uint16 *server_unc,
- [in] [string,charset(UTF16)] uint16 *emulated_server_unc,
- [in] [string,charset(UTF16)] uint16 *transport,
+ [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *emulated_server_unc,
+ [in,unique] [string,charset(UTF16)] uint16 *transport,
[in] uint32 servicebitsofinterest,
[in] uint32 servicebits,
[in] uint32 updateimmediately
[ uuid("367abb81-9844-35f1-ad32-98f038001003"),
version(2.0),
pointer_default(unique),
- pointer_default_top(unique),
endpoint("ncacn_np:[\\pipe\\svcctl]", "ncalrpc:"),
helpstring("Service Control")
] interface svcctl
[in] uint32 type,
[in] uint32 start,
[in] uint32 error,
- [in] [string,charset(UTF16)] uint16 *binary_path,
- [in] [string,charset(UTF16)] uint16 *load_order_group,
+ [in,unique] [string,charset(UTF16)] uint16 *binary_path,
+ [in,unique] [string,charset(UTF16)] uint16 *load_order_group,
[out,ref] uint32 *tag_id,
- [in] [string,charset(UTF16)] uint16 *dependencies,
- [in] [string,charset(UTF16)] uint16 *service_start_name,
- [in] [string,charset(UTF16)] uint16 *password,
- [in] [string,charset(UTF16)] uint16 *display_name
+ [in,unique] [string,charset(UTF16)] uint16 *dependencies,
+ [in,unique] [string,charset(UTF16)] uint16 *service_start_name,
+ [in,unique] [string,charset(UTF16)] uint16 *password,
+ [in,unique] [string,charset(UTF16)] uint16 *display_name
);
/*****************/
WERROR svcctl_CreateServiceW(
[in,ref] policy_handle *scmanager_handle,
[in] [string,charset(UTF16)] uint16 ServiceName[],
- [in] [string,charset(UTF16)] uint16 *DisplayName,
+ [in,unique] [string,charset(UTF16)] uint16 *DisplayName,
[in] uint32 desired_access,
[in] uint32 type,
[in] uint32 start_type,
[in] uint32 error_control,
[in] [string,charset(UTF16)] uint16 binary_path[],
- [in] [string,charset(UTF16)] uint16 *LoadOrderGroupKey,
- [in,out] uint32 *TagId,
- [in,size_is(dependencies_size)] uint8 *dependencies,
+ [in,unique] [string,charset(UTF16)] uint16 *LoadOrderGroupKey,
+ [in,out,unique] uint32 *TagId,
+ [in,unique,size_is(dependencies_size)] uint8 *dependencies,
[in] uint32 dependencies_size,
- [in] [string,charset(UTF16)] uint16 *service_start_name,
- [in,size_is(password_size)] uint8 *password,
+ [in,unique] [string,charset(UTF16)] uint16 *service_start_name,
+ [in,unique,size_is(password_size)] uint8 *password,
[in] uint32 password_size,
[out,ref] policy_handle *handle
);
WERROR svcctl_EnumDependentServicesW(
[in,ref] policy_handle *service,
[in] uint32 state,
- [out] ENUM_SERVICE_STATUS *service_status,
+ [out,unique] ENUM_SERVICE_STATUS *service_status,
[in] uint32 buf_size,
[out,ref] uint32 *bytes_needed,
[out,ref] uint32 *services_returned
[out,size_is(buf_size)] uint8 service[*],
[out,ref] uint32 *bytes_needed,
[out,ref] uint32 *services_returned,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/*****************/
/* Function 0x0f */
WERROR svcctl_OpenSCManagerW(
- [in] [string,charset(UTF16)] uint16 *MachineName,
- [in] [string,charset(UTF16)] uint16 *DatabaseName,
+ [in,unique] [string,charset(UTF16)] uint16 *MachineName,
+ [in,unique] [string,charset(UTF16)] uint16 *DatabaseName,
[in] uint32 access_mask,
[out,ref] policy_handle *handle
);
WERROR svcctl_StartServiceW(
[in,ref] policy_handle *handle,
[in] uint32 NumArgs,
- [in/*FIXME:,length_is(NumArgs)*/] [string,charset(UTF16)] uint16 *Arguments
+ [in,unique/*FIXME:,length_is(NumArgs)*/] [string,charset(UTF16)] uint16 *Arguments
);
/*****************/
/* Function 0x14 */
WERROR svcctl_GetServiceDisplayNameW(
[in,ref] policy_handle *handle,
- [in] [string,charset(UTF16)] uint16 *service_name,
+ [in,unique] [string,charset(UTF16)] uint16 *service_name,
[out,ref] [string,charset(UTF16)] uint16 **display_name,
- [in,out] uint32 *display_name_length
+ [in,out,unique] uint32 *display_name_length
);
/*****************/
/* Function 0x15 */
WERROR svcctl_GetServiceKeyNameW(
[in,ref] policy_handle *handle,
- [in] [string,charset(UTF16)] uint16 *service_name,
+ [in,unique] [string,charset(UTF16)] uint16 *service_name,
[out,ref] [string,charset(UTF16)] uint16 **key_name,
- [in,out] uint32 *display_name_length
+ [in,out,unique] uint32 *display_name_length
);
/*****************/
[in] uint32 type,
[in] uint32 start,
[in] uint32 error,
- [in] [string,charset(UTF16)] uint16 *binary_path,
- [in] [string,charset(UTF16)] uint16 *load_order_group,
+ [in,unique] [string,charset(UTF16)] uint16 *binary_path,
+ [in,unique] [string,charset(UTF16)] uint16 *load_order_group,
[out,ref] uint32 *tag_id,
- [in] [string,charset(UTF16)] uint16 *dependencies,
- [in] [string,charset(UTF16)] uint16 *service_start_name,
- [in] [string,charset(UTF16)] uint16 *password,
- [in] [string,charset(UTF16)] uint16 *display_name
+ [in,unique] [string,charset(UTF16)] uint16 *dependencies,
+ [in,unique] [string,charset(UTF16)] uint16 *service_start_name,
+ [in,unique] [string,charset(UTF16)] uint16 *password,
+ [in,unique] [string,charset(UTF16)] uint16 *display_name
);
/*****************/
/* Function 0x18 */
WERROR svcctl_CreateServiceA(
[in,ref] policy_handle *handle,
- [in] [string,charset(UTF16)] uint16 *ServiceName,
- [in] [string,charset(UTF16)] uint16 *DisplayName,
+ [in,unique] [string,charset(UTF16)] uint16 *ServiceName,
+ [in,unique] [string,charset(UTF16)] uint16 *DisplayName,
[in] uint32 desired_access,
[in] uint32 type,
[in] uint32 start_type,
[in] uint32 error_control,
- [in] [string,charset(UTF16)] uint16 *binary_path,
- [in] [string,charset(UTF16)] uint16 *LoadOrderGroupKey,
- [out] uint32 *TagId,
- [in] [string,charset(UTF16)] uint16 *dependencies,
- [in] [string,charset(UTF16)] uint16 *service_start_name,
- [in] [string,charset(UTF16)] uint16 *password
+ [in,unique] [string,charset(UTF16)] uint16 *binary_path,
+ [in,unique] [string,charset(UTF16)] uint16 *LoadOrderGroupKey,
+ [out,unique] uint32 *TagId,
+ [in,unique] [string,charset(UTF16)] uint16 *dependencies,
+ [in,unique] [string,charset(UTF16)] uint16 *service_start_name,
+ [in,unique] [string,charset(UTF16)] uint16 *password
);
/*****************/
WERROR svcctl_EnumDependentServicesA(
[in,ref] policy_handle *service,
[in] uint32 state,
- [out] ENUM_SERVICE_STATUS *service_status,
+ [out,unique] ENUM_SERVICE_STATUS *service_status,
[in] uint32 buf_size,
[out,ref] uint32 *bytes_needed,
[out,ref] uint32 *services_returned
[out,size_is(buf_size)] uint8 service[*],
[out,ref] uint32 *bytes_needed,
[out,ref] uint32 *services_returned,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/*****************/
/* Function 0x1b */
WERROR svcctl_OpenSCManagerA(
- [in] [string,charset(UTF16)] uint16 *MachineName,
- [in] [string,charset(UTF16)] uint16 *DatabaseName,
+ [in,unique] [string,charset(UTF16)] uint16 *MachineName,
+ [in,unique] [string,charset(UTF16)] uint16 *DatabaseName,
[in] uint32 access_mask,
[out,ref] policy_handle *handle
);
/* Function 0x1c */
WERROR svcctl_OpenServiceA(
[in,ref] policy_handle *scmanager_handle,
- [in] [string,charset(UTF16)] uint16 *ServiceName,
+ [in,unique] [string,charset(UTF16)] uint16 *ServiceName,
[in] uint32 access_mask
);
WERROR svcctl_StartServiceA(
[in,ref] policy_handle *handle,
[in] uint32 NumArgs,
- [in/*FIXME:,length_is(NumArgs)*/] [string,charset(UTF16)] uint16 *Arguments
+ [in,unique/*FIXME:,length_is(NumArgs)*/] [string,charset(UTF16)] uint16 *Arguments
);
/*****************/
/* Function 0x20 */
WERROR svcctl_GetServiceDisplayNameA(
[in,ref] policy_handle *handle,
- [in] [string,charset(UTF16)] uint16 *service_name,
+ [in,unique] [string,charset(UTF16)] uint16 *service_name,
[out,ref] [string,charset(UTF16)] uint16 **display_name,
- [in,out] uint32 *display_name_length
+ [in,out,unique] uint32 *display_name_length
);
/*****************/
/* Function 0x21 */
WERROR svcctl_GetServiceKeyNameA(
[in,ref] policy_handle *handle,
- [in] [string,charset(UTF16)] uint16 *service_name,
+ [in,unique] [string,charset(UTF16)] uint16 *service_name,
[out,ref] [string,charset(UTF16)] uint16 **key_name,
- [in,out] uint32 *display_name_length
+ [in,out,unique] uint32 *display_name_length
);
/*****************/
WERROR svcctl_ChangeServiceConfig2A(
[in,ref] policy_handle *handle,
[in] uint32 info_level,
- [in] uint8 *info
+ [in,unique] uint8 *info
);
/*****************/
WERROR svcctl_ChangeServiceConfig2W(
[in,ref] policy_handle *handle,
[in] uint32 info_level,
- [in] uint8 *info
+ [in,unique] uint8 *info
);
/*****************/
[in] uint32 buf_size,
[out,ref] uint32 *bytes_needed,
[out,ref] uint32 *service_returned,
- [in,out] uint32 *resume_handle,
+ [in,out,unique] uint32 *resume_handle,
[out,ref] [string,charset(UTF16)] uint16 **group_name
);
[in] uint32 buf_size,
[out,ref] uint32 *bytes_needed,
[out,ref] uint32 *service_returned,
- [in,out] uint32 *resume_handle,
+ [in,out,unique] uint32 *resume_handle,
[out,ref] [string,charset(UTF16)] uint16 **group_name
);
version(1.0),
endpoint("ncacn_np:[\\pipe\\winreg]","ncacn_ip_tcp:","ncalrpc:"),
pointer_default(unique),
- pointer_default_top(unique),
helpstring("Remote Registry Service")
] interface winreg
{
/******************/
/* Function: 0x00 */
WERROR winreg_OpenHKCR(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/******************/
/* Function: 0x01 */
WERROR winreg_OpenHKCU(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/******************/
/* Function: 0x02 */
WERROR winreg_OpenHKLM(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/******************/
/* Function: 0x03 */
WERROR winreg_OpenHKPD(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/******************/
/* Function: 0x04 */
WERROR winreg_OpenHKU(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/* Function: 0x0d */
WERROR winreg_LoadKey(
[in,ref] policy_handle *handle,
- [in] winreg_String *keyname,
- [in] winreg_String *filename
+ [in,unique] winreg_String *keyname,
+ [in,unique] winreg_String *filename
);
/******************/
WERROR winreg_QueryValue(
[in,ref] policy_handle *handle,
[in] winreg_String value_name,
- [in,out] winreg_Type *type,
- [in,out,size_is(*data_size),length_is(*value_length)] uint8 *data,
- [in,out] uint32 *data_size,
- [in,out] uint32 *value_length
+ [in,out,unique] winreg_Type *type,
+ [in,out,unique,size_is(*data_size),length_is(*value_length)] uint8 *data,
+ [in,out,unique] uint32 *data_size,
+ [in,out,unique] uint32 *value_length
);
/******************/
/******************/
/* Function: 0x18 */
WERROR winreg_InitiateSystemShutdown(
- [in] uint16 *hostname,
- [in] initshutdown_String *message,
+ [in,unique] uint16 *hostname,
+ [in,unique] initshutdown_String *message,
[in] uint32 timeout,
[in] uint8 force_apps,
[in] uint8 reboot
/******************/
/* Function: 0x19 */
WERROR winreg_AbortSystemShutdown(
- [in] uint16 *server
+ [in,unique] uint16 *server
);
/******************/
/******************/
/* Function: 0x1b */
WERROR winreg_OpenHKCC(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/******************/
/* Function: 0x1c */
WERROR winreg_OpenHKDD(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
[in,ref] policy_handle *key_handle,
[in,out,ref,size_is(num_values),length_is(num_values)] QueryMultipleValue *values,
[in] uint32 num_values,
- [in,out,size_is(*buffer_size),length_is(*buffer_size)] uint8 *buffer,
+ [in,out,unique,size_is(*buffer_size),length_is(*buffer_size)] uint8 *buffer,
[in,out,ref] uint32 *buffer_size
);
/******************/
/* Function: 0x1e */
WERROR winreg_InitiateSystemShutdownEx(
- [in] uint16 *hostname,
- [in] initshutdown_String *message,
+ [in,unique] uint16 *hostname,
+ [in,unique] initshutdown_String *message,
[in] uint32 timeout,
[in] uint8 force_apps,
[in] uint8 reboot,
/******************/
/* Function: 0x20 */
WERROR winreg_OpenHKPT(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
/******************/
/* Function: 0x21 */
WERROR winreg_OpenHKPN(
- [in] uint16 *system_name,
+ [in,unique] uint16 *system_name,
[in] winreg_AccessMask access_mask,
[out,ref] policy_handle *handle
);
[ uuid("6bffd098-a112-3610-9833-46c3f87e345a"),
version(1.0),
pointer_default(unique),
- pointer_default_top(unique),
helpstring("Workstation Service"),
endpoint("ncacn_np:[\\pipe\\wkssvc]","ncacn_ip_tcp:","ncalrpc:")
] interface wkssvc
} wkssvc_NetWkstaInfo;
WERROR wkssvc_NetWkstaGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] uint32 level,
[out,switch_is(level),ref] wkssvc_NetWkstaInfo *info
);
/******************/
/* Function: 0x01 */
WERROR wkssvc_NetWkstaSetInfo(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] uint32 level,
[in,switch_is(level),ref] wkssvc_NetWkstaInfo *info,
[in,out,ref] uint32 *parm_error
} wkssvc_NetWkstaEnumUsersInfo;
WERROR wkssvc_NetWkstaEnumUsers(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,out,ref] wkssvc_NetWkstaEnumUsersInfo *info,
[in] uint32 prefmaxlen,
[out,ref] uint32 *entries_read,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/*****************************/
} wkssvc_NetrWkstaUserInfo;
WERROR wkssvc_NetrWkstaUserGetInfo(
- [in] [string,charset(UTF16)] uint16 *unknown,
+ [in,unique] [string,charset(UTF16)] uint16 *unknown,
[in] uint32 level,
[out,ref] [switch_is(level)] wkssvc_NetrWkstaUserInfo *info
);
/*****************************/
/* Function 0x04 */
WERROR wkssvc_NetrWkstaUserSetInfo(
- [in] [string,charset(UTF16)] uint16 *unknown,
+ [in,unique] [string,charset(UTF16)] uint16 *unknown,
[in] uint32 level,
[in,ref] [switch_is(level)] wkssvc_NetrWkstaUserInfo *info,
- [in,out] uint32 *parm_err
+ [in,out,unique] uint32 *parm_err
);
/*****************************/
} wkssvc_NetWkstaTransportInfo;
WERROR wkssvc_NetWkstaTransportEnum (
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,out,ref] wkssvc_NetWkstaTransportInfo *info,
[in] uint32 max_buffer,
[out,ref] uint32 *total_entries,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/*****************************/
/* Function 0x06 */
/* only supported on NT */
WERROR wkssvc_NetrWkstaTransportAdd(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] uint32 level, /* must be 0 */
[in,ref] wkssvc_NetWkstaTransportInfo0 *info0,
- [in,out] uint32 *parm_err
+ [in,out,unique] uint32 *parm_err
);
/*****************************/
/* Function 0x07 */
/* only supported on NT */
WERROR wkssvc_NetrWkstaTransportDel(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *transport_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *transport_name,
[in] uint32 unknown3
);
} wkssvc_NetrUseGetInfoCtr;
WERROR wkssvc_NetrUseAdd(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] uint32 level,
[in,ref] [switch_is(level)] wkssvc_NetrUseGetInfoCtr *ctr,
- [in,out] uint32 *parm_err
+ [in,out,unique] uint32 *parm_err
);
/*****************************/
/* Function 0x09 */
WERROR wkssvc_NetrUseGetInfo(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *use_name,
[in] uint32 level,
[out,ref] [switch_is(level)] wkssvc_NetrUseGetInfoCtr *ctr
/*****************************/
/* Function 0x0a */
WERROR wkssvc_NetrUseDel(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *use_name,
[in] uint32 force_cond
);
} wkssvc_NetrUseEnumInfo;
WERROR wkssvc_NetrUseEnum(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,out,ref] wkssvc_NetrUseEnumInfo *info,
[in] uint32 prefmaxlen,
[out,ref] uint32 *entries_read,
- [in,out] uint32 *resume_handle
+ [in,out,unique] uint32 *resume_handle
);
/*****************************/
/* Function 0x0c */
WERROR wkssvc_NetrMessageBufferSend(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *message_name,
- [in] [string,charset(UTF16)] uint16 *message_sender_name,
+ [in,unique] [string,charset(UTF16)] uint16 *message_sender_name,
[in,ref] [size_is(message_size)] uint8 *message_buffer,
[in] uint32 message_size
);
} wkssvc_NetrWorkstationStatistics;
WERROR wkssvc_NetrWorkstationStatisticsGet(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *unknown2,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *unknown2,
[in] uint32 unknown3,
[in] uint32 unknown4,
[out,ref] wkssvc_NetrWorkstationStatistics **info
/*****************************/
/* Function 0x10 */
WERROR wkssvc_NetrJoinDomain(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *domain_name,
- [in] [string,charset(UTF16)] uint16 *account_ou,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] [string,charset(UTF16)] uint16 *password,
+ [in,unique] [string,charset(UTF16)] uint16 *account_ou,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] [string,charset(UTF16)] uint16 *password,
[in] wkssvc_joinflags join_flags
);
/*****************************/
/* Function 0x11 */
WERROR wkssvc_NetrUnjoinDomain(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] [string,charset(UTF16)] uint16 *password,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] [string,charset(UTF16)] uint16 *password,
[in] wkssvc_joinflags unjoin_flags
);
} wkssvc_renameflags;
WERROR wkssvc_NetrRenameMachineInDomain(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *NewMachineName,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] [string,charset(UTF16)] uint16 *password,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *NewMachineName,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] [string,charset(UTF16)] uint16 *password,
[in] wkssvc_renameflags RenameOptions
);
} wkssvc_NetValidateNameType;
WERROR wkssvc_NetrValidateName(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *name,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] [string,charset(UTF16)] uint16 *Password,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] [string,charset(UTF16)] uint16 *Password,
[in] wkssvc_NetValidateNameType name_type
);
} wkssvc_NetJoinStatus;
WERROR wkssvc_NetrGetJoinInformation(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,out,ref] [string,charset(UTF16)] uint16 **name_buffer,
[out,ref] wkssvc_NetJoinStatus *name_type
);
/*****************************/
/* Function 0x15 */
WERROR wkssvc_NetrGetJoinableOus(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *domain_name,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] [string,charset(UTF16)] uint16 *unknown,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] [string,charset(UTF16)] uint16 *unknown,
[in,out,ref] uint32 *num_ous,
[out,ref] [size_is(*num_ous)] [string,charset(UTF16)] uint16 ***ous
);
/*****************************/
/* Function 0x16 */
WERROR wkssvc_NetrJoinDomain2 (
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *domain_name,
- [in] [string,charset(UTF16)] uint16 *account_ou,
- [in] [string,charset(UTF16)] uint16 *admin_account,
- [in] wkssvc_PasswordBuffer *encrypted_password,
+ [in,unique] [string,charset(UTF16)] uint16 *account_ou,
+ [in,unique] [string,charset(UTF16)] uint16 *admin_account,
+ [in,unique] wkssvc_PasswordBuffer *encrypted_password,
[in] wkssvc_joinflags join_flags
);
/*****************************/
/* Function 0x17 */
WERROR wkssvc_NetrUnjoinDomain2 (
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *account,
- [in] wkssvc_PasswordBuffer *encrypted_password,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *account,
+ [in,unique] wkssvc_PasswordBuffer *encrypted_password,
[in] wkssvc_joinflags unjoin_flags
);
/*****************************/
/* Function 0x18 */
WERROR wkssvc_NetrRenameMachineInDomain2(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *NewMachineName,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *NewMachineName,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
[in] wkssvc_renameflags RenameOptions
);
/*****************************/
/* Function 0x19 */
WERROR wkssvc_NetrValidateName2(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *name,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
[in] wkssvc_NetValidateNameType name_type
);
/*****************************/
/* Function 0x1a */
WERROR wkssvc_NetrGetJoinableOus2(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in,ref] [string,charset(UTF16)] uint16 *domain_name,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
[in,out,ref] uint32 *num_ous,
[out,ref] [size_is(*num_ous)] [string,charset(UTF16)] uint16 ***ous
);
/*****************************/
/* Function 0x1b */
WERROR wkssvc_NetrAddAlternateComputerName(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *NewAlternateMachineName,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *NewAlternateMachineName,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
[in] uint32 Reserved
);
/*****************************/
/* Function 0x1c */
WERROR wkssvc_NetrRemoveAlternateComputerName(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *AlternateMachineNameToRemove,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *AlternateMachineNameToRemove,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
[in] uint32 Reserved
);
/*****************************/
/* Function 0x1d */
WERROR wkssvc_NetrSetPrimaryComputername(
- [in] [string,charset(UTF16)] uint16 *server_name,
- [in] [string,charset(UTF16)] uint16 *primary_name,
- [in] [string,charset(UTF16)] uint16 *Account,
- [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *primary_name,
+ [in,unique] [string,charset(UTF16)] uint16 *Account,
+ [in,unique] wkssvc_PasswordBuffer *EncryptedPassword,
[in] uint32 Reserved
);
} wkssvc_ComputerNamesCtr;
WERROR wkssvc_NetrEnumerateComputerNames(
- [in] [string,charset(UTF16)] uint16 *server_name,
+ [in,unique] [string,charset(UTF16)] uint16 *server_name,
[in] wkssvc_ComputerNameType name_type,
[in] uint32 Reserved,
[out,ref] wkssvc_ComputerNamesCtr **ctr
static ssize_t client_receive_smb(struct cli_state *cli, size_t maxlen)
{
- ssize_t len;
+ size_t len;
for(;;) {
- len = receive_smb_raw(cli->fd, cli->inbuf, cli->timeout,
- maxlen, &cli->smb_rw_error);
+ NTSTATUS status;
- if (len < 0) {
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
+
+ status = receive_smb_raw(cli->fd, cli->inbuf, cli->timeout,
+ maxlen, &len);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("client_receive_smb failed\n"));
show_msg(cli->inbuf);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
+ set_smb_read_error(&cli->smb_rw_error,
+ SMB_READ_EOF);
+ return -1;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ set_smb_read_error(&cli->smb_rw_error,
+ SMB_READ_TIMEOUT);
+ return -1;
+ }
+
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR);
+ return -1;
+ }
+
+ if (len < 0) {
return len;
}
ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len)
{
- return read_socket_with_timeout(cli->fd, buffer, len, len,
- cli->timeout, &cli->smb_rw_error);
+ NTSTATUS status;
+
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
+
+ status = read_socket_with_timeout(
+ cli->fd, buffer, len, len, cli->timeout, NULL);
+ if (NT_STATUS_IS_OK(status)) {
+ return len;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_EOF);
+ return -1;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_TIMEOUT);
+ return -1;
+ }
+
+ set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR);
+ return -1;
}
/****************************************************************************
DEBUGLEVEL = -1;
while (1) {
- if (read_data(fd_in, (char *)&r, sizeof(r), NULL) != sizeof(r))
+ NTSTATUS status;
+
+ status = read_data(fd_in, (char *)&r, sizeof(r));
+
+ if (!NT_STATUS_IS_OK(status)) {
break;
+ }
pull_ascii_nstring( qname, sizeof(qname), r.name.name);
r.result.s_addr = interpret_addr(qname);
struct query_record r;
struct packet_struct *p, *p2;
struct name_record *namerec;
- int size;
+ NTSTATUS status;
if (fd_in == -1)
return;
start_async_dns();
}
- if ((size=read_data(fd_in, (char *)&r, sizeof(r), NULL)) != sizeof(r)) {
- if (size) {
- DEBUG(0,("Incomplete DNS answer from child!\n"));
- fd_in = -1;
- }
+ status = read_data(fd_in, (char *)&r, sizeof(r));
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("read from child failed: %s\n", nt_errstr(status)));
+ fd_in = -1;
BlockSignals(True, SIGTERM);
return;
}
#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
#define PAM_SM_PASSWORD
+#define PAM_SM_SESSION
#ifndef PAM_WINBIND_CONFIG_FILE
#define PAM_WINBIND_CONFIG_FILE "/etc/security/pam_winbind.conf"
}
sep = response.data.info.winbind_separator;
- got_sep = True;
+ got_sep = true;
if (!sep) {
d_fprintf(stderr, "winbind separator was NULL!\n");
static char winbind_separator(void)
{
- return winbind_separator_int(False);
+ return winbind_separator_int(false);
}
static const char *get_winbind_domain(void)
{
- wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcDomainInfo *dinfo = NULL;
static fstring winbind_domain;
ZERO_STRUCT(dinfo);
-
+
wbc_status = wbcDomainInfo(".", &dinfo);
if (!WBC_ERROR_IS_OK(wbc_status)) {
d_fprintf(stderr, "could not obtain winbind domain name!\n");
-
+
/* HACK: (this module should not call lp_ funtions) */
return lp_workgroup();
}
- fstrcpy(winbind_domain, dinfo->short_name);
+ fstrcpy(winbind_domain, dinfo->short_name);
wbcFreeMemory(dinfo);
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
form DOMAIN/user into a domain and a user */
-static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
+static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
fstring user)
{
if ((p = strchr(domuser, '@')) != NULL) {
fstrcpy(domain, "");
fstrcpy(user, domuser);
- return True;
+ return true;
}
-
+
fstrcpy(user, domuser);
fstrcpy(domain, get_winbind_domain());
- return True;
+ return true;
}
-
+
fstrcpy(user, p+1);
fstrcpy(domain, domuser);
domain[PTR_DIFF(p, domuser)] = 0;
strupper_m(domain);
- return True;
+ return true;
}
/* pull pwent info for a given user */
static bool wbinfo_get_userinfo(char *user)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
- struct passwd *pwd = NULL;
+ struct passwd *pwd = NULL;
wbc_status = wbcGetpwnam(user, &pwd);
if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
}
-
+
d_printf("%s:%s:%d:%d:%s:%s:%s\n",
pwd->pw_name,
pwd->pw_passwd,
pwd->pw_gecos,
pwd->pw_dir,
pwd->pw_shell);
-
+
return true;
}
static bool wbinfo_get_uidinfo(int uid)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
- struct passwd *pwd = NULL;
+ struct passwd *pwd = NULL;
wbc_status = wbcGetpwuid(uid, &pwd);
if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
}
-
+
d_printf("%s:%s:%d:%d:%s:%s:%s\n",
pwd->pw_name,
pwd->pw_passwd,
pwd->pw_gecos,
pwd->pw_dir,
pwd->pw_shell);
-
+
return true;
}
&response);
if ( result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
- d_printf( "%s:%s:%d\n",
+ d_printf( "%s:%s:%d\n",
response.data.gr.gr_name,
response.data.gr.gr_passwd,
response.data.gr.gr_gid );
-
- return True;
+
+ return true;
}
/* List groups a user is a member of */
struct winbindd_response response;
NSS_STATUS result;
int i;
-
+
ZERO_STRUCT(request);
ZERO_STRUCT(response);
result = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
for (i = 0; i < response.data.num_entries; i++)
d_printf("%d\n", (int)((gid_t *)response.extra_data.data)[i]);
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
s = (const char *)response.extra_data.data;
for (i = 0; i < response.data.num_entries; i++) {
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
static bool wbinfo_get_userdomgroups(const char *user_sid)
fstrcpy(request.data.sid, user_sid);
result = winbindd_request_response(WINBINDD_GETUSERDOMGROUPS, &request,
- &response);
+ &response);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
if (response.data.num_entries != 0)
printf("%s", (char *)response.extra_data.data);
-
+
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
/* Convert NetBIOS name to IP */
if (winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.winsresp);
- return True;
+ return true;
}
/* Convert IP to NetBIOS name */
if (winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response) !=
NSS_STATUS_SUCCESS) {
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.winsresp);
- return True;
+ return true;
}
/* List trusted domains */
if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
extra_data);
TALLOC_FREE(frame);
SAFE_FREE(response.extra_data.data);
- return False;
+ return false;
}
*p = 0;
d_printf("%s\n", name);
SAFE_FREE(response.extra_data.data);
}
- return True;
+ return true;
}
/* List own domain */
{
d_printf("%s\n", get_winbind_domain());
- return True;
+ return true;
}
/* show sequence numbers */
if (winbindd_request_response(WINBINDD_SHOW_SEQUENCE, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
SAFE_FREE(response.extra_data.data);
}
- return True;
+ return true;
}
/* Show domain info */
if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("Primary : %s\n",
response.data.domain_info.primary ? "Yes" : "No");
- return True;
+ return true;
}
/* Get a foreign DC's name */
if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not get dc name for %s\n", domain_name);
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.dc_name);
- return True;
+ return true;
}
/* Find a DC */
if (winbindd_request_response(WINBINDD_DSGETDCNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not find dc for %s\n", domain_name);
- return False;
+ return false;
}
/* Display response */
d_printf("%s\n", response.data.dc_name);
- return True;
+ return true;
}
/* Check trust account password */
static bool wbinfo_check_secret(void)
{
- struct winbindd_response response;
- NSS_STATUS result;
+ struct winbindd_response response;
+ NSS_STATUS result;
- ZERO_STRUCT(response);
+ ZERO_STRUCT(response);
- result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
-
- d_printf("checking the trust secret via RPC calls %s\n",
+ result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
+
+ d_printf("checking the trust secret via RPC calls %s\n",
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
- if (result != NSS_STATUS_SUCCESS)
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- response.data.auth.nt_status_string,
+ if (result != NSS_STATUS_SUCCESS)
+ d_fprintf(stderr, "error code was %s (0x%x)\n",
+ response.data.auth.nt_status_string,
response.data.auth.nt_status);
-
+
return result == NSS_STATUS_SUCCESS;
}
if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%s\n", response.data.sid.sid);
- return True;
+ return true;
}
/* Convert gid to sid */
if (winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%s\n", response.data.sid.sid);
- return True;
+ return true;
}
/* Convert sid to uid */
if (winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%d\n", (int)response.data.uid);
- return True;
+ return true;
}
static bool wbinfo_sid_to_gid(char *sid)
if (winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%d\n", (int)response.data.gid);
- return True;
+ return true;
}
static bool wbinfo_allocate_uid(void)
uid_t uid;
if (!winbind_allocate_uid(&uid))
- return False;
+ return false;
d_printf("New uid: %d\n", uid);
- return True;
+ return true;
}
static bool wbinfo_allocate_gid(void)
gid_t gid;
if (!winbind_allocate_gid(&gid))
- return False;
+ return false;
d_printf("New gid: %d\n", gid);
- return True;
+ return true;
}
/* Convert sid to string */
if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
- d_printf("%s%c%s %d\n", response.data.name.dom_name,
- winbind_separator(), response.data.name.name,
+ d_printf("%s%c%s %d\n", response.data.name.dom_name,
+ winbind_separator(), response.data.name.name,
response.data.name.type);
- return True;
+ return true;
}
/* Lookup a list of RIDs */
if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
NSS_STATUS_SUCCESS) {
d_printf("Could not get domain sid for %s\n", request.domain_name);
- return False;
+ return false;
}
if (!string_to_sid(&sid, response.data.domain_info.sid)) {
d_printf("Could not convert %s to sid\n", response.data.domain_info.sid);
- return False;
+ return false;
}
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
d_printf("talloc_new failed\n");
- return False;
+ return false;
}
num_rids = 0;
if (rids == NULL) {
TALLOC_FREE(mem_ctx);
- return False;
+ return false;
}
if (!winbind_lookup_rids(mem_ctx, &sid, num_rids, rids,
&domain_name, &names, &types)) {
d_printf("winbind_lookup_rids failed\n");
TALLOC_FREE(mem_ctx);
- return False;
+ return false;
}
d_printf("Domain: %s\n", domain_name);
}
TALLOC_FREE(mem_ctx);
- return True;
+ return true;
}
/* Convert string to sid */
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- parse_wbinfo_domain_user(name, request.data.name.dom_name,
+ parse_wbinfo_domain_user(name, request.data.name.dom_name,
request.data.name.name);
if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Display response */
d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
- return True;
+ return true;
}
/* Authenticate a user with a plaintext password */
static bool wbinfo_auth(char *username)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
- char *s = NULL;
- char *p = NULL;
- char *password = NULL;
- char *name = NULL;
+ char *s = NULL;
+ char *p = NULL;
+ const char *password = NULL;
+ char *name = NULL;
if ((s = SMB_STRDUP(username)) == NULL) {
return false;
}
if ((p = strchr(s, '%')) != NULL) {
- *p = 0;
+ *p = 0;
p++;
+ password = p;
+ } else {
+ password = "";
}
name = s;
- password = p;
wbc_status = wbcAuthenticateUser(name, password);
- d_printf("plaintext password authentication %s\n",
+ d_printf("plaintext password authentication %s\n",
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
#if 0
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
- response.data.auth.nt_status_string,
+ response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
#endif
SAFE_FREE(s);
- return WBC_ERROR_IS_OK(wbc_status);
+ return WBC_ERROR_IS_OK(wbc_status);
}
/* Authenticate a user with a challenge/response */
{
struct winbindd_request request;
struct winbindd_response response;
- NSS_STATUS result;
- fstring name_user;
- fstring name_domain;
- fstring pass;
- char *p;
+ NSS_STATUS result;
+ fstring name_user;
+ fstring name_domain;
+ fstring pass;
+ char *p;
/* Send off request */
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- p = strchr(username, '%');
+ p = strchr(username, '%');
- if (p) {
- *p = 0;
- fstrcpy(pass, p + 1);
+ if (p) {
+ *p = 0;
+ fstrcpy(pass, p + 1);
}
parse_wbinfo_domain_user(username, name_domain, name_user);
fstrcpy(request.data.auth_crap.user, name_user);
- fstrcpy(request.data.auth_crap.domain,
- name_domain);
+ fstrcpy(request.data.auth_crap.domain, name_domain);
generate_random_buffer(request.data.auth_crap.chal, 8);
-
+
if (lp_client_ntlmv2_auth()) {
DATA_BLOB server_chal;
- DATA_BLOB names_blob;
+ DATA_BLOB names_blob;
DATA_BLOB lm_response;
DATA_BLOB nt_response;
- server_chal = data_blob(request.data.auth_crap.chal, 8);
-
+ server_chal = data_blob(request.data.auth_crap.chal, 8);
+
/* Pretend this is a login to 'us', for blob purposes */
names_blob = NTLMv2_generate_names_blob(global_myname(), lp_workgroup());
-
- if (!SMBNTLMv2encrypt(name_user, name_domain, pass, &server_chal,
+
+ if (!SMBNTLMv2encrypt(name_user, name_domain, pass, &server_chal,
&names_blob,
&lm_response, &nt_response, NULL)) {
data_blob_free(&names_blob);
data_blob_free(&server_chal);
- return False;
+ return false;
}
data_blob_free(&names_blob);
data_blob_free(&server_chal);
- memcpy(request.data.auth_crap.nt_resp, nt_response.data,
- MIN(nt_response.length,
+ memcpy(request.data.auth_crap.nt_resp, nt_response.data,
+ MIN(nt_response.length,
sizeof(request.data.auth_crap.nt_resp)));
request.data.auth_crap.nt_resp_len = nt_response.length;
- memcpy(request.data.auth_crap.lm_resp, lm_response.data,
- MIN(lm_response.length,
+ memcpy(request.data.auth_crap.lm_resp, lm_response.data,
+ MIN(lm_response.length,
sizeof(request.data.auth_crap.lm_resp)));
request.data.auth_crap.lm_resp_len = lm_response.length;
-
+
data_blob_free(&nt_response);
data_blob_free(&lm_response);
} else {
- if (lp_client_lanman_auth()
- && SMBencrypt(pass, request.data.auth_crap.chal,
+ if (lp_client_lanman_auth()
+ && SMBencrypt(pass, request.data.auth_crap.chal,
(uchar *)request.data.auth_crap.lm_resp)) {
request.data.auth_crap.lm_resp_len = 24;
} else {
/* Display response */
- d_printf("challenge/response password authentication %s\n",
- (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
+ d_printf("challenge/response password authentication %s\n",
+ (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
- response.data.auth.nt_status_string,
+ response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
- return result == NSS_STATUS_SUCCESS;
+ return result == NSS_STATUS_SUCCESS;
}
/* Authenticate a user with a plaintext password and set a token */
{
struct winbindd_request request;
struct winbindd_response response;
- NSS_STATUS result;
- char *p;
+ NSS_STATUS result;
+ char *p;
/* Send off request */
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- p = strchr(username, '%');
+ p = strchr(username, '%');
- if (p) {
- *p = 0;
- fstrcpy(request.data.auth.user, username);
- fstrcpy(request.data.auth.pass, p + 1);
- *p = '%';
- } else {
- fstrcpy(request.data.auth.user, username);
+ if (p) {
+ *p = 0;
+ fstrcpy(request.data.auth.user, username);
+ fstrcpy(request.data.auth.pass, p + 1);
+ *p = '%';
+ } else {
+ fstrcpy(request.data.auth.user, username);
fstrcpy(request.data.auth.pass, getpass("Password: "));
}
/* Display response */
- d_printf("plaintext password authentication %s\n",
- (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
+ d_printf("plaintext password authentication %s\n",
+ (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
- response.data.auth.nt_status_string,
+ response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
if (result != NSS_STATUS_SUCCESS)
- return False;
+ return false;
if (response.extra_data.data == NULL) {
d_fprintf(stderr, "Did not get token data\n");
- return False;
+ return false;
}
if (!afs_settoken_str((char *)response.extra_data.data)) {
d_fprintf(stderr, "Could not set token\n");
- return False;
+ return false;
}
d_printf("Successfully created AFS token\n");
- return True;
+ return true;
}
/* Print domain users */
if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Look through extra data */
if (!response.extra_data.data)
- return False;
+ return false;
extra_data = (const char *)response.extra_data.data;
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
/* Print domain groups */
if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
NSS_STATUS_SUCCESS)
- return False;
+ return false;
/* Look through extra data */
if (!response.extra_data.data)
- return False;
+ return false;
extra_data = (const char *)response.extra_data.data;
SAFE_FREE(response.extra_data.data);
- return True;
+ return true;
}
/* Set the authorised user for winbindd access in secrets.tdb */
} else {
char *thepass = getpass("Password: ");
if (thepass) {
- password = thepass;
+ password = thepass;
} else
password = "";
}
if (!secrets_store(SECRETS_AUTH_USER, user,
strlen(user) + 1)) {
d_fprintf(stderr, "error storing username\n");
- return False;
+ return false;
}
/* We always have a domain name added by the
if (!secrets_store(SECRETS_AUTH_DOMAIN, domain,
strlen(domain) + 1)) {
d_fprintf(stderr, "error storing domain name\n");
- return False;
+ return false;
}
} else {
if (!secrets_store(SECRETS_AUTH_PASSWORD, password,
strlen(password) + 1)) {
d_fprintf(stderr, "error storing password\n");
- return False;
+ return false;
}
} else
secrets_delete(SECRETS_AUTH_PASSWORD);
- return True;
+ return true;
}
static void wbinfo_get_auth_user(void)
char *user, *domain, *password;
/* Lift data from secrets file */
-
+
secrets_fetch_ipc_userpass(&user, &domain, &password);
if ((!user || !*user) && (!domain || !*domain ) && (!password || !*password)){
/* Display response */
- d_printf("Ping to winbindd %s on fd %d\n",
- (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", winbindd_fd);
+ d_printf("Ping to winbindd %s on fd %d\n",
+ (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", winbindd_fd);
- return result == NSS_STATUS_SUCCESS;
+ return result == NSS_STATUS_SUCCESS;
}
/* Main program */
int main(int argc, char **argv, char **envp)
{
int opt;
- TALLOC_CTX *frame = talloc_stackframe();
+ TALLOC_CTX *frame = talloc_stackframe();
poptContext pc;
static char *string_arg;
static char *opt_domain_name;
struct poptOption long_options[] = {
POPT_AUTOHELP
- /* longName, shortName, argInfo, argPtr, value, descrip,
+ /* longName, shortName, argInfo, argPtr, value, descrip,
argDesc */
{ "domain-users", 'u', POPT_ARG_NONE, 0, 'u', "Lists all domain users", "domain"},
poptFreeContext(pc);
- if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, True)) {
+ if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, true)) {
d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
get_dyn_CONFIGFILE(), strerror(errno));
exit(1);
}
break;
case 'm':
- if (!wbinfo_list_domains(False)) {
+ if (!wbinfo_list_domains(false)) {
d_fprintf(stderr, "Could not list trusted domains\n");
goto done;
}
}
break;
case 'a': {
- bool got_error = False;
+ bool got_error = false;
if (!wbinfo_auth(string_arg)) {
d_fprintf(stderr, "Could not authenticate user %s with "
"plaintext password\n", string_arg);
- got_error = True;
+ got_error = true;
}
if (!wbinfo_auth_crap(string_arg)) {
d_fprintf(stderr, "Could not authenticate user %s with "
"challenge/response\n", string_arg);
- got_error = True;
+ got_error = true;
}
if (got_error)
}
break;
case OPT_SEPARATOR: {
- const char sep = winbind_separator_int(True);
+ const char sep = winbind_separator_int(true);
if ( !sep ) {
goto done;
}
break;
}
case OPT_LIST_ALL_DOMAINS:
- if (!wbinfo_list_domains(True)) {
+ if (!wbinfo_list_domains(true)) {
goto done;
}
break;
return "AF_UNSPEC";
case AF_INET:
return "AF_INET";
-#if defined(HAVE_IPv6)
+#if defined(HAVE_IPV6)
case AF_INET6:
return "AF_INET6";
#endif
case AF_UNSPEC:
case AF_INET:
break;
-#if defined(HAVE_IPv6)
- case AF_INET6: /* not yet */
- return KRB5_PLUGIN_NO_HANDLE;
+#if defined(HAVE_IPV6)
+ case AF_INET6:
+ break;
#endif
default:
return EINVAL;
Globals.bWinbindTrustedDomainsOnly = False;
Globals.bWinbindNestedGroups = True;
Globals.winbind_expand_groups = 1;
- Globals.szWinbindNssInfo = str_list_make("template", NULL);
+ Globals.szWinbindNssInfo = str_list_make(NULL, "template", NULL);
Globals.bWinbindRefreshTickets = False;
Globals.bWinbindOfflineLogon = False;
return (const char **)def;
if (data->list==NULL) {
- data->list = str_list_make(data->value, NULL);
+ data->list = str_list_make(NULL, data->value, NULL);
}
return (const char **)data->list;
PTR_DIFF(parm_table[i].ptr, &sDefault)));
else if (parm_table[i].type == P_LIST &&
parm_table[i].p_class == P_LOCAL)
- str_list_free((char ***)
- (((char *)pservice) +
- PTR_DIFF(parm_table[i].ptr, &sDefault)));
+ TALLOC_FREE(*((char ***)
+ (((char *)pservice) +
+ PTR_DIFF(parm_table[i].ptr,
+ &sDefault))));
}
data = pservice->param_opt;
DEBUG(5,("[%s = %s]\n", data->key, data->value));
string_free(&data->key);
string_free(&data->value);
- str_list_free(&data->list);
+ TALLOC_FREE(data->list);
pdata = data->next;
SAFE_FREE(data);
data = pdata;
while (data) {
string_free(&data->key);
string_free(&data->value);
- str_list_free(&data->list);
+ TALLOC_FREE(data->list);
pdata = data->next;
SAFE_FREE(data);
data = pdata;
strupper_m(*(char **)dest_ptr);
break;
case P_LIST:
- str_list_free((char ***)dest_ptr);
- str_list_copy((char ***)dest_ptr, *(const char ***)src_ptr);
+ TALLOC_FREE(*((char ***)dest_ptr));
+ str_list_copy(NULL, (char ***)dest_ptr,
+ *(const char ***)src_ptr);
break;
default:
break;
/* If we already have same option, override it */
if (strcmp(pdata->key, data->key) == 0) {
string_free(&pdata->value);
- str_list_free(&data->list);
+ TALLOC_FREE(data->list);
pdata->value = SMB_STRDUP(data->value);
not_added = False;
break;
static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
{
- str_list_free(&Globals.szNetbiosAliases);
- Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
+ TALLOC_FREE(Globals.szNetbiosAliases);
+ Globals.szNetbiosAliases = str_list_make(NULL, pszParmValue, NULL);
return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
}
/* If we already have same option, override it */
if (strcmp(data->key, param_key) == 0) {
string_free(&data->value);
- str_list_free(&data->list);
+ TALLOC_FREE(data->list);
data->value = SMB_STRDUP(pszParmValue);
not_added = False;
break;
break;
case P_LIST:
- str_list_free((char ***)parm_ptr);
- *(char ***)parm_ptr = str_list_make(pszParmValue, NULL);
+ TALLOC_FREE(*((char ***)parm_ptr));
+ *(char ***)parm_ptr = str_list_make(
+ NULL, pszParmValue, NULL);
break;
case P_STRING:
continue;
switch (parm_table[i].type) {
case P_LIST:
- str_list_copy(&(parm_table[i].def.lvalue),
- *(const char ***)parm_table[i].ptr);
+ str_list_copy(
+ NULL, &(parm_table[i].def.lvalue),
+ *(const char ***)parm_table[i].ptr);
break;
case P_STRING:
case P_USTRING:
string_free( (char**)parm_table[i].ptr );
}
else if (parm_table[i].type == P_LIST) {
- str_list_free( (char***)parm_table[i].ptr );
+ TALLOC_FREE( *((char***)parm_table[i].ptr) );
}
}
}
while (data) {
string_free(&data->key);
string_free(&data->value);
- str_list_free(&data->list);
+ TALLOC_FREE(data->list);
pdata = data->next;
SAFE_FREE(data);
data = pdata;
if (*domain_name == NULL) {
*domain_name = talloc_strdup(
mem_ctx, unix_users_domain_name());
+ if (*domain_name == NULL) {
+ return false;
+ }
}
for (i=0; i<num_rids; i++) {
(*names)[i] = talloc_strdup(
(*names), uidtoname(rids[i]));
+ if ((*names)[i] == NULL) {
+ return false;
+ }
(*types)[i] = SID_NAME_USER;
}
return true;
if (*domain_name == NULL) {
*domain_name = talloc_strdup(
mem_ctx, unix_groups_domain_name());
+ if (*domain_name == NULL) {
+ return false;
+ }
}
for (i=0; i<num_rids; i++) {
(*names)[i] = talloc_strdup(
(*names), gidtoname(rids[i]));
+ if ((*names)[i] == NULL) {
+ return false;
+ }
(*types)[i] = SID_NAME_DOM_GRP;
}
return true;
int algorithmic_rid_base(void)
{
- static int rid_offset = 0;
-
- if (rid_offset != 0)
- return rid_offset;
+ int rid_offset;
rid_offset = lp_algorithmic_rid_base();
return false;
}
- *entry = state->entries[state->current++];
+ entry->idx = state->entries[state->current].idx;
+ entry->rid = state->entries[state->current].rid;
+ entry->acct_flags = state->entries[state->current].acct_flags;
+
+ entry->account_name = talloc_strdup(
+ search->mem_ctx, state->entries[state->current].account_name);
+ entry->fullname = talloc_strdup(
+ search->mem_ctx, state->entries[state->current].fullname);
+ entry->description = talloc_strdup(
+ search->mem_ctx, state->entries[state->current].description);
+
+ if ((entry->account_name == NULL) || (entry->fullname == NULL)
+ || (entry->description == NULL)) {
+ DEBUG(0, ("talloc_strdup failed\n"));
+ return false;
+ }
+ state->current += 1;
return true;
}
return result;
}
-/** Query LSA security object */
-
-NTSTATUS rpccli_lsa_query_secobj(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 sec_info,
- SEC_DESC_BUF **psdb)
-{
- prs_struct qbuf, rbuf;
- LSA_Q_QUERY_SEC_OBJ q;
- LSA_R_QUERY_SEC_OBJ r;
- NTSTATUS result;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_q_query_sec_obj(&q, pol, sec_info);
-
- CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_QUERYSECOBJ,
- q, r,
- qbuf, rbuf,
- lsa_io_q_query_sec_obj,
- lsa_io_r_query_sec_obj,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
- }
-
- /* Return output parameters */
-
- if (psdb)
- *psdb = r.buf;
-
- done:
-
- return result;
-}
-
-
/* Enumerate account rights This is similar to enum_privileges but
takes a SID directly, avoiding the open_account call.
*/
#include "includes.h"
-/* Connect to SAMR database */
-
-NTSTATUS rpccli_samr_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- uint32 access_mask, POLICY_HND *connect_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_CONNECT q;
- SAMR_R_CONNECT r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_connect to %s\n", cli->cli->desthost));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_connect(&q, cli->cli->desthost, access_mask);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CONNECT,
- q, r,
- qbuf, rbuf,
- samr_io_q_connect,
- samr_io_r_connect,
- NT_STATUS_UNSUCCESSFUL);
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *connect_pol = r.connect_pol;
-#ifdef __INSURE__
- connect_pol->marker = malloc(1);
-#endif
- }
-
- return result;
-}
-
-/* Connect to SAMR database */
-
-NTSTATUS rpccli_samr_connect4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- uint32 access_mask, POLICY_HND *connect_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_CONNECT4 q;
- SAMR_R_CONNECT4 r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_connect4(&q, cli->cli->desthost, access_mask);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CONNECT4,
- q, r,
- qbuf, rbuf,
- samr_io_q_connect4,
- samr_io_r_connect4,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *connect_pol = r.connect_pol;
-#ifdef __INSURE__
- connect_pol->marker = malloc(1);
-#endif
- }
-
- return result;
-}
-
-/* Open handle on a domain */
-
-NTSTATUS rpccli_samr_open_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *connect_pol, uint32 access_mask,
- const DOM_SID *domain_sid,
- POLICY_HND *domain_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_OPEN_DOMAIN q;
- SAMR_R_OPEN_DOMAIN r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_open_domain with sid %s\n",
- sid_string_dbg(domain_sid) ));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_open_domain(&q, connect_pol, access_mask, domain_sid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_DOMAIN,
- q, r,
- qbuf, rbuf,
- samr_io_q_open_domain,
- samr_io_r_open_domain,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *domain_pol = r.domain_pol;
-#ifdef __INSURE__
- domain_pol->marker = malloc(1);
-#endif
- }
-
- return result;
-}
-
-NTSTATUS rpccli_samr_open_user(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 access_mask,
- uint32 user_rid, POLICY_HND *user_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_OPEN_USER q;
- SAMR_R_OPEN_USER r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_open_user with rid 0x%x\n", user_rid ));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_open_user(&q, domain_pol, access_mask, user_rid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_USER,
- q, r,
- qbuf, rbuf,
- samr_io_q_open_user,
- samr_io_r_open_user,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *user_pol = r.user_pol;
-#ifdef __INSURE__
- user_pol->marker = malloc(1);
-#endif
- }
-
- return result;
-}
-
-/* Open handle on a group */
-
-NTSTATUS rpccli_samr_open_group(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 access_mask,
- uint32 group_rid, POLICY_HND *group_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_OPEN_GROUP q;
- SAMR_R_OPEN_GROUP r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_open_group with rid 0x%x\n", group_rid ));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_open_group(&q, domain_pol, access_mask, group_rid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_GROUP,
- q, r,
- qbuf, rbuf,
- samr_io_q_open_group,
- samr_io_r_open_group,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *group_pol = r.pol;
-#ifdef __INSURE__
- group_pol->marker = malloc(1);
-#endif
- }
-
- return result;
-}
-
-/* Create domain group */
-
-NTSTATUS rpccli_samr_create_dom_group(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- const char *group_name,
- uint32 access_mask, POLICY_HND *group_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_CREATE_DOM_GROUP q;
- SAMR_R_CREATE_DOM_GROUP r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_create_dom_group\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_create_dom_group(&q, domain_pol, group_name, access_mask);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CREATE_DOM_GROUP,
- q, r,
- qbuf, rbuf,
- samr_io_q_create_dom_group,
- samr_io_r_create_dom_group,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (NT_STATUS_IS_OK(result))
- *group_pol = r.pol;
-
- return result;
-}
-
-/* Add a domain group member */
-
-NTSTATUS rpccli_samr_add_groupmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *group_pol, uint32 rid)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_ADD_GROUPMEM q;
- SAMR_R_ADD_GROUPMEM r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_add_groupmem\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_add_groupmem(&q, group_pol, rid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ADD_GROUPMEM,
- q, r,
- qbuf, rbuf,
- samr_io_q_add_groupmem,
- samr_io_r_add_groupmem,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
-/* Delete a domain group member */
-
-NTSTATUS rpccli_samr_del_groupmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *group_pol, uint32 rid)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_DEL_GROUPMEM q;
- SAMR_R_DEL_GROUPMEM r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_del_groupmem\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_del_groupmem(&q, group_pol, rid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DEL_GROUPMEM,
- q, r,
- qbuf, rbuf,
- samr_io_q_del_groupmem,
- samr_io_r_del_groupmem,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
/* Query user info */
NTSTATUS rpccli_samr_query_userinfo(struct rpc_pipe_client *cli,
return result;
}
-/* Query user aliases */
-
-NTSTATUS rpccli_samr_query_useraliases(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *dom_pol, uint32 num_sids,
- DOM_SID2 *sid,
- uint32 *num_aliases, uint32 **als_rids)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_USERALIASES q;
- SAMR_R_QUERY_USERALIASES r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- int i;
- uint32 *sid_ptrs;
-
- DEBUG(10,("cli_samr_query_useraliases\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- if (num_sids) {
- sid_ptrs = TALLOC_ARRAY(mem_ctx, uint32, num_sids);
- if (sid_ptrs == NULL)
- return NT_STATUS_NO_MEMORY;
- } else {
- sid_ptrs = NULL;
- }
-
- for (i=0; i<num_sids; i++)
- sid_ptrs[i] = 1;
-
- /* Marshall data and send request */
-
- init_samr_q_query_useraliases(&q, dom_pol, num_sids, sid_ptrs, sid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_USERALIASES,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_useraliases,
- samr_io_r_query_useraliases,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *num_aliases = r.num_entries;
- *als_rids = r.rid;
- }
-
- return result;
-}
-
-/* Query user groups */
-
-NTSTATUS rpccli_samr_query_groupmem(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *group_pol, uint32 *num_mem,
- uint32 **rid, uint32 **attr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_GROUPMEM q;
- SAMR_R_QUERY_GROUPMEM r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_groupmem\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_query_groupmem(&q, group_pol);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_GROUPMEM,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_groupmem,
- samr_io_r_query_groupmem,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *num_mem = r.num_entries;
- *rid = r.rid;
- *attr = r.attr;
- }
-
- return result;
-}
-
/**
* Enumerate domain users
*
return result;
}
-/* Enumerate domain groups */
-
-NTSTATUS rpccli_samr_enum_als_groups(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 *start_idx,
- uint32 size, struct acct_info **dom_aliases,
- uint32 *num_dom_aliases)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_ENUM_DOM_ALIASES q;
- SAMR_R_ENUM_DOM_ALIASES r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 name_idx, i;
-
- DEBUG(10,("cli_samr_enum_als_groups starting at index %u\n", (unsigned int)*start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_enum_dom_aliases(&q, pol, *start_idx, size);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ENUM_DOM_ALIASES,
- q, r,
- qbuf, rbuf,
- samr_io_q_enum_dom_aliases,
- samr_io_r_enum_dom_aliases,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_dom_aliases = r.num_entries2;
-
- if (*num_dom_aliases == 0)
- goto done;
-
- if (!((*dom_aliases) = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_dom_aliases))) {
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- memset(*dom_aliases, 0, sizeof(struct acct_info) * *num_dom_aliases);
-
- name_idx = 0;
-
- for (i = 0; i < *num_dom_aliases; i++) {
-
- (*dom_aliases)[i].rid = r.sam[i].rid;
-
- if (r.sam[i].hdr_name.buffer) {
- unistr2_to_ascii((*dom_aliases)[i].acct_name,
- &r.uni_grp_name[name_idx],
- sizeof((*dom_aliases)[i].acct_name));
- name_idx++;
- }
-
- *start_idx = r.next_idx;
- }
-
- done:
- return result;
-}
-
-/* Query alias members */
-
-NTSTATUS rpccli_samr_query_aliasmem(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *alias_pol, uint32 *num_mem,
- DOM_SID **sids)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_ALIASMEM q;
- SAMR_R_QUERY_ALIASMEM r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 i;
-
- DEBUG(10,("cli_samr_query_aliasmem\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_query_aliasmem(&q, alias_pol);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_ALIASMEM,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_aliasmem,
- samr_io_r_query_aliasmem,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (!NT_STATUS_IS_OK(result = r.status)) {
- goto done;
- }
-
- *num_mem = r.num_sids;
-
- if (*num_mem == 0) {
- *sids = NULL;
- result = NT_STATUS_OK;
- goto done;
- }
-
- if (!(*sids = TALLOC_ARRAY(mem_ctx, DOM_SID, *num_mem))) {
- result = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
-
- for (i = 0; i < *num_mem; i++) {
- (*sids)[i] = r.sid[i].sid;
- }
-
- done:
- return result;
-}
-
-/* Open handle on an alias */
-
-NTSTATUS rpccli_samr_open_alias(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 access_mask,
- uint32 alias_rid, POLICY_HND *alias_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_OPEN_ALIAS q;
- SAMR_R_OPEN_ALIAS r;
- NTSTATUS result;
-
- DEBUG(10,("cli_samr_open_alias with rid 0x%x\n", alias_rid));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_open_alias(&q, domain_pol, access_mask, alias_rid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_OPEN_ALIAS,
- q, r,
- qbuf, rbuf,
- samr_io_q_open_alias,
- samr_io_r_open_alias,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *alias_pol = r.pol;
-#ifdef __INSURE__
- alias_pol->marker = malloc(1);
-#endif
- }
-
- return result;
-}
-
-/* Create an alias */
-
-NTSTATUS rpccli_samr_create_dom_alias(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, const char *name,
- POLICY_HND *alias_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_CREATE_DOM_ALIAS q;
- SAMR_R_CREATE_DOM_ALIAS r;
- NTSTATUS result;
-
- DEBUG(10,("cli_samr_create_dom_alias named %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_create_dom_alias(&q, domain_pol, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CREATE_DOM_ALIAS,
- q, r,
- qbuf, rbuf,
- samr_io_q_create_dom_alias,
- samr_io_r_create_dom_alias,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (NT_STATUS_IS_OK(result = r.status)) {
- *alias_pol = r.alias_pol;
- }
-
- return result;
-}
-
-/* Add an alias member */
-
-NTSTATUS rpccli_samr_add_aliasmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *alias_pol, DOM_SID *member)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_ADD_ALIASMEM q;
- SAMR_R_ADD_ALIASMEM r;
- NTSTATUS result;
-
- DEBUG(10,("cli_samr_add_aliasmem"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_add_aliasmem(&q, alias_pol, member);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ADD_ALIASMEM,
- q, r,
- qbuf, rbuf,
- samr_io_q_add_aliasmem,
- samr_io_r_add_aliasmem,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- return result;
-}
-
-/* Delete an alias member */
-
-NTSTATUS rpccli_samr_del_aliasmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *alias_pol, DOM_SID *member)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_DEL_ALIASMEM q;
- SAMR_R_DEL_ALIASMEM r;
- NTSTATUS result;
-
- DEBUG(10,("cli_samr_del_aliasmem"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_del_aliasmem(&q, alias_pol, member);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DEL_ALIASMEM,
- q, r,
- qbuf, rbuf,
- samr_io_q_del_aliasmem,
- samr_io_r_del_aliasmem,
- NT_STATUS_UNSUCCESSFUL);
-
- result = r.status;
-
- return result;
-}
-
-/* Query alias info */
-
-NTSTATUS rpccli_samr_query_alias_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *alias_pol, uint16 switch_value,
- ALIAS_INFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_ALIASINFO q;
- SAMR_R_QUERY_ALIASINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_alias_info\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_query_aliasinfo(&q, alias_pol, switch_value);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_ALIASINFO,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_aliasinfo,
- samr_io_r_query_aliasinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (!NT_STATUS_IS_OK(result = r.status)) {
- goto done;
- }
-
- *ctr = *r.ctr;
-
- done:
-
- return result;
-}
-
-/* Query domain info */
-
-NTSTATUS rpccli_samr_query_dom_info(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- SAM_UNK_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DOMAIN_INFO q;
- SAMR_R_QUERY_DOMAIN_INFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dom_info\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_query_domain_info(&q, domain_pol, switch_value);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DOMAIN_INFO,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_domain_info,
- samr_io_r_query_domain_info,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (!NT_STATUS_IS_OK(result = r.status)) {
- goto done;
- }
-
- done:
-
- return result;
-}
-
-/* Query domain info2 */
+/* Enumerate domain groups */
-NTSTATUS rpccli_samr_query_dom_info2(struct rpc_pipe_client *cli,
+NTSTATUS rpccli_samr_enum_als_groups(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- SAM_UNK_CTR *ctr)
+ POLICY_HND *pol, uint32 *start_idx,
+ uint32 size, struct acct_info **dom_aliases,
+ uint32 *num_dom_aliases)
{
prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DOMAIN_INFO2 q;
- SAMR_R_QUERY_DOMAIN_INFO2 r;
+ SAMR_Q_ENUM_DOM_ALIASES q;
+ SAMR_R_ENUM_DOM_ALIASES r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ uint32 name_idx, i;
- DEBUG(10,("cli_samr_query_dom_info2\n"));
+ DEBUG(10,("cli_samr_enum_als_groups starting at index %u\n", (unsigned int)*start_idx));
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Marshall data and send request */
- init_samr_q_query_domain_info2(&q, domain_pol, switch_value);
-
- r.ctr = ctr;
+ init_samr_q_enum_dom_aliases(&q, pol, *start_idx, size);
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DOMAIN_INFO2,
+ CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_ENUM_DOM_ALIASES,
q, r,
qbuf, rbuf,
- samr_io_q_query_domain_info2,
- samr_io_r_query_domain_info2,
+ samr_io_q_enum_dom_aliases,
+ samr_io_r_enum_dom_aliases,
NT_STATUS_UNSUCCESSFUL);
/* Return output parameters */
- if (!NT_STATUS_IS_OK(result = r.status)) {
+ result = r.status;
+
+ if (!NT_STATUS_IS_OK(result) &&
+ NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
goto done;
}
- done:
+ *num_dom_aliases = r.num_entries2;
+
+ if (*num_dom_aliases == 0)
+ goto done;
+
+ if (!((*dom_aliases) = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_dom_aliases))) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ memset(*dom_aliases, 0, sizeof(struct acct_info) * *num_dom_aliases);
+ name_idx = 0;
+
+ for (i = 0; i < *num_dom_aliases; i++) {
+
+ (*dom_aliases)[i].rid = r.sam[i].rid;
+
+ if (r.sam[i].hdr_name.buffer) {
+ unistr2_to_ascii((*dom_aliases)[i].acct_name,
+ &r.uni_grp_name[name_idx],
+ sizeof((*dom_aliases)[i].acct_name));
+ name_idx++;
+ }
+
+ *start_idx = r.next_idx;
+ }
+
+ done:
return result;
}
-/* Set domain info */
+/* Query alias info */
-NTSTATUS rpccli_samr_set_domain_info(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- SAM_UNK_CTR *ctr)
+NTSTATUS rpccli_samr_query_alias_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *alias_pol, uint16 switch_value,
+ ALIAS_INFO_CTR *ctr)
{
prs_struct qbuf, rbuf;
- SAMR_Q_SET_DOMAIN_INFO q;
- SAMR_R_SET_DOMAIN_INFO r;
+ SAMR_Q_QUERY_ALIASINFO q;
+ SAMR_R_QUERY_ALIASINFO r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- DEBUG(10,("cli_samr_set_domain_info\n"));
+ DEBUG(10,("cli_samr_query_alias_info\n"));
ZERO_STRUCT(q);
ZERO_STRUCT(r);
/* Marshall data and send request */
- init_samr_q_set_domain_info(&q, domain_pol, switch_value, ctr);
+ init_samr_q_query_aliasinfo(&q, alias_pol, switch_value);
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_SET_DOMAIN_INFO,
+ CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_ALIASINFO,
q, r,
qbuf, rbuf,
- samr_io_q_set_domain_info,
- samr_io_r_set_domain_info,
+ samr_io_q_query_aliasinfo,
+ samr_io_r_query_aliasinfo,
NT_STATUS_UNSUCCESSFUL);
/* Return output parameters */
goto done;
}
- done:
+ *ctr = *r.ctr;
+
+ done:
return result;
}
return result;
}
-/* Create a domain user */
-
-NTSTATUS rpccli_samr_create_dom_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, const char *acct_name,
- uint32 acb_info, uint32 acct_flags,
- POLICY_HND *user_pol, uint32 *rid)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_CREATE_USER q;
- SAMR_R_CREATE_USER r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_create_dom_user %s\n", acct_name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_create_user(&q, domain_pol, acct_name, acb_info, acct_flags);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CREATE_USER,
- q, r,
- qbuf, rbuf,
- samr_io_q_create_user,
- samr_io_r_create_user,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- if (!NT_STATUS_IS_OK(result = r.status)) {
- goto done;
- }
-
- if (user_pol)
- *user_pol = r.user_pol;
-
- if (rid)
- *rid = r.user_rid;
-
- done:
-
- return result;
-}
-
/* Set userinfo */
NTSTATUS rpccli_samr_set_userinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
return result;
}
-
-/* Delete domain group */
-
-NTSTATUS rpccli_samr_delete_dom_group(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *group_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_DELETE_DOM_GROUP q;
- SAMR_R_DELETE_DOM_GROUP r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_delete_dom_group\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_delete_dom_group(&q, group_pol);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DELETE_DOM_GROUP,
- q, r,
- qbuf, rbuf,
- samr_io_q_delete_dom_group,
- samr_io_r_delete_dom_group,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
-/* Delete domain alias */
-
-NTSTATUS rpccli_samr_delete_dom_alias(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *alias_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_DELETE_DOM_ALIAS q;
- SAMR_R_DELETE_DOM_ALIAS r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_delete_dom_alias\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_delete_dom_alias(&q, alias_pol);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DELETE_DOM_ALIAS,
- q, r,
- qbuf, rbuf,
- samr_io_q_delete_dom_alias,
- samr_io_r_delete_dom_alias,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
-/* Delete domain user */
-
-NTSTATUS rpccli_samr_delete_dom_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *user_pol)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_DELETE_DOM_USER q;
- SAMR_R_DELETE_DOM_USER r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_delete_dom_user\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_delete_dom_user(&q, user_pol);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_DELETE_DOM_USER,
- q, r,
- qbuf, rbuf,
- samr_io_q_delete_dom_user,
- samr_io_r_delete_dom_user,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
-/* Remove foreign SID */
-
-NTSTATUS rpccli_samr_remove_sid_foreign_domain(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *user_pol,
- DOM_SID *sid)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN q;
- SAMR_R_REMOVE_SID_FOREIGN_DOMAIN r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_remove_sid_foreign_domain\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_remove_sid_foreign_domain(&q, user_pol, sid);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_REMOVE_SID_FOREIGN_DOMAIN,
- q, r,
- qbuf, rbuf,
- samr_io_q_remove_sid_foreign_domain,
- samr_io_r_remove_sid_foreign_domain,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
-/* Query user security object */
-
-NTSTATUS rpccli_samr_query_sec_obj(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *user_pol, uint32 sec_info,
- TALLOC_CTX *ctx, SEC_DESC_BUF **sec_desc_buf)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_SEC_OBJ q;
- SAMR_R_QUERY_SEC_OBJ r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_sec_obj\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_query_sec_obj(&q, user_pol, sec_info);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_SEC_OBJECT,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_sec_obj,
- samr_io_r_query_sec_obj,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
- *sec_desc_buf=dup_sec_desc_buf(ctx, r.buf);
-
- return result;
-}
-
-/* Set user security object */
-
-NTSTATUS rpccli_samr_set_sec_obj(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *user_pol, uint32 sec_info,
- SEC_DESC_BUF *sec_desc_buf)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_SET_SEC_OBJ q;
- SAMR_R_SET_SEC_OBJ r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_set_sec_obj\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_set_sec_obj(&q, user_pol, sec_info, sec_desc_buf);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_SET_SEC_OBJECT,
- q, r,
- qbuf, rbuf,
- samr_io_q_set_sec_obj,
- samr_io_r_set_sec_obj,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- return result;
-}
-
-/* Lookup Domain Name */
-
-NTSTATUS rpccli_samr_lookup_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *user_pol, char *domain_name,
- DOM_SID *sid)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_LOOKUP_DOMAIN q;
- SAMR_R_LOOKUP_DOMAIN r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_lookup_domain\n"));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_lookup_domain(&q, user_pol, domain_name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_LOOKUP_DOMAIN,
- q, r,
- qbuf, rbuf,
- samr_io_q_lookup_domain,
- samr_io_r_lookup_domain,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (NT_STATUS_IS_OK(result))
- sid_copy(sid, &r.dom_sid.sid);
-
- return result;
-}
/********************************************************************
********************************************************************/
-bool prs_ev_open_unknown0( const char *desc, prs_struct *ps, int depth, EVENTLOG_OPEN_UNKNOWN0 *u )
-{
- if ( !u )
- return False;
-
- if ( !prs_uint16("", ps, depth, &u->unknown1) )
- return False;
- if ( !prs_uint16("", ps, depth, &u->unknown2) )
- return False;
-
- return True;
-}
-
-/********************************************************************
-********************************************************************/
-
-bool eventlog_io_q_open_eventlog(const char *desc, EVENTLOG_Q_OPEN_EVENTLOG *q_u,
- prs_struct *ps, int depth)
-{
- if(q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_q_open_eventlog");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if ( !prs_pointer("", ps, depth, (void*)&q_u->unknown0, sizeof(EVENTLOG_OPEN_UNKNOWN0), (PRS_POINTER_CAST)prs_ev_open_unknown0))
- return False;
-
- if ( !prs_unistr4("logname", ps, depth, &q_u->logname) )
- return False;
- if ( !prs_align(ps) )
- return False;
-
- if ( !prs_unistr4("servername", ps, depth, &q_u->servername) )
- return False;
- if ( !prs_align(ps) )
- return False;
-
- if ( !prs_uint32("unknown1", ps, depth, &q_u->unknown1) )
- return False;
- if ( !prs_uint32("unknown2", ps, depth, &q_u->unknown2) )
- return False;
-
- return True;
-}
-
-bool eventlog_io_r_open_eventlog(const char *desc, EVENTLOG_R_OPEN_EVENTLOG *r_u,
- prs_struct *ps, int depth)
-{
- if(r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_r_open_eventlog");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!(smb_io_pol_hnd("log handle", &(r_u->handle), ps, depth)))
- return False;
-
- if(!(prs_ntstatus("status code", ps, depth, &r_u->status)))
- return False;
-
- return True;
-}
-
-bool eventlog_io_q_get_num_records(const char *desc, EVENTLOG_Q_GET_NUM_RECORDS *q_u,
- prs_struct *ps, int depth)
-{
- if(q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_q_get_num_records");
- depth++;
-
- if(!(prs_align(ps)))
- return False;
-
- if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
- return False;
-
- return True;
-}
-
-bool eventlog_io_r_get_num_records(const char *desc, EVENTLOG_R_GET_NUM_RECORDS *r_u,
- prs_struct *ps, int depth)
-{
- if(r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_r_get_num_records");
- depth++;
-
- if(!(prs_align(ps)))
- return False;
-
- if(!(prs_uint32("num records", ps, depth, &(r_u->num_records))))
- return False;
-
- if(!(prs_ntstatus("status code", ps, depth, &r_u->status)))
- return False;
-
- return True;
-}
-
-bool eventlog_io_q_get_oldest_entry(const char *desc, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u,
- prs_struct *ps, int depth)
-{
- if(q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_q_get_oldest_entry");
- depth++;
-
- if(!(prs_align(ps)))
- return False;
-
- if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
- return False;
-
- return True;
-}
-
-bool eventlog_io_r_get_oldest_entry(const char *desc, EVENTLOG_R_GET_OLDEST_ENTRY *r_u,
- prs_struct *ps, int depth)
-{
- if(r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_r_get_oldest_entry");
- depth++;
-
- if(!(prs_align(ps)))
- return False;
-
- if(!(prs_uint32("oldest entry", ps, depth, &(r_u->oldest_entry))))
- return False;
-
- if(!(prs_ntstatus("status code", ps, depth, &r_u->status)))
- return False;
-
- return True;
-}
-
bool eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u,
prs_struct *ps, int depth)
{
return True;
}
-
-/** The windows client seems to be doing something funny with the file name
- A call like
- ClearEventLog(handle, "backup_file")
- on the client side will result in the backup file name looking like this on the
- server side:
- \??\${CWD of client}\backup_file
- If an absolute path gets specified, such as
- ClearEventLog(handle, "C:\\temp\\backup_file")
- then it is still mangled by the client into this:
- \??\C:\temp\backup_file
- when it is on the wire.
- I'm not sure where the \?? is coming from, or why the ${CWD} of the client process
- would be added in given that the backup file gets written on the server side. */
-
-bool eventlog_io_q_clear_eventlog(const char *desc, EVENTLOG_Q_CLEAR_EVENTLOG *q_u,
- prs_struct *ps, int depth)
-{
- if(q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_q_clear_eventlog");
- depth++;
-
- if(!prs_align(ps))
- return False;
- if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth)))
- return False;
-
- if ( !prs_unistr4("backupfile", ps, depth, &q_u->backupfile) )
- return False;
-
- return True;
-
-}
-
-bool eventlog_io_r_clear_eventlog(const char *desc, EVENTLOG_R_CLEAR_EVENTLOG *r_u,
- prs_struct *ps, int depth)
-{
- if(r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "eventlog_io_r_clear_eventlog");
- depth++;
-
- if(!prs_align(ps))
- return False;
- if(!(prs_ntstatus("status code", ps, depth, &r_u->status)))
- return False;
-
- return True;
-}
return True;
}
-/*******************************************************************
-makes an LSA_Q_QUERY_SEC_OBJ structure.
-********************************************************************/
-
-void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *in, const POLICY_HND *hnd,
- uint32 sec_info)
-{
- DEBUG(5, ("init_q_query_sec_obj\n"));
-
- in->pol = *hnd;
- in->sec_info = sec_info;
-
- return;
-}
-
-/*******************************************************************
- Reads or writes an LSA_Q_QUERY_SEC_OBJ structure.
-********************************************************************/
-
-bool lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *in,
- prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj");
- depth++;
-
- if (!smb_io_pol_hnd("", &in->pol, ps, depth))
- return False;
-
- if (!prs_uint32("sec_info", ps, depth, &in->sec_info))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Reads or writes a LSA_R_QUERY_SEC_OBJ structure.
-********************************************************************/
-
-bool lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *out, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("ptr", ps, depth, &out->ptr))
- return False;
-
- if (out->ptr != 0) {
- if (!sec_io_desc_buf("sec", &out->buf, ps, depth))
- return False;
- }
-
- if (!prs_ntstatus("status", ps, depth, &out->status))
- return False;
-
- return True;
-}
-
/*******************************************************************
Inits an LSA_Q_QUERY_INFO structure.
********************************************************************/
return True;
}
-
-/*******************************************************************
-********************************************************************/
-
-bool lsa_io_q_delete_object(const char *desc, LSA_Q_DELETE_OBJECT *in, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_q_delete_object");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("", &in->handle, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool lsa_io_r_delete_object(const char *desc, LSA_R_DELETE_OBJECT *out, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "lsa_io_r_delete_object");
- depth++;
-
- if(!prs_ntstatus("status", ps, depth, &out->status))
- return False;
-
- return True;
-}
#define DBGC_CLASS DBGC_RPC_PARSE
/*******************************************************************
-inits a SAMR_Q_LOOKUP_DOMAIN structure.
+ inits a structure.
********************************************************************/
-void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
- POLICY_HND *pol, char *dom_name)
+static void init_lsa_String(struct lsa_String *name, const char *s)
{
- DEBUG(5, ("init_samr_q_lookup_domain\n"));
+ name->string = s;
+}
- q_u->connect_pol = *pol;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
- init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
+void init_samr_DomInfo1(struct samr_DomInfo1 *r,
+ uint16_t min_password_length,
+ uint16_t password_history_length,
+ uint32_t password_properties,
+ int64_t max_password_age,
+ int64_t min_password_age)
+{
+ r->min_password_length = min_password_length;
+ r->password_history_length = password_history_length;
+ r->password_properties = password_properties;
+ r->max_password_age = max_password_age;
+ r->min_password_age = min_password_age;
}
/*******************************************************************
-reads or writes a structure.
+ inits a structure.
********************************************************************/
-bool samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
- prs_struct *ps, int depth)
+
+void init_samr_DomInfo2(struct samr_DomInfo2 *r,
+ NTTIME force_logoff_time,
+ const char *comment,
+ const char *domain_name,
+ const char *primary,
+ uint64_t sequence_num,
+ uint32_t unknown2,
+ enum samr_Role role,
+ uint32_t unknown3,
+ uint32_t num_users,
+ uint32_t num_groups,
+ uint32_t num_aliases)
{
- if (q_u == NULL)
- return False;
+ r->force_logoff_time = force_logoff_time;
+ init_lsa_String(&r->comment, comment);
+ init_lsa_String(&r->domain_name, domain_name);
+ init_lsa_String(&r->primary, primary);
+ r->sequence_num = sequence_num;
+ r->unknown2 = unknown2;
+ r->role = role;
+ r->unknown3 = unknown3;
+ r->num_users = num_users;
+ r->num_groups = num_groups;
+ r->num_aliases = num_aliases;
+}
- prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
- depth++;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- if(!prs_align(ps))
- return False;
+void init_samr_DomInfo3(struct samr_DomInfo3 *r,
+ NTTIME force_logoff_time)
+{
+ r->force_logoff_time = force_logoff_time;
+}
- if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
- return False;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
- return False;
+void init_samr_DomInfo4(struct samr_DomInfo4 *r,
+ const char *comment)
+{
+ init_lsa_String(&r->comment, comment);
+}
- if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
- return False;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- return True;
+void init_samr_DomInfo5(struct samr_DomInfo5 *r,
+ const char *domain_name)
+{
+ init_lsa_String(&r->domain_name, domain_name);
}
/*******************************************************************
-inits a SAMR_R_LOOKUP_DOMAIN structure.
+ inits a structure.
********************************************************************/
-void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
- DOM_SID *dom_sid, NTSTATUS status)
+void init_samr_DomInfo6(struct samr_DomInfo6 *r,
+ const char *primary)
{
- DEBUG(5, ("init_samr_r_lookup_domain\n"));
-
- r_u->status = status;
- r_u->ptr_sid = 0;
- if (NT_STATUS_IS_OK(status)) {
- r_u->ptr_sid = 1;
- init_dom_sid2(&r_u->dom_sid, dom_sid);
- }
+ init_lsa_String(&r->primary, primary);
}
/*******************************************************************
-reads or writes a structure.
+ inits a structure.
********************************************************************/
-bool samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
- prs_struct *ps, int depth)
+void init_samr_DomInfo7(struct samr_DomInfo7 *r,
+ enum samr_Role role)
{
- if (r_u == NULL)
- return False;
+ r->role = role;
+}
- prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
- depth++;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- if(!prs_align(ps))
- return False;
+void init_samr_DomInfo8(struct samr_DomInfo8 *r,
+ uint64_t sequence_num,
+ NTTIME domain_create_time)
+{
+ r->sequence_num = sequence_num;
+ r->domain_create_time = domain_create_time;
+}
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
- return False;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- if (r_u->ptr_sid != 0) {
- if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- }
+void init_samr_DomInfo9(struct samr_DomInfo9 *r,
+ uint32_t unknown)
+{
+ r->unknown = unknown;
+}
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+/*******************************************************************
+ inits a structure.
+********************************************************************/
- return True;
+void init_samr_DomInfo12(struct samr_DomInfo12 *r,
+ uint64_t lockout_duration,
+ uint64_t lockout_window,
+ uint16_t lockout_threshold)
+{
+ r->lockout_duration = lockout_duration;
+ r->lockout_window = lockout_window;
+ r->lockout_threshold = lockout_threshold;
}
/*******************************************************************
-reads or writes a structure.
+inits a structure.
********************************************************************/
-void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
+void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
+ uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
{
- DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
+ u_1->min_length_password = min_pass_len;
+ u_1->password_history = pass_hist;
+
+ if (lp_check_password_script() && *lp_check_password_script()) {
+ password_properties |= DOMAIN_PASSWORD_COMPLEX;
+ }
+ u_1->password_properties = password_properties;
+
+ /* password never expire */
+ u_1->expire = nt_expire;
- q_u->dom_pol = *dom_pol;
- init_dom_sid2(&q_u->sid, sid);
+ /* can change the password now */
+ u_1->min_passwordage = nt_min_age;
+
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
- return False;
+ if (u_1 == NULL)
+ return False;
- prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
+ prs_debug(ps, depth, desc, "sam_io_unk_info1");
depth++;
- if(!prs_align(ps))
+ if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
+ if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
return False;
-
- if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
+ if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
return False;
-
- if(!prs_align(ps))
+ if(!smb_io_time("expire", &u_1->expire, ps, depth))
+ return False;
+ if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
return False;
return True;
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_STR1 structure.
********************************************************************/
-bool samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
+ uint32 name_buf, uint32 desc_buf,
+ prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
+ prs_debug(ps, depth, desc, "sam_io_sam_str1");
depth++;
if(!prs_align(ps))
return False;
+ if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
+ return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
+ return False;
+
+ if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
return False;
return True;
}
/*******************************************************************
-reads or writes a structure.
+inits a SAM_ENTRY1 structure.
********************************************************************/
-void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
- POLICY_HND *pol, uint32 flags,
- const DOM_SID *sid)
+static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
+ UNISTR2 *sam_name, UNISTR2 *sam_full,
+ UNISTR2 *sam_desc, uint32 rid_user,
+ uint32 acb_info)
{
- DEBUG(5, ("samr_init_samr_q_open_domain\n"));
+ DEBUG(5, ("init_sam_entry1\n"));
- q_u->pol = *pol;
- q_u->flags = flags;
- init_dom_sid2(&q_u->dom_sid, sid);
+ ZERO_STRUCTP(sam);
+
+ sam->user_idx = user_idx;
+ sam->rid_user = rid_user;
+ sam->acb_info = acb_info;
+
+ init_uni_hdr(&sam->hdr_acct_name, sam_name);
+ init_uni_hdr(&sam->hdr_user_name, sam_full);
+ init_uni_hdr(&sam->hdr_user_desc, sam_desc);
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_ENTRY1 structure.
********************************************************************/
-bool samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_open_domain");
+ prs_debug(ps, depth, desc, "sam_io_sam_entry1");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
+ if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
return False;
- if(!prs_uint32("flags", ps, depth, &q_u->flags))
+ if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
+ return False;
+ if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
return False;
- if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
+ if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
return False;
return True;
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_STR2 structure.
********************************************************************/
-bool samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
+ uint32 desc_buf, prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_open_domain");
+ prs_debug(ps, depth, desc, "sam_io_sam_str2");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
+ if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
return False;
return True;
}
/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
- POLICY_HND *user_pol)
-{
- DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
-
- q_u->user_pol = *user_pol;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
-}
-
-/*******************************************************************
- Init.
+inits a SAM_ENTRY2 structure.
********************************************************************/
-
-void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
+static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
+ UNISTR2 *sam_name, UNISTR2 *sam_desc,
+ uint32 rid_user, uint32 acb_info)
{
- DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
-
- r_u->min_pwd_length = 0x0000;
-
- /*
- * used to be
- * r_u->unknown_1 = 0x0015;
- * but for trusts.
- */
- r_u->unknown_1 = 0x01D1;
- r_u->unknown_1 = 0x0015;
+ DEBUG(5, ("init_sam_entry2\n"));
- r_u->password_properties = 0x00000000;
+ sam->user_idx = user_idx;
+ sam->rid_user = rid_user;
+ sam->acb_info = acb_info;
- r_u->status = status;
+ init_uni_hdr(&sam->hdr_srv_name, sam_name);
+ init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_ENTRY2 structure.
********************************************************************/
-bool samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
+ prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
+ prs_debug(ps, depth, desc, "sam_io_sam_entry2");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
+ if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
return False;
- if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
+
+ if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
return False;
- if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
+ if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
return False;
- if(!prs_ntstatus("status ", ps, depth, &r_u->status))
+ if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
+ return False;
+ if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
return False;
return True;
}
-
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_STR3 structure.
********************************************************************/
-bool samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
+ uint32 desc_buf, prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
+ prs_debug(ps, depth, desc, "sam_io_sam_str3");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
- return False;
-
- if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
+ if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
return False;
-
- if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
+ if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
return False;
-
+
return True;
}
-
/*******************************************************************
-reads or writes a structure.
+inits a SAM_ENTRY3 structure.
********************************************************************/
-void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
- POLICY_HND *user_pol, uint32 sec_info)
+static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
+ UNISTR2 *grp_name, UNISTR2 *grp_desc,
+ uint32 rid_grp)
{
- DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
+ DEBUG(5, ("init_sam_entry3\n"));
- q_u->user_pol = *user_pol;
- q_u->sec_info = sec_info;
-}
+ sam->grp_idx = grp_idx;
+ sam->rid_grp = rid_grp;
+ sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
+ init_uni_hdr(&sam->hdr_grp_name, grp_name);
+ init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
+}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_ENTRY3 structure.
********************************************************************/
-bool samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
+ prs_debug(ps, depth, desc, "sam_io_sam_entry3");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
+ if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
return False;
- if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
+ if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
+ return False;
+ if(!prs_uint32("attr ", ps, depth, &sam->attr))
return False;
- return True;
+ if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
+ return False;
+ if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
+ return False;
+
+ return True;
}
/*******************************************************************
-reads or writes a structure.
+inits a SAM_ENTRY4 structure.
********************************************************************/
-void init_samr_q_query_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
- POLICY_HND *domain_pol, uint16 switch_value)
+static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
+ uint32 len_acct_name)
{
- DEBUG(5, ("samr_init_samr_q_query_domain_info\n"));
+ DEBUG(5, ("init_sam_entry4\n"));
- q_u->domain_pol = *domain_pol;
- q_u->switch_value = switch_value;
+ sam->user_idx = user_idx;
+ init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_ENTRY4 structure.
********************************************************************/
-bool samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_query_domain_info");
+ prs_debug(ps, depth, desc, "sam_io_sam_entry4");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
+ if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
return False;
-
- if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
+ if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
return False;
return True;
}
/*******************************************************************
-inits a structure.
+inits a SAM_ENTRY5 structure.
********************************************************************/
-void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
- uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
+static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
+ uint32 len_grp_name)
{
- u_1->min_length_password = min_pass_len;
- u_1->password_history = pass_hist;
-
- if (lp_check_password_script() && *lp_check_password_script()) {
- password_properties |= DOMAIN_PASSWORD_COMPLEX;
- }
- u_1->password_properties = password_properties;
-
- /* password never expire */
- u_1->expire = nt_expire;
+ DEBUG(5, ("init_sam_entry5\n"));
- /* can change the password now */
- u_1->min_passwordage = nt_min_age;
-
+ sam->grp_idx = grp_idx;
+ init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
+ len_grp_name != 0);
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_ENTRY5 structure.
********************************************************************/
-static bool sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
- prs_struct *ps, int depth)
+static bool sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
+ prs_struct *ps, int depth)
{
- if (u_1 == NULL)
- return False;
+ if (sam == NULL)
+ return False;
- prs_debug(ps, depth, desc, "sam_io_unk_info1");
+ prs_debug(ps, depth, desc, "sam_io_sam_entry5");
depth++;
- if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
- return False;
- if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
- return False;
- if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
+ if(!prs_align(ps))
return False;
- if(!smb_io_time("expire", &u_1->expire, ps, depth))
+
+ if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
return False;
- if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
+ if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
return False;
return True;
}
/*******************************************************************
-inits a structure.
+inits a SAM_ENTRY structure.
********************************************************************/
-void init_unk_info2(SAM_UNK_INFO_2 * u_2,
- const char *comment, const char *domain, const char *server,
- uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
+void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
{
- u_2->logout = nt_logout;
-
- u_2->seq_num = seq_num;
-
-
- u_2->unknown_4 = 0x00000001;
- u_2->server_role = server_role;
- u_2->unknown_6 = 0x00000001;
- u_2->num_domain_usrs = num_users;
- u_2->num_domain_grps = num_groups;
- u_2->num_local_grps = num_alias;
+ DEBUG(10, ("init_sam_entry: %d\n", rid));
- init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
- init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
- init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
- init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
- init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
- init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
+ sam->rid = rid;
+ init_uni_hdr(&sam->hdr_name, uni2);
}
/*******************************************************************
-reads or writes a structure.
+reads or writes a SAM_ENTRY structure.
********************************************************************/
-static bool sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
+static bool sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
prs_struct *ps, int depth)
{
- if (u_2 == NULL)
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_unk_info2");
+ prs_debug(ps, depth, desc, "sam_io_sam_entry");
depth++;
- if(!smb_io_time("logout", &u_2->logout, ps, depth))
- return False;
- if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
- return False;
- if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
- return False;
- if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
- return False;
-
- /* put all the data in here, at the moment, including what the above
- pointer is referring to
- */
-
- if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
- return False;
-
- if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
- return False;
- if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
- return False;
- if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
- return False;
- if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
- return False;
- if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
- return False;
- if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
- return False;
-
- if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
+ if(!prs_align(ps))
return False;
- if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
+ if(!prs_uint32("rid", ps, depth, &sam->rid))
return False;
- if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
+ if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
return False;
return True;
}
/*******************************************************************
-inits a structure.
+inits a SAMR_Q_ENUM_DOM_USERS structure.
********************************************************************/
-void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
+void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
+ uint32 start_idx,
+ uint32 acb_mask, uint32 size)
{
- u_3->logout = nt_logout;
+ DEBUG(5, ("init_samr_q_enum_dom_users\n"));
+
+ q_e->pol = *pol;
+
+ q_e->start_idx = start_idx; /* zero indicates lots */
+ q_e->acb_mask = acb_mask;
+ q_e->max_size = size;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
- prs_struct *ps, int depth)
+bool samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
+ prs_struct *ps, int depth)
{
- if (u_3 == NULL)
+ if (q_e == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_unk_info3");
+ prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
depth++;
- if(!smb_io_time("logout", &u_3->logout, ps, depth))
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
+ return False;
+
+ if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
+ return False;
+ if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
+ return False;
+
+ if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
return False;
return True;
}
+
/*******************************************************************
-inits a structure.
+inits a SAMR_R_ENUM_DOM_USERS structure.
********************************************************************/
-void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
+void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
+ uint32 next_idx, uint32 num_sam_entries)
{
- init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
- init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
+ DEBUG(5, ("init_samr_r_enum_dom_users\n"));
+
+ r_u->next_idx = next_idx;
+
+ if (num_sam_entries != 0) {
+ r_u->ptr_entries1 = 1;
+ r_u->ptr_entries2 = 1;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->num_entries3 = num_sam_entries;
+
+ r_u->num_entries4 = num_sam_entries;
+ } else {
+ r_u->ptr_entries1 = 0;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->ptr_entries2 = 1;
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
- prs_struct *ps, int depth)
+bool samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
+ prs_struct *ps, int depth)
{
- if (u_4 == NULL)
+ uint32 i;
+
+ if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_unk_info4");
+ prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
depth++;
- if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
+ if(!prs_align(ps))
return False;
- if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
+ if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
+ return False;
+ if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
return False;
- return True;
-}
+ if (r_u->ptr_entries1 != 0) {
+ if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
+ return False;
+ if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
+ return False;
+ if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
+ return False;
-/*******************************************************************
-inits a structure.
-********************************************************************/
+ if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
+ r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
+ r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
+ }
-void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
-{
- init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
- init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
-}
+ if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
+ DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
+ r_u->num_entries4 = 0;
+ r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
+ return False;
+ }
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ for (i = 0; i < r_u->num_entries2; i++) {
+ if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
+ return False;
+ }
-static bool sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
- prs_struct *ps, int depth)
-{
- if (u_5 == NULL)
- return False;
+ for (i = 0; i < r_u->num_entries2; i++) {
+ if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
+ return False;
+ }
- prs_debug(ps, depth, desc, "sam_io_unk_info5");
- depth++;
+ }
- if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
+ if(!prs_align(ps))
return False;
-
- if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
+
+ if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
+ return False;
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
return True;
}
/*******************************************************************
-inits a structure.
+inits a SAMR_Q_QUERY_DISPINFO structure.
********************************************************************/
-void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
+void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx,
+ uint32 max_entries, uint32 max_size)
{
- init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
- init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
+ DEBUG(5, ("init_samr_q_query_dispinfo\n"));
+
+ q_e->domain_pol = *pol;
+
+ q_e->switch_level = switch_level;
+
+ q_e->start_idx = start_idx;
+ q_e->max_entries = max_entries;
+ q_e->max_size = max_size;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
- prs_struct *ps, int depth)
+bool samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
+ prs_struct *ps, int depth)
{
- if (u_6 == NULL)
+ if (q_e == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_unk_info6");
+ prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
depth++;
- if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
+ if(!prs_align(ps))
+ return False;
+
+ if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
+ return False;
+
+ if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
+ return False;
+ if(!prs_align(ps))
return False;
- if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
+ if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
+ return False;
+ if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
+ return False;
+ if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
return False;
return True;
}
/*******************************************************************
-inits a structure.
+inits a SAM_DISPINFO_1 structure.
********************************************************************/
-void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
+NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
+ uint32 num_entries, uint32 start_idx,
+ struct samr_displayentry *entries)
{
- u_7->server_role = server_role;
-}
+ uint32 i;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
-static bool sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
- prs_struct *ps, int depth)
-{
- if (u_7 == NULL)
- return False;
+ if (num_entries==0)
+ return NT_STATUS_OK;
- prs_debug(ps, depth, desc, "sam_io_unk_info7");
- depth++;
+ *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
+ if (*sam == NULL)
+ return NT_STATUS_NO_MEMORY;
- if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
- return False;
+ (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
+ if ((*sam)->sam == NULL)
+ return NT_STATUS_NO_MEMORY;
- return True;
-}
+ (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
+ if ((*sam)->str == NULL)
+ return NT_STATUS_NO_MEMORY;
-/*******************************************************************
-inits a structure.
-********************************************************************/
+ for (i = 0; i < num_entries ; i++) {
+ init_unistr2(&(*sam)->str[i].uni_acct_name,
+ entries[i].account_name, UNI_FLAGS_NONE);
+ init_unistr2(&(*sam)->str[i].uni_full_name,
+ entries[i].fullname, UNI_FLAGS_NONE);
+ init_unistr2(&(*sam)->str[i].uni_acct_desc,
+ entries[i].description, UNI_FLAGS_NONE);
-void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
-{
- unix_to_nt_time(&u_8->domain_create_time, 0);
- u_8->seq_num = seq_num;
+ init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
+ &(*sam)->str[i].uni_acct_name,
+ &(*sam)->str[i].uni_full_name,
+ &(*sam)->str[i].uni_acct_desc,
+ entries[i].rid, entries[i].acct_flags);
+ }
+
+ return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
- prs_struct *ps, int depth)
+static bool sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
+ uint32 num_entries,
+ prs_struct *ps, int depth)
{
- if (u_8 == NULL)
- return False;
+ uint32 i;
- prs_debug(ps, depth, desc, "sam_io_unk_info8");
+ prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
depth++;
- if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
+ if(!prs_align(ps))
return False;
- if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
- return False;
+ if (UNMARSHALLING(ps) && num_entries > 0) {
+
+ if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
+ return False;
+ }
+
+ if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_STR1\n"));
+ return False;
+ }
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_str1("", &sam->str[i],
+ sam->sam[i].hdr_acct_name.buffer,
+ sam->sam[i].hdr_user_name.buffer,
+ sam->sam[i].hdr_user_desc.buffer, ps, depth))
+ return False;
+ }
return True;
}
/*******************************************************************
-inits a structure.
+inits a SAM_DISPINFO_2 structure.
********************************************************************/
-void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
+NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
+ uint32 num_entries, uint32 start_idx,
+ struct samr_displayentry *entries)
{
- u_9->unknown = unknown;
-}
+ uint32 i;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
-static bool sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
- prs_struct *ps, int depth)
-{
- if (u_9 == NULL)
- return False;
+ if (num_entries==0)
+ return NT_STATUS_OK;
- prs_debug(ps, depth, desc, "sam_io_unk_info9");
- depth++;
+ *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
+ if (*sam == NULL)
+ return NT_STATUS_NO_MEMORY;
- if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
- return False;
+ (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
+ if ((*sam)->sam == NULL)
+ return NT_STATUS_NO_MEMORY;
- return True;
-}
+ (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
+ if ((*sam)->str == NULL)
+ return NT_STATUS_NO_MEMORY;
-/*******************************************************************
-inits a structure.
-********************************************************************/
+ for (i = 0; i < num_entries; i++) {
+ init_unistr2(&(*sam)->str[i].uni_srv_name,
+ entries[i].account_name, UNI_FLAGS_NONE);
+ init_unistr2(&(*sam)->str[i].uni_srv_desc,
+ entries[i].description, UNI_FLAGS_NONE);
-void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
-{
- u_12->duration = nt_lock_duration;
- u_12->reset_count = nt_reset_time;
+ init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
+ &(*sam)->str[i].uni_srv_name,
+ &(*sam)->str[i].uni_srv_desc,
+ entries[i].rid, entries[i].acct_flags);
+ }
- u_12->bad_attempt_lockout = lockout;
+ return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
- prs_struct *ps, int depth)
+static bool sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
+ uint32 num_entries,
+ prs_struct *ps, int depth)
{
- if (u_12 == NULL)
+ uint32 i;
+
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_unk_info12");
+ prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
depth++;
- if(!smb_io_time("duration", &u_12->duration, ps, depth))
- return False;
- if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
- return False;
- if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
+ if(!prs_align(ps))
return False;
- return True;
-}
+ if (UNMARSHALLING(ps) && num_entries > 0) {
-/*******************************************************************
-inits a structure.
-********************************************************************/
+ if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
+ return False;
+ }
-void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
-{
- unix_to_nt_time(&u_13->domain_create_time, 0);
- u_13->seq_num = seq_num;
- u_13->unknown1 = 0;
- u_13->unknown2 = 0;
+ if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_STR2\n"));
+ return False;
+ }
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_str2("", &sam->str[i],
+ sam->sam[i].hdr_srv_name.buffer,
+ sam->sam[i].hdr_srv_desc.buffer, ps, depth))
+ return False;
+ }
+
+ return True;
}
/*******************************************************************
-reads or writes a structure.
+inits a SAM_DISPINFO_3 structure.
********************************************************************/
-static bool sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
- prs_struct *ps, int depth)
+NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
+ uint32 num_entries, uint32 start_idx,
+ struct samr_displayentry *entries)
{
- if (u_13 == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_unk_info13");
- depth++;
+ uint32 i;
- if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
- return False;
+ DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
- if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
- return False;
+ if (num_entries==0)
+ return NT_STATUS_OK;
- if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1))
- return False;
- if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2))
- return False;
+ *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
+ if (*sam == NULL)
+ return NT_STATUS_NO_MEMORY;
- return True;
-}
+ if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
+ return NT_STATUS_NO_MEMORY;
-/*******************************************************************
-inits a SAMR_R_QUERY_DOMAIN_INFO structure.
-********************************************************************/
+ if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
+ return NT_STATUS_NO_MEMORY;
-void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
- uint16 switch_value, SAM_UNK_CTR * ctr,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_domain_info\n"));
+ for (i = 0; i < num_entries; i++) {
+ DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
- r_u->ptr_0 = 0;
- r_u->switch_value = 0;
- r_u->status = status; /* return status */
+ init_unistr2(&(*sam)->str[i].uni_grp_name,
+ entries[i].account_name, UNI_FLAGS_NONE);
+ init_unistr2(&(*sam)->str[i].uni_grp_desc,
+ entries[i].description, UNI_FLAGS_NONE);
- if (NT_STATUS_IS_OK(status)) {
- r_u->switch_value = switch_value;
- r_u->ptr_0 = 1;
- r_u->ctr = ctr;
+ init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
+ &(*sam)->str[i].uni_grp_name,
+ &(*sam)->str[i].uni_grp_desc,
+ entries[i].rid);
}
+
+ return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
+ uint32 num_entries,
+ prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ uint32 i;
+
+ if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_query_domain_info");
+ prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
- return False;
+ if (UNMARSHALLING(ps) && num_entries > 0) {
- if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
- if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
- return False;
- if(!prs_align(ps))
+ if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
return False;
+ }
- switch (r_u->switch_value) {
- case 0x0d:
- if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
- return False;
- break;
- case 0x0c:
- if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
- return False;
- break;
- case 0x09:
- if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
- return False;
- break;
- case 0x08:
- if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
- return False;
- break;
- case 0x07:
- if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
- return False;
- break;
- case 0x06:
- if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
- return False;
- break;
- case 0x05:
- if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
- return False;
- break;
- case 0x04:
- if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
- return False;
- break;
- case 0x03:
- if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
- return False;
- break;
- case 0x02:
- if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
- return False;
- break;
- case 0x01:
- if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
- return False;
- break;
- default:
- DEBUG(0, ("samr_io_r_query_domain_info: unknown switch level 0x%x\n",
- r_u->switch_value));
- r_u->status = NT_STATUS_INVALID_INFO_CLASS;
+ if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_STR3\n"));
return False;
}
}
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
+ return False;
+ }
-void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
- POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
-{
- DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_str3("", &sam->str[i],
+ sam->sam[i].hdr_grp_name.buffer,
+ sam->sam[i].hdr_grp_desc.buffer, ps, depth))
+ return False;
+ }
- q_u->pol = *pol;
- q_u->sec_info = sec_info;
- q_u->buf = buf;
+ return True;
}
-
/*******************************************************************
-reads or writes a SAMR_R_SET_SEC_OBJ structure.
+inits a SAM_DISPINFO_4 structure.
********************************************************************/
-bool samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
- prs_struct *ps, int depth)
+NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
+ uint32 num_entries, uint32 start_idx,
+ struct samr_displayentry *entries)
{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
- depth++;
-
- if(!prs_align(ps))
- return False;
+ uint32 i;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
- return True;
-}
+ if (num_entries==0)
+ return NT_STATUS_OK;
-/*******************************************************************
-reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
-********************************************************************/
+ *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
+ if (*sam == NULL)
+ return NT_STATUS_NO_MEMORY;
-bool samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
- depth++;
+ (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
+ if ((*sam)->sam == NULL)
+ return NT_STATUS_NO_MEMORY;
- if(!prs_align(ps))
- return False;
+ (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
+ if ((*sam)->str == NULL)
+ return NT_STATUS_NO_MEMORY;
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
- return False;
- if (r_u->ptr != 0) {
- if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
- return False;
- }
+ for (i = 0; i < num_entries; i++) {
+ size_t len_sam_name = strlen(entries[i].account_name);
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
+
+ init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
+ len_sam_name);
- return True;
+ init_string2(&(*sam)->str[i].acct_name,
+ entries[i].account_name, len_sam_name+1,
+ len_sam_name);
+ }
+
+ return NT_STATUS_OK;
}
/*******************************************************************
-reads or writes a SAM_STR1 structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
- uint32 name_buf, uint32 desc_buf,
- prs_struct *ps, int depth)
+static bool sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
+ uint32 num_entries,
+ prs_struct *ps, int depth)
{
+ uint32 i;
+
if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_str1");
+ prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
depth++;
if(!prs_align(ps))
return False;
- if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
- return False;
- if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
- return False;
+ if (UNMARSHALLING(ps) && num_entries > 0) {
- if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
- return False;
+ if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
+ return False;
+ }
+
+ if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_STR4\n"));
+ return False;
+ }
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
+ sam->sam[i].hdr_acct_name.buffer, ps, depth))
+ return False;
+ }
return True;
}
/*******************************************************************
-inits a SAM_ENTRY1 structure.
+inits a SAM_DISPINFO_5 structure.
********************************************************************/
-static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
- UNISTR2 *sam_name, UNISTR2 *sam_full,
- UNISTR2 *sam_desc, uint32 rid_user,
- uint32 acb_info)
+NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
+ uint32 num_entries, uint32 start_idx,
+ struct samr_displayentry *entries)
{
- DEBUG(5, ("init_sam_entry1\n"));
+ uint32 len_sam_name;
+ uint32 i;
- ZERO_STRUCTP(sam);
+ DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
- sam->user_idx = user_idx;
- sam->rid_user = rid_user;
- sam->acb_info = acb_info;
+ if (num_entries==0)
+ return NT_STATUS_OK;
- init_uni_hdr(&sam->hdr_acct_name, sam_name);
- init_uni_hdr(&sam->hdr_user_name, sam_full);
- init_uni_hdr(&sam->hdr_user_desc, sam_desc);
+ *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
+ if (*sam == NULL)
+ return NT_STATUS_NO_MEMORY;
+
+ if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
+ return NT_STATUS_NO_MEMORY;
+
+ if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
+ return NT_STATUS_NO_MEMORY;
+
+ for (i = 0; i < num_entries; i++) {
+ DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
+
+ len_sam_name = strlen(entries[i].account_name);
+
+ init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
+ init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
+ len_sam_name+1, len_sam_name);
+ }
+
+ return NT_STATUS_OK;
}
/*******************************************************************
-reads or writes a SAM_ENTRY1 structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
- prs_struct *ps, int depth)
+static bool sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
+ uint32 num_entries,
+ prs_struct *ps, int depth)
{
+ uint32 i;
+
if (sam == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_entry1");
+ prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
- return False;
+ if (UNMARSHALLING(ps) && num_entries > 0) {
- if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
- return False;
- if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
- return False;
+ if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
+ return False;
+ }
- if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
- return False;
- if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
- return False;
- if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
- return False;
+ if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
+ DEBUG(0, ("out of memory allocating SAM_STR5\n"));
+ return False;
+ }
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < num_entries; i++) {
+ if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
+ sam->sam[i].hdr_grp_name.buffer, ps, depth))
+ return False;
+ }
return True;
}
/*******************************************************************
-reads or writes a SAM_STR2 structure.
+inits a SAMR_R_QUERY_DISPINFO structure.
********************************************************************/
-static bool sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
- uint32 desc_buf, prs_struct *ps, int depth)
+void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
+ uint32 num_entries, uint32 total_size, uint32 data_size,
+ uint16 switch_level, SAM_DISPINFO_CTR * ctr,
+ NTSTATUS status)
{
- if (sam == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_sam_str2");
- depth++;
+ DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
- if(!prs_align(ps))
- return False;
+ r_u->total_size = total_size;
- if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
- return False;
- if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
- return False;
+ r_u->data_size = data_size;
- return True;
-}
+ r_u->switch_level = switch_level;
+ r_u->num_entries = num_entries;
-/*******************************************************************
-inits a SAM_ENTRY2 structure.
-********************************************************************/
-static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
- UNISTR2 *sam_name, UNISTR2 *sam_desc,
- uint32 rid_user, uint32 acb_info)
-{
- DEBUG(5, ("init_sam_entry2\n"));
+ if (num_entries==0)
+ r_u->ptr_entries = 0;
+ else
+ r_u->ptr_entries = 1;
- sam->user_idx = user_idx;
- sam->rid_user = rid_user;
- sam->acb_info = acb_info;
+ r_u->num_entries2 = num_entries;
+ r_u->ctr = ctr;
- init_uni_hdr(&sam->hdr_srv_name, sam_name);
- init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
+ r_u->status = status;
}
/*******************************************************************
-reads or writes a SAM_ENTRY2 structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
+bool samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
prs_struct *ps, int depth)
{
- if (sam == NULL)
+ if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_entry2");
+ prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
+ if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
return False;
-
- if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
+ if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
return False;
- if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
+ if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
+ return False;
+ if(!prs_align(ps))
return False;
- if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
+ if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
return False;
- if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
+ if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
return False;
- return True;
-}
+ if (r_u->ptr_entries==0) {
+ if(!prs_align(ps))
+ return False;
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ return False;
-/*******************************************************************
-reads or writes a SAM_STR3 structure.
-********************************************************************/
+ return True;
+ }
-static bool sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
- uint32 desc_buf, prs_struct *ps, int depth)
-{
- if (sam == NULL)
+ if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_str3");
- depth++;
-
+ switch (r_u->switch_level) {
+ case 0x1:
+ if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
+ r_u->num_entries, ps, depth))
+ return False;
+ break;
+ case 0x2:
+ if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
+ r_u->num_entries, ps, depth))
+ return False;
+ break;
+ case 0x3:
+ if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
+ r_u->num_entries, ps, depth))
+ return False;
+ break;
+ case 0x4:
+ if(!sam_io_sam_dispinfo_4("user list",
+ r_u->ctr->sam.info4,
+ r_u->num_entries, ps, depth))
+ return False;
+ break;
+ case 0x5:
+ if(!sam_io_sam_dispinfo_5("group list",
+ r_u->ctr->sam.info5,
+ r_u->num_entries, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
+ break;
+ }
+
if(!prs_align(ps))
return False;
-
- if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
- return False;
- if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
return True;
}
/*******************************************************************
-inits a SAM_ENTRY3 structure.
+inits a GROUP_INFO1 structure.
********************************************************************/
-static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
- UNISTR2 *grp_name, UNISTR2 *grp_desc,
- uint32 rid_grp)
+void init_samr_group_info1(GROUP_INFO1 * gr1,
+ char *acct_name, char *acct_desc,
+ uint32 num_members)
{
- DEBUG(5, ("init_sam_entry3\n"));
+ DEBUG(5, ("init_samr_group_info1\n"));
- sam->grp_idx = grp_idx;
- sam->rid_grp = rid_grp;
- sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
+ gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
+ gr1->num_members = num_members;
- init_uni_hdr(&sam->hdr_grp_name, grp_name);
- init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
+ init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
+ init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
}
/*******************************************************************
-reads or writes a SAM_ENTRY3 structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
- prs_struct *ps, int depth)
+bool samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
+ prs_struct *ps, int depth)
{
- if (sam == NULL)
+ uint16 dummy = 1;
+
+ if (gr1 == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_entry3");
+ prs_debug(ps, depth, desc, "samr_io_group_info1");
depth++;
+ if(!prs_uint16("level", ps, depth, &dummy))
+ return False;
+
if(!prs_align(ps))
return False;
- if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
+ if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
return False;
- if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
+ if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
return False;
- if(!prs_uint32("attr ", ps, depth, &sam->attr))
+ if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
return False;
- if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
+ if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
return False;
- if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
+
+ if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
+ gr1->hdr_acct_name.buffer, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
+ gr1->hdr_acct_desc.buffer, ps, depth))
return False;
return True;
}
/*******************************************************************
-inits a SAM_ENTRY4 structure.
+inits a GROUP_INFO2 structure.
********************************************************************/
-static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
- uint32 len_acct_name)
+void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
{
- DEBUG(5, ("init_sam_entry4\n"));
+ DEBUG(5, ("init_samr_group_info2\n"));
- sam->user_idx = user_idx;
- init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
+ gr2->level = 2;
+ init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
}
/*******************************************************************
-reads or writes a SAM_ENTRY4 structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
- prs_struct *ps, int depth)
+bool samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
{
- if (sam == NULL)
+ if (gr2 == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_entry4");
+ prs_debug(ps, depth, desc, "samr_io_group_info2");
depth++;
- if(!prs_align(ps))
+ if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
return False;
- if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
+ if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
return False;
- if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
+ if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
+ gr2->hdr_acct_name.buffer, ps, depth))
return False;
return True;
}
/*******************************************************************
-inits a SAM_ENTRY5 structure.
+inits a GROUP_INFO3 structure.
********************************************************************/
-static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
- uint32 len_grp_name)
+void init_samr_group_info3(GROUP_INFO3 *gr3)
{
- DEBUG(5, ("init_sam_entry5\n"));
+ DEBUG(5, ("init_samr_group_info3\n"));
- sam->grp_idx = grp_idx;
- init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
- len_grp_name != 0);
+ gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
}
/*******************************************************************
-reads or writes a SAM_ENTRY5 structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
- prs_struct *ps, int depth)
+bool samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
{
- if (sam == NULL)
+ if (gr3 == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_entry5");
+ prs_debug(ps, depth, desc, "samr_io_group_info3");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
- return False;
- if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
+ if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
return False;
return True;
}
/*******************************************************************
-inits a SAM_ENTRY structure.
+inits a GROUP_INFO4 structure.
********************************************************************/
-void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
+void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
{
- DEBUG(10, ("init_sam_entry: %d\n", rid));
+ DEBUG(5, ("init_samr_group_info4\n"));
- sam->rid = rid;
- init_uni_hdr(&sam->hdr_name, uni2);
+ gr4->level = 4;
+ init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
}
/*******************************************************************
-reads or writes a SAM_ENTRY structure.
+reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
- prs_struct *ps, int depth)
+bool samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
+ prs_struct *ps, int depth)
{
- if (sam == NULL)
+ if (gr4 == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_entry");
+ prs_debug(ps, depth, desc, "samr_io_group_info4");
depth++;
- if(!prs_align(ps))
+ if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
return False;
- if(!prs_uint32("rid", ps, depth, &sam->rid))
+ if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
return False;
- if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
+ if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
+ gr4->hdr_acct_desc.buffer, ps, depth))
return False;
return True;
}
/*******************************************************************
-inits a SAMR_Q_ENUM_DOM_USERS structure.
+inits a GROUP_INFO5 structure.
********************************************************************/
-void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
- uint32 start_idx,
- uint32 acb_mask, uint32 size)
+void init_samr_group_info5(GROUP_INFO5 * gr5,
+ char *acct_name, char *acct_desc,
+ uint32 num_members)
{
- DEBUG(5, ("init_samr_q_enum_dom_users\n"));
+ DEBUG(5, ("init_samr_group_info5\n"));
- q_e->pol = *pol;
+ gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
+ gr5->num_members = num_members;
- q_e->start_idx = start_idx; /* zero indicates lots */
- q_e->acb_mask = acb_mask;
- q_e->max_size = size;
+ init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
+ init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
- prs_struct *ps, int depth)
+bool samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
+ prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ uint16 dummy = 1;
+
+ if (gr5 == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
+ prs_debug(ps, depth, desc, "samr_io_group_info5");
depth++;
+ if(!prs_uint16("level", ps, depth, &dummy))
+ return False;
+
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
+ if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
return False;
- if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
+ if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
return False;
- if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
+ if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
return False;
- if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
+ if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
+ gr5->hdr_acct_name.buffer, ps, depth))
+ return False;
+
+ if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
+ gr5->hdr_acct_desc.buffer, ps, depth))
return False;
return True;
/*******************************************************************
-inits a SAMR_R_ENUM_DOM_USERS structure.
+reads or writes a structure.
********************************************************************/
-void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
- uint32 next_idx, uint32 num_sam_entries)
+static bool samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
+ prs_struct *ps, int depth)
{
- DEBUG(5, ("init_samr_r_enum_dom_users\n"));
+ if (UNMARSHALLING(ps))
+ *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
- r_u->next_idx = next_idx;
+ if (*ctr == NULL)
+ return False;
- if (num_sam_entries != 0) {
- r_u->ptr_entries1 = 1;
- r_u->ptr_entries2 = 1;
- r_u->num_entries2 = num_sam_entries;
- r_u->num_entries3 = num_sam_entries;
+ prs_debug(ps, depth, desc, "samr_group_info_ctr");
+ depth++;
- r_u->num_entries4 = num_sam_entries;
- } else {
- r_u->ptr_entries1 = 0;
- r_u->num_entries2 = num_sam_entries;
- r_u->ptr_entries2 = 1;
+ if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
+ return False;
+
+ switch ((*ctr)->switch_value1) {
+ case 1:
+ if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
+ return False;
+ break;
+ case 2:
+ if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
+ return False;
+ break;
+ case 3:
+ if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
+ return False;
+ break;
+ case 4:
+ if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
+ return False;
+ break;
+ case 5:
+ if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
+ break;
}
+
+ return True;
}
/*******************************************************************
-reads or writes a structure.
+inits a SAMR_Q_SET_GROUPINFO structure.
********************************************************************/
-bool samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
- prs_struct *ps, int depth)
+void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
+ POLICY_HND *pol, GROUP_INFO_CTR * ctr)
{
- uint32 i;
+ DEBUG(5, ("init_samr_q_set_groupinfo\n"));
- if (r_u == NULL)
+ q_e->pol = *pol;
+ q_e->ctr = ctr;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+
+bool samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
+ prs_struct *ps, int depth)
+{
+ if (q_e == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
+ prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
+ if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
return False;
- if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
+
+ if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
return False;
- if (r_u->ptr_entries1 != 0) {
- if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
- return False;
- if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
- return False;
- if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
- return False;
+ return True;
+}
- if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
- r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
- r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
- }
+/*******************************************************************
+inits a SAMR_R_SET_GROUPINFO structure.
+********************************************************************/
- if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
- DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
- r_u->num_entries4 = 0;
- r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
- return False;
- }
+void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
+{
+ DEBUG(5, ("init_samr_r_set_groupinfo\n"));
- for (i = 0; i < r_u->num_entries2; i++) {
- if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
- return False;
- }
+ r_u->status = status;
+}
- for (i = 0; i < r_u->num_entries2; i++) {
- if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
- return False;
- }
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
- }
+bool samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
+ prs_struct *ps, int depth)
+{
+ if (r_u == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
+ depth++;
if(!prs_align(ps))
return False;
-
- if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
- return False;
+
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a SAMR_Q_QUERY_DISPINFO structure.
+inits a SAMR_Q_QUERY_GROUPINFO structure.
********************************************************************/
-void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
- uint16 switch_level, uint32 start_idx,
- uint32 max_entries, uint32 max_size)
+void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
+ POLICY_HND *pol, uint16 switch_level)
{
- DEBUG(5, ("init_samr_q_query_dispinfo\n"));
+ DEBUG(5, ("init_samr_q_query_groupinfo\n"));
- q_e->domain_pol = *pol;
+ q_e->pol = *pol;
q_e->switch_level = switch_level;
-
- q_e->start_idx = start_idx;
- q_e->max_entries = max_entries;
- q_e->max_size = max_size;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
- prs_struct *ps, int depth)
+bool samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
+ prs_struct *ps, int depth)
{
if (q_e == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
+ prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
+ if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
return False;
if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
return False;
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
- return False;
- if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
- return False;
- if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
- return False;
return True;
}
/*******************************************************************
-inits a SAM_DISPINFO_1 structure.
+inits a SAMR_R_QUERY_GROUPINFO structure.
********************************************************************/
-NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
- uint32 num_entries, uint32 start_idx,
- struct samr_displayentry *entries)
+void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
+ GROUP_INFO_CTR * ctr, NTSTATUS status)
{
- uint32 i;
-
- DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
-
- if (num_entries==0)
- return NT_STATUS_OK;
-
- *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
- if (*sam == NULL)
- return NT_STATUS_NO_MEMORY;
-
- (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
- if ((*sam)->sam == NULL)
- return NT_STATUS_NO_MEMORY;
-
- (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
- if ((*sam)->str == NULL)
- return NT_STATUS_NO_MEMORY;
-
- for (i = 0; i < num_entries ; i++) {
- init_unistr2(&(*sam)->str[i].uni_acct_name,
- entries[i].account_name, UNI_FLAGS_NONE);
- init_unistr2(&(*sam)->str[i].uni_full_name,
- entries[i].fullname, UNI_FLAGS_NONE);
- init_unistr2(&(*sam)->str[i].uni_acct_desc,
- entries[i].description, UNI_FLAGS_NONE);
-
- init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
- &(*sam)->str[i].uni_acct_name,
- &(*sam)->str[i].uni_full_name,
- &(*sam)->str[i].uni_acct_desc,
- entries[i].rid, entries[i].acct_flags);
- }
+ DEBUG(5, ("init_samr_r_query_groupinfo\n"));
- return NT_STATUS_OK;
+ r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
+ r_u->ctr = ctr;
+ r_u->status = status;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
- uint32 num_entries,
- prs_struct *ps, int depth)
+bool samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
+ prs_struct *ps, int depth)
{
- uint32 i;
+ if (r_u == NULL)
+ return False;
- prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
+ prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
depth++;
if(!prs_align(ps))
return False;
- if (UNMARSHALLING(ps) && num_entries > 0) {
-
- if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
- return False;
- }
-
- if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_STR1\n"));
- return False;
- }
- }
+ if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
+ return False;
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
+ if (r_u->ptr != 0) {
+ if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
return False;
}
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_str1("", &sam->str[i],
- sam->sam[i].hdr_acct_name.buffer,
- sam->sam[i].hdr_user_name.buffer,
- sam->sam[i].hdr_user_desc.buffer, ps, depth))
- return False;
- }
+ if(!prs_align(ps))
+ return False;
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ return False;
return True;
}
/*******************************************************************
-inits a SAM_DISPINFO_2 structure.
+inits a SAMR_Q_QUERY_USERGROUPS structure.
********************************************************************/
-NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
- uint32 num_entries, uint32 start_idx,
- struct samr_displayentry *entries)
+void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
+ POLICY_HND *hnd)
{
- uint32 i;
-
- DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
+ DEBUG(5, ("init_samr_q_query_usergroups\n"));
- if (num_entries==0)
- return NT_STATUS_OK;
+ q_u->pol = *hnd;
+}
- *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
- if (*sam == NULL)
- return NT_STATUS_NO_MEMORY;
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
- (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
- if ((*sam)->sam == NULL)
- return NT_STATUS_NO_MEMORY;
+bool samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
+ prs_struct *ps, int depth)
+{
+ if (q_u == NULL)
+ return False;
- (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
- if ((*sam)->str == NULL)
- return NT_STATUS_NO_MEMORY;
+ prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
+ depth++;
- for (i = 0; i < num_entries; i++) {
- init_unistr2(&(*sam)->str[i].uni_srv_name,
- entries[i].account_name, UNI_FLAGS_NONE);
- init_unistr2(&(*sam)->str[i].uni_srv_desc,
- entries[i].description, UNI_FLAGS_NONE);
+ if(!prs_align(ps))
+ return False;
- init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
- &(*sam)->str[i].uni_srv_name,
- &(*sam)->str[i].uni_srv_desc,
- entries[i].rid, entries[i].acct_flags);
+ if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+inits a SAMR_R_QUERY_USERGROUPS structure.
+********************************************************************/
+
+void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
+ uint32 num_gids, DOM_GID * gid,
+ NTSTATUS status)
+{
+ DEBUG(5, ("init_samr_r_query_usergroups\n"));
+
+ if (NT_STATUS_IS_OK(status)) {
+ r_u->ptr_0 = 1;
+ r_u->num_entries = num_gids;
+ r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
+ r_u->num_entries2 = num_gids;
+
+ r_u->gid = gid;
+ } else {
+ r_u->ptr_0 = 0;
+ r_u->num_entries = 0;
+ r_u->ptr_1 = 0;
+ r_u->gid = NULL;
}
- return NT_STATUS_OK;
+ r_u->status = status;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
- uint32 num_entries,
- prs_struct *ps, int depth)
+bool samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
+ prs_struct *ps, int depth)
{
uint32 i;
-
- if (sam == NULL)
+ if (gid == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
+ prs_debug(ps, depth, desc, "samr_io_gids");
depth++;
if(!prs_align(ps))
return False;
- if (UNMARSHALLING(ps) && num_entries > 0) {
+ if(!prs_uint32("num_gids", ps, depth, num_gids))
+ return False;
- if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
- return False;
+ if ((*num_gids) != 0) {
+ if (UNMARSHALLING(ps)) {
+ (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
}
- if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_STR2\n"));
+ if ((*gid) == NULL) {
return False;
}
- }
-
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
- return False;
- }
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_str2("", &sam->str[i],
- sam->sam[i].hdr_srv_name.buffer,
- sam->sam[i].hdr_srv_desc.buffer, ps, depth))
- return False;
+ for (i = 0; i < (*num_gids); i++) {
+ if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
+ return False;
+ }
}
return True;
}
/*******************************************************************
-inits a SAM_DISPINFO_3 structure.
+reads or writes a structure.
********************************************************************/
-NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
- uint32 num_entries, uint32 start_idx,
- struct samr_displayentry *entries)
+bool samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
+ prs_struct *ps, int depth)
{
- uint32 i;
+ if (r_u == NULL)
+ return False;
- DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
+ prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
+ depth++;
- if (num_entries==0)
- return NT_STATUS_OK;
+ if(!prs_align(ps))
+ return False;
- *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
- if (*sam == NULL)
- return NT_STATUS_NO_MEMORY;
+ if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
+ return False;
- if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
- return NT_STATUS_NO_MEMORY;
+ if (r_u->ptr_0 != 0) {
+ if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
+ return False;
+ if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
+ return False;
- if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
- return NT_STATUS_NO_MEMORY;
+ if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
+ if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
+ return False;
+ }
+ }
- for (i = 0; i < num_entries; i++) {
- DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
+ if(!prs_align(ps))
+ return False;
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ return False;
- init_unistr2(&(*sam)->str[i].uni_grp_name,
- entries[i].account_name, UNI_FLAGS_NONE);
- init_unistr2(&(*sam)->str[i].uni_grp_desc,
- entries[i].description, UNI_FLAGS_NONE);
+ return True;
+}
- init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
- &(*sam)->str[i].uni_grp_name,
- &(*sam)->str[i].uni_grp_desc,
- entries[i].rid);
- }
+/*******************************************************************
+inits a SAMR_Q_ENUM_DOMAINS structure.
+********************************************************************/
- return NT_STATUS_OK;
+void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
+ POLICY_HND *pol,
+ uint32 start_idx, uint32 size)
+{
+ DEBUG(5, ("init_samr_q_enum_domains\n"));
+
+ q_e->pol = *pol;
+
+ q_e->start_idx = start_idx;
+ q_e->max_size = size;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
- uint32 num_entries,
- prs_struct *ps, int depth)
+bool samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
+ prs_struct *ps, int depth)
{
- uint32 i;
-
- if (sam == NULL)
+ if (q_e == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
+ prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
depth++;
if(!prs_align(ps))
return False;
- if (UNMARSHALLING(ps) && num_entries > 0) {
-
- if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
- return False;
- }
-
- if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_STR3\n"));
- return False;
- }
- }
-
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
- return False;
- }
+ if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+ return False;
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_str3("", &sam->str[i],
- sam->sam[i].hdr_grp_name.buffer,
- sam->sam[i].hdr_grp_desc.buffer, ps, depth))
- return False;
- }
+ if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
+ return False;
+ if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
+ return False;
return True;
}
/*******************************************************************
-inits a SAM_DISPINFO_4 structure.
+inits a SAMR_R_ENUM_DOMAINS structure.
********************************************************************/
-NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
- uint32 num_entries, uint32 start_idx,
- struct samr_displayentry *entries)
+void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
+ uint32 next_idx, uint32 num_sam_entries)
{
- uint32 i;
-
- DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
-
- if (num_entries==0)
- return NT_STATUS_OK;
-
- *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
- if (*sam == NULL)
- return NT_STATUS_NO_MEMORY;
-
- (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
- if ((*sam)->sam == NULL)
- return NT_STATUS_NO_MEMORY;
-
- (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
- if ((*sam)->str == NULL)
- return NT_STATUS_NO_MEMORY;
+ DEBUG(5, ("init_samr_r_enum_domains\n"));
- for (i = 0; i < num_entries; i++) {
- size_t len_sam_name = strlen(entries[i].account_name);
+ r_u->next_idx = next_idx;
- DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
-
- init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
- len_sam_name);
+ if (num_sam_entries != 0) {
+ r_u->ptr_entries1 = 1;
+ r_u->ptr_entries2 = 1;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->num_entries3 = num_sam_entries;
- init_string2(&(*sam)->str[i].acct_name,
- entries[i].account_name, len_sam_name+1,
- len_sam_name);
+ r_u->num_entries4 = num_sam_entries;
+ } else {
+ r_u->ptr_entries1 = 0;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->ptr_entries2 = 1;
}
-
- return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
- uint32 num_entries,
- prs_struct *ps, int depth)
+bool samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
+ prs_struct *ps, int depth)
{
uint32 i;
- if (sam == NULL)
+ if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
+ prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
depth++;
if(!prs_align(ps))
return False;
- if (UNMARSHALLING(ps) && num_entries > 0) {
+ if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
+ return False;
+ if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
+ return False;
- if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
+ if (r_u->ptr_entries1 != 0) {
+ if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
return False;
+ if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
+ return False;
+ if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
+ return False;
+
+ if (UNMARSHALLING(ps) && r_u->num_entries2) {
+ r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
+ r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
}
- if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_STR4\n"));
+ if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
+ DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
+ r_u->num_entries4 = 0;
+ r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
return False;
}
- }
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
- return False;
- }
+ for (i = 0; i < r_u->num_entries2; i++) {
+ fstring tmp;
+ slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
+ if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < r_u->num_entries2; i++) {
+ fstring tmp;
+ slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
+ if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
+ r_u->sam[i].hdr_name.buffer, ps,
+ depth))
+ return False;
+ }
- for (i = 0; i < num_entries; i++) {
- if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
- sam->sam[i].hdr_acct_name.buffer, ps, depth))
- return False;
}
+ if(!prs_align(ps))
+ return False;
+ if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
+ return False;
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ return False;
+
return True;
}
/*******************************************************************
-inits a SAM_DISPINFO_5 structure.
+inits a SAMR_Q_ENUM_DOM_GROUPS structure.
********************************************************************/
-NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
- uint32 num_entries, uint32 start_idx,
- struct samr_displayentry *entries)
+void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
+ POLICY_HND *pol,
+ uint32 start_idx, uint32 size)
{
- uint32 len_sam_name;
- uint32 i;
+ DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
- DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
+ q_e->pol = *pol;
- if (num_entries==0)
- return NT_STATUS_OK;
+ q_e->start_idx = start_idx;
+ q_e->max_size = size;
+}
- *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
- if (*sam == NULL)
- return NT_STATUS_NO_MEMORY;
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
- if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
- return NT_STATUS_NO_MEMORY;
+bool samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
+ prs_struct *ps, int depth)
+{
+ if (q_e == NULL)
+ return False;
- if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
- return NT_STATUS_NO_MEMORY;
+ prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
+ depth++;
- for (i = 0; i < num_entries; i++) {
- DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
+ if(!prs_align(ps))
+ return False;
- len_sam_name = strlen(entries[i].account_name);
-
- init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
- init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
- len_sam_name+1, len_sam_name);
- }
+ if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
+ return False;
- return NT_STATUS_OK;
+ if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
+ return False;
+ if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+inits a SAMR_R_ENUM_DOM_GROUPS structure.
+********************************************************************/
+
+void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
+ uint32 next_idx, uint32 num_sam_entries)
+{
+ DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
+
+ r_u->next_idx = next_idx;
+
+ if (num_sam_entries != 0) {
+ r_u->ptr_entries1 = 1;
+ r_u->ptr_entries2 = 1;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->num_entries3 = num_sam_entries;
+
+ r_u->num_entries4 = num_sam_entries;
+ } else {
+ r_u->ptr_entries1 = 0;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->ptr_entries2 = 1;
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static bool sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
- uint32 num_entries,
- prs_struct *ps, int depth)
+bool samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
+ prs_struct *ps, int depth)
{
uint32 i;
- if (sam == NULL)
+ if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
+ prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
depth++;
if(!prs_align(ps))
return False;
- if (UNMARSHALLING(ps) && num_entries > 0) {
+ if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
+ return False;
+ if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
+ return False;
- if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
+ if (r_u->ptr_entries1 != 0) {
+ if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
+ return False;
+ if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
return False;
+ if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
+ return False;
+
+ if (UNMARSHALLING(ps) && r_u->num_entries2) {
+ r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
+ r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
}
- if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
- DEBUG(0, ("out of memory allocating SAM_STR5\n"));
+ if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
+ DEBUG(0,
+ ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
+ r_u->num_entries4 = 0;
+ r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
return False;
}
- }
- for (i = 0; i < num_entries; i++) {
- if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
- return False;
- }
+ for (i = 0; i < r_u->num_entries2; i++) {
+ if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
+ return False;
+ }
- for (i = 0; i < num_entries; i++) {
- if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
- sam->sam[i].hdr_grp_name.buffer, ps, depth))
- return False;
+ for (i = 0; i < r_u->num_entries2; i++) {
+ if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
+ r_u->sam[i].hdr_name.buffer, ps, depth))
+ return False;
+ }
}
+ if(!prs_align(ps))
+ return False;
+ if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
+ return False;
+ if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ return False;
+
return True;
}
/*******************************************************************
-inits a SAMR_R_QUERY_DISPINFO structure.
+inits a SAMR_Q_ENUM_DOM_ALIASES structure.
********************************************************************/
-void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
- uint32 num_entries, uint32 total_size, uint32 data_size,
- uint16 switch_level, SAM_DISPINFO_CTR * ctr,
- NTSTATUS status)
+void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
+ POLICY_HND *pol, uint32 start_idx,
+ uint32 size)
{
- DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
-
- r_u->total_size = total_size;
-
- r_u->data_size = data_size;
-
- r_u->switch_level = switch_level;
- r_u->num_entries = num_entries;
-
- if (num_entries==0)
- r_u->ptr_entries = 0;
- else
- r_u->ptr_entries = 1;
+ DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
- r_u->num_entries2 = num_entries;
- r_u->ctr = ctr;
+ q_e->pol = *pol;
- r_u->status = status;
+ q_e->start_idx = start_idx;
+ q_e->max_size = size;
}
+
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
- prs_struct *ps, int depth)
+bool samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
+ prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ if (q_e == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
+ prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
- return False;
- if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
- return False;
- if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
- return False;
- if(!prs_align(ps))
+ if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
return False;
- if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
+ if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
return False;
- if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
+ if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
return False;
- if (r_u->ptr_entries==0) {
- if(!prs_align(ps))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
- }
+ return True;
+}
- if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
- return False;
+/*******************************************************************
+inits a SAMR_R_ENUM_DOM_ALIASES structure.
+********************************************************************/
- switch (r_u->switch_level) {
- case 0x1:
- if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
- r_u->num_entries, ps, depth))
- return False;
- break;
- case 0x2:
- if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
- r_u->num_entries, ps, depth))
- return False;
- break;
- case 0x3:
- if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
- r_u->num_entries, ps, depth))
- return False;
- break;
- case 0x4:
- if(!sam_io_sam_dispinfo_4("user list",
- r_u->ctr->sam.info4,
- r_u->num_entries, ps, depth))
- return False;
- break;
- case 0x5:
- if(!sam_io_sam_dispinfo_5("group list",
- r_u->ctr->sam.info5,
- r_u->num_entries, ps, depth))
- return False;
- break;
- default:
- DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
- break;
- }
-
- if(!prs_align(ps))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
+void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
+{
+ DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
-/*******************************************************************
-inits a SAMR_Q_OPEN_GROUP structure.
-********************************************************************/
+ r_u->next_idx = next_idx;
-void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
- POLICY_HND *hnd,
- uint32 access_mask, uint32 rid)
-{
- DEBUG(5, ("init_samr_q_open_group\n"));
+ if (num_sam_entries != 0) {
+ r_u->ptr_entries1 = 1;
+ r_u->ptr_entries2 = 1;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->num_entries3 = num_sam_entries;
- q_c->domain_pol = *hnd;
- q_c->access_mask = access_mask;
- q_c->rid_group = rid;
+ r_u->num_entries4 = num_sam_entries;
+ } else {
+ r_u->ptr_entries1 = 0;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->ptr_entries2 = 1;
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
- prs_struct *ps, int depth)
+bool samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ uint32 i;
+
+ if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_open_group");
+ prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
- return False;
-
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
+ if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
return False;
- if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
+ if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
return False;
- return True;
-}
+ if (r_u->ptr_entries1 != 0) {
+ if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
+ return False;
+ if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
+ return False;
+ if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
+ r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
+ r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
+ }
-bool samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
+ if (r_u->num_entries2 != 0 &&
+ (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
+ DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
+ r_u->num_entries4 = 0;
+ r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
+ return False;
+ }
- prs_debug(ps, depth, desc, "samr_io_r_open_group");
- depth++;
+ for (i = 0; i < r_u->num_entries2; i++) {
+ if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < r_u->num_entries2; i++) {
+ if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
+ r_u->sam[i].hdr_name.buffer, ps,
+ depth))
+ return False;
+ }
+ }
if(!prs_align(ps))
return False;
-
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
+ if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
return False;
-
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a GROUP_INFO1 structure.
+inits a ALIAS_INFO1 structure.
********************************************************************/
-void init_samr_group_info1(GROUP_INFO1 * gr1,
- char *acct_name, char *acct_desc,
- uint32 num_members)
+void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
{
- DEBUG(5, ("init_samr_group_info1\n"));
-
- gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
- gr1->num_members = num_members;
+ DEBUG(5, ("init_samr_alias_info1\n"));
- init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
- init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
- init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
+ init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
+ al1->num_member = num_member;
+ init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
+bool samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
prs_struct *ps, int depth)
{
- uint16 dummy = 1;
-
- if (gr1 == NULL)
+ if (al1 == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_group_info1");
+ prs_debug(ps, depth, desc, "samr_io_alias_info1");
depth++;
- if(!prs_uint16("level", ps, depth, &dummy))
- return False;
-
if(!prs_align(ps))
return False;
- if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
+ if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
return False;
-
- if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
+ if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
return False;
- if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
+ if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
return False;
- if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
+ if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
return False;
-
- if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
- gr1->hdr_acct_name.buffer, ps, depth))
+ if ( !prs_align(ps) )
return False;
-
- if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
- gr1->hdr_acct_desc.buffer, ps, depth))
+ if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
+ return False;
+ if ( !prs_align(ps) )
return False;
return True;
}
/*******************************************************************
-inits a GROUP_INFO2 structure.
+inits a ALIAS_INFO3 structure.
********************************************************************/
-void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
+void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
{
- DEBUG(5, ("init_samr_group_info2\n"));
+ DEBUG(5, ("init_samr_alias_info3\n"));
- gr2->level = 2;
- init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
- init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
+ init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
+bool samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
+ prs_struct *ps, int depth)
{
- if (gr2 == NULL)
+ if (al3 == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_group_info2");
+ prs_debug(ps, depth, desc, "samr_io_alias_info3");
depth++;
- if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
+ if(!prs_align(ps))
return False;
- if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
- gr2->hdr_acct_name.buffer, ps, depth))
+ if (!prs_unistr4("description", ps, depth, &al3->description))
return False;
return True;
}
/*******************************************************************
-inits a GROUP_INFO3 structure.
+reads or writes a structure.
********************************************************************/
-void init_samr_group_info3(GROUP_INFO3 *gr3)
+bool samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
+ prs_struct *ps, int depth)
{
- DEBUG(5, ("init_samr_group_info3\n"));
+ if (al2 == NULL)
+ return False;
- gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
+ prs_debug(ps, depth, desc, "samr_io_alias_info2");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (!prs_unistr4("name", ps, depth, &al2->name))
+ return False;
+
+ return True;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
+bool samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
{
- if (gr3 == NULL)
+ if ( !ctr )
return False;
- prs_debug(ps, depth, desc, "samr_io_group_info3");
+ prs_debug(ps, depth, desc, "samr_alias_info_ctr");
depth++;
- if(!prs_align(ps))
+ if ( !prs_uint16("level", ps, depth, &ctr->level) )
return False;
- if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
+ if(!prs_align(ps))
return False;
+ switch (ctr->level) {
+ case 1:
+ if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
+ return False;
+ break;
+ case 2:
+ if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
+ return False;
+ break;
+ case 3:
+ if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
+ break;
+ }
return True;
}
/*******************************************************************
-inits a GROUP_INFO4 structure.
+inits a SAMR_Q_QUERY_ALIASINFO structure.
********************************************************************/
-void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
+void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
+ POLICY_HND *pol, uint32 switch_level)
{
- DEBUG(5, ("init_samr_group_info4\n"));
+ DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
- gr4->level = 4;
- init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
+ q_e->pol = *pol;
+ q_e->level = switch_level;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
- prs_struct *ps, int depth)
+bool samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
+ prs_struct *ps, int depth)
{
- if (gr4 == NULL)
+ if ( !in )
return False;
- prs_debug(ps, depth, desc, "samr_io_group_info4");
+ prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
depth++;
- if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
- return False;
- if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
+ if(!prs_align(ps))
return False;
- if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
- gr4->hdr_acct_desc.buffer, ps, depth))
+
+ if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
+ return False;
+
+ if ( !prs_uint16("level", ps, depth, &in->level) )
return False;
return True;
}
/*******************************************************************
-inits a GROUP_INFO5 structure.
+inits a SAMR_R_QUERY_ALIASINFO structure.
********************************************************************/
-void init_samr_group_info5(GROUP_INFO5 * gr5,
- char *acct_name, char *acct_desc,
- uint32 num_members)
+void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
+ ALIAS_INFO_CTR * ctr, NTSTATUS status)
{
- DEBUG(5, ("init_samr_group_info5\n"));
-
- gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
- gr5->num_members = num_members;
+ DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
- init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
- init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
- init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
+ out->ctr = ctr;
+ out->status = status;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
- prs_struct *ps, int depth)
+bool samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
+ prs_struct *ps, int depth)
{
- uint16 dummy = 1;
-
- if (gr5 == NULL)
+ if ( !out )
return False;
- prs_debug(ps, depth, desc, "samr_io_group_info5");
+ prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
depth++;
- if(!prs_uint16("level", ps, depth, &dummy))
- return False;
-
if(!prs_align(ps))
return False;
- if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
- return False;
-
- if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
- return False;
- if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
- return False;
-
- if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
- return False;
-
- if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
- gr5->hdr_acct_name.buffer, ps, depth))
- return False;
-
- if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
- gr5->hdr_acct_desc.buffer, ps, depth))
+ if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
return False;
-
- return True;
-}
-
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
- prs_struct *ps, int depth)
-{
- if (UNMARSHALLING(ps))
- *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
-
- if (*ctr == NULL)
+ if(!prs_align(ps))
return False;
- prs_debug(ps, depth, desc, "samr_group_info_ctr");
- depth++;
-
- if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
+ if(!prs_ntstatus("status", ps, depth, &out->status))
return False;
- switch ((*ctr)->switch_value1) {
- case 1:
- if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
- return False;
- break;
- case 2:
- if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
- return False;
- break;
- case 3:
- if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
- return False;
- break;
- case 4:
- if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
- return False;
- break;
- case 5:
- if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
- return False;
- break;
- default:
- DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
- break;
- }
-
return True;
}
/*******************************************************************
-inits a SAMR_Q_CREATE_DOM_GROUP structure.
+inits a SAMR_Q_SET_ALIASINFO structure.
********************************************************************/
-void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
- POLICY_HND *pol, const char *acct_desc,
- uint32 access_mask)
+void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
+ POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
{
- DEBUG(5, ("init_samr_q_create_dom_group\n"));
-
- q_e->pol = *pol;
-
- init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
+ DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
- q_e->access_mask = access_mask;
+ q_u->alias_pol = *hnd;
+ q_u->ctr = *ctr;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
- prs_struct *ps, int depth)
+bool samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
+ prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
+ prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
- return False;
-
- if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
- q_e->hdr_acct_desc.buffer, ps, depth))
- return False;
-
- if(!prs_align(ps))
+ if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
return False;
- if(!prs_uint32("access", ps, depth, &q_e->access_mask))
+ if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
return False;
return True;
reads or writes a structure.
********************************************************************/
-bool samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
- prs_struct *ps, int depth)
+bool samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
+ prs_struct *ps, int depth)
{
if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
+ prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
depth++;
if(!prs_align(ps))
return False;
-
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
- return False;
-
- if(!prs_uint32("rid ", ps, depth, &r_u->rid))
- return False;
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a SAMR_Q_DELETE_DOM_GROUP structure.
+inits a SAMR_Q_LOOKUP_RIDS structure.
********************************************************************/
-void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
- POLICY_HND *hnd)
+void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
+ POLICY_HND *pol, uint32 flags,
+ uint32 num_rids, uint32 *rid)
{
- DEBUG(5, ("init_samr_q_delete_dom_group\n"));
+ DEBUG(5, ("init_samr_q_lookup_rids\n"));
+
+ q_u->pol = *pol;
- q_c->group_pol = *hnd;
+ q_u->num_rids1 = num_rids;
+ q_u->flags = flags;
+ q_u->ptr = 0;
+ q_u->num_rids2 = num_rids;
+ if (num_rids) {
+ q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
+ } else {
+ q_u->rid = NULL;
+ }
+ if (q_u->rid == NULL) {
+ q_u->num_rids1 = 0;
+ q_u->num_rids2 = 0;
+ } else {
+ memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
- prs_struct *ps, int depth)
+bool samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
+ prs_struct *ps, int depth)
{
+ uint32 i;
+ fstring tmp;
+
if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
+ prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
depth++;
+ if (UNMARSHALLING(ps))
+ ZERO_STRUCTP(q_u);
+
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
+ if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
return False;
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
+ if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
- depth++;
-
- if(!prs_align(ps))
+ if(!prs_uint32("flags ", ps, depth, &q_u->flags))
return False;
-
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
+ if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
return False;
+ if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
+ q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
+ if (q_u->rid == NULL)
+ return False;
+ }
+
+ for (i = 0; i < q_u->num_rids2; i++) {
+ slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
+ if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
+ return False;
+ }
+
return True;
}
/*******************************************************************
-inits a SAMR_Q_DEL_GROUPMEM structure.
+inits a SAMR_R_LOOKUP_RIDS structure.
********************************************************************/
-void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
- POLICY_HND *pol, uint32 rid)
+void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
+ uint32 num_names, UNIHDR * hdr_name,
+ UNISTR2 *uni_name, uint32 *type)
{
- DEBUG(5, ("init_samr_q_del_groupmem\n"));
+ DEBUG(5, ("init_samr_r_lookup_rids\n"));
- q_e->pol = *pol;
- q_e->rid = rid;
+ r_u->hdr_name = NULL;
+ r_u->uni_name = NULL;
+ r_u->type = NULL;
+
+ if (num_names != 0) {
+ r_u->num_names1 = num_names;
+ r_u->ptr_names = 1;
+ r_u->num_names2 = num_names;
+
+ r_u->num_types1 = num_names;
+ r_u->ptr_types = 1;
+ r_u->num_types2 = num_names;
+
+ r_u->hdr_name = hdr_name;
+ r_u->uni_name = uni_name;
+ r_u->type = type;
+ } else {
+ r_u->num_names1 = num_names;
+ r_u->ptr_names = 0;
+ r_u->num_names2 = num_names;
+
+ r_u->num_types1 = num_names;
+ r_u->ptr_types = 0;
+ r_u->num_types2 = num_names;
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
- prs_struct *ps, int depth)
+bool samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
+ prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ uint32 i;
+ fstring tmp;
+ if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
+ prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+ if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
return False;
-
- if(!prs_uint32("rid", ps, depth, &q_e->rid))
+ if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
return False;
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_DEL_GROUPMEM structure.
-********************************************************************/
+ if (r_u->ptr_names != 0) {
-void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_del_groupmem\n"));
+ if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
+ return False;
- r_u->status = status;
-}
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
+ if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
+ r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
+ if (r_u->hdr_name == NULL)
+ return False;
- prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
- depth++;
+ r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
+ if (r_u->uni_name == NULL)
+ return False;
+ }
+
+ for (i = 0; i < r_u->num_names2; i++) {
+ slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
+ if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
+ return False;
+ }
+ for (i = 0; i < r_u->num_names2; i++) {
+ slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
+ if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
+ return False;
+ }
+ }
+
if(!prs_align(ps))
return False;
+ if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
+ return False;
+ if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
+ return False;
+
+ if (r_u->ptr_types != 0) {
+
+ if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
+ return False;
+
+ if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
+ r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
+ if (r_u->type == NULL)
+ return False;
+ }
+
+ for (i = 0; i < r_u->num_types2; i++) {
+ slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
+ if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
+ return False;
+ }
+ }
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a SAMR_Q_ADD_GROUPMEM structure.
+inits a SAMR_Q_LOOKUP_NAMES structure.
********************************************************************/
-void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
- POLICY_HND *pol, uint32 rid)
+NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
+ POLICY_HND *pol, uint32 flags,
+ uint32 num_names, const char **name)
{
- DEBUG(5, ("init_samr_q_add_groupmem\n"));
+ uint32 i;
- q_e->pol = *pol;
- q_e->rid = rid;
- q_e->unknown = 0x0005;
+ DEBUG(5, ("init_samr_q_lookup_names\n"));
+
+ q_u->pol = *pol;
+
+ q_u->num_names1 = num_names;
+ q_u->flags = flags;
+ q_u->ptr = 0;
+ q_u->num_names2 = num_names;
+
+ if (num_names) {
+ if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
+ return NT_STATUS_NO_MEMORY;
+
+ if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
+ return NT_STATUS_NO_MEMORY;
+ } else {
+ q_u->hdr_name = NULL;
+ q_u->uni_name = NULL;
+ }
+
+ for (i = 0; i < num_names; i++) {
+ init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
+ init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
+ }
+
+ return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
+bool samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ uint32 i;
+
+ if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
+ prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
depth++;
+ if (UNMARSHALLING(ps))
+ ZERO_STRUCTP(q_u);
+
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+ if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
return False;
- if(!prs_uint32("rid ", ps, depth, &q_e->rid))
+ if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
+ return False;
+ if(!prs_uint32("flags ", ps, depth, &q_u->flags))
return False;
- if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
+ if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
+ return False;
+ if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
return False;
+ if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
+ q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
+ q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
+ if (!q_u->hdr_name || !q_u->uni_name)
+ return False;
+ }
+
+ for (i = 0; i < q_u->num_names2; i++) {
+ if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < q_u->num_names2; i++) {
+ if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
+ return False;
+ }
+
return True;
}
/*******************************************************************
-inits a SAMR_R_ADD_GROUPMEM structure.
+inits a SAMR_R_LOOKUP_NAMES structure.
********************************************************************/
-void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
+NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
+ uint32 num_rids,
+ uint32 *rid, enum lsa_SidType *type,
NTSTATUS status)
{
- DEBUG(5, ("init_samr_r_add_groupmem\n"));
+ DEBUG(5, ("init_samr_r_lookup_names\n"));
+
+ if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
+ uint32 i;
+
+ r_u->num_types1 = num_rids;
+ r_u->ptr_types = 1;
+ r_u->num_types2 = num_rids;
+
+ r_u->num_rids1 = num_rids;
+ r_u->ptr_rids = 1;
+ r_u->num_rids2 = num_rids;
+
+ if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
+ return NT_STATUS_NO_MEMORY;
+ if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
+ return NT_STATUS_NO_MEMORY;
+
+ for (i = 0; i < num_rids; i++) {
+ r_u->rids[i] = rid[i];
+ r_u->types[i] = type[i];
+ }
+ } else {
+
+ r_u->num_types1 = 0;
+ r_u->ptr_types = 0;
+ r_u->num_types2 = 0;
+
+ r_u->num_rids1 = 0;
+ r_u->ptr_rids = 0;
+ r_u->num_rids2 = 0;
+
+ r_u->rids = NULL;
+ r_u->types = NULL;
+ }
r_u->status = status;
+
+ return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
+bool samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
prs_struct *ps, int depth)
{
+ uint32 i;
+ fstring tmp;
+
if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
+ prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
depth++;
+ if (UNMARSHALLING(ps))
+ ZERO_STRUCTP(r_u);
+
if(!prs_align(ps))
return False;
+ if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
+ return False;
+ if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
+ return False;
+
+ if (r_u->ptr_rids != 0) {
+ if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
+ return False;
+
+ if (r_u->num_rids2 != r_u->num_rids1) {
+ /* RPC fault */
+ return False;
+ }
+
+ if (UNMARSHALLING(ps) && r_u->num_rids2) {
+ r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
+
+ if (!r_u->rids) {
+ DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
+ return False;
+ }
+ }
+
+ for (i = 0; i < r_u->num_rids2; i++) {
+ slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
+ if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
+ return False;
+ }
+ }
+
+ if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
+ return False;
+ if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
+ return False;
+
+ if (r_u->ptr_types != 0) {
+ if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
+ return False;
+
+ if (r_u->num_types2 != r_u->num_types1) {
+ /* RPC fault */
+ return False;
+ }
+
+ if (UNMARSHALLING(ps) && r_u->num_types2) {
+ r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
+
+ if (!r_u->types) {
+ DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
+ return False;
+ }
+ }
+
+ for (i = 0; i < r_u->num_types2; i++) {
+ slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
+ if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
+ return False;
+ }
+ }
+
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a SAMR_Q_SET_GROUPINFO structure.
+inits a SAMR_Q_QUERY_USERINFO structure.
********************************************************************/
-void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
- POLICY_HND *pol, GROUP_INFO_CTR * ctr)
+void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
+ const POLICY_HND *hnd, uint16 switch_value)
{
- DEBUG(5, ("init_samr_q_set_groupinfo\n"));
+ DEBUG(5, ("init_samr_q_query_userinfo\n"));
- q_e->pol = *pol;
- q_e->ctr = ctr;
+ q_u->pol = *hnd;
+ q_u->switch_value = switch_value;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
- prs_struct *ps, int depth)
+bool samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
+ prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
+ prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+ if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
return False;
-
- if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
+
+ if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
return False;
return True;
}
/*******************************************************************
-inits a SAMR_R_SET_GROUPINFO structure.
+reads or writes a LOGON_HRS structure.
********************************************************************/
-void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
+static bool sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
+ prs_struct *ps, int depth)
{
- DEBUG(5, ("init_samr_r_set_groupinfo\n"));
+ if (hrs == NULL)
+ return False;
- r_u->status = status;
-}
+ prs_debug(ps, depth, desc, "sam_io_logon_hrs");
+ depth++;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ if(!prs_align(ps))
+ return False;
-bool samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
+ if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
return False;
- prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
- depth++;
+ if(!prs_uint32("offset", ps, depth, &hrs->offset))
+ return False;
- if(!prs_align(ps))
+ if(!prs_uint32("len ", ps, depth, &hrs->len))
return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if (hrs->len > sizeof(hrs->hours)) {
+ DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
+ hrs->len = sizeof(hrs->hours);
+ }
+
+ if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
return False;
return True;
}
/*******************************************************************
-inits a SAMR_Q_QUERY_GROUPINFO structure.
+inits a SAM_USER_INFO_18 structure.
********************************************************************/
-void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
- POLICY_HND *pol, uint16 switch_level)
+void init_sam_user_info18(SAM_USER_INFO_18 * usr,
+ const uint8 lm_pwd[16], const uint8 nt_pwd[16])
{
- DEBUG(5, ("init_samr_q_query_groupinfo\n"));
-
- q_e->pol = *pol;
+ DEBUG(5, ("init_sam_user_info18\n"));
- q_e->switch_level = switch_level;
+ usr->lm_pwd_active =
+ memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
+ usr->nt_pwd_active =
+ memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
- prs_struct *ps, int depth)
+static bool sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
+ prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ if (u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
+ prs_debug(ps, depth, desc, "samr_io_r_user_info18");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+ if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
+ return False;
+ if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
return False;
- if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
+ if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
+ return False;
+ if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
return False;
return True;
}
/*******************************************************************
-inits a SAMR_R_QUERY_GROUPINFO structure.
+inits a SAM_USER_INFO_7 structure.
********************************************************************/
-void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
- GROUP_INFO_CTR * ctr, NTSTATUS status)
+void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
{
- DEBUG(5, ("init_samr_r_query_groupinfo\n"));
+ DEBUG(5, ("init_sam_user_info7\n"));
+
+ init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
+ init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
- r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
- r_u->ctr = ctr;
- r_u->status = status;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
+ prs_struct *ps, int depth)
{
- if (r_u == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
+ prs_debug(ps, depth, desc, "samr_io_r_user_info7");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
+ if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
return False;
- if (r_u->ptr != 0) {
- if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
- return False;
- }
-
- if(!prs_align(ps))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
return False;
return True;
}
/*******************************************************************
-inits a SAMR_Q_QUERY_GROUPMEM structure.
+inits a SAM_USER_INFO_9 structure.
********************************************************************/
-void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
+void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
{
- DEBUG(5, ("init_samr_q_query_groupmem\n"));
+ DEBUG(5, ("init_sam_user_info9\n"));
- q_c->group_pol = *hnd;
+ usr->rid_group = rid_group;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
+ prs_debug(ps, depth, desc, "samr_io_r_user_info9");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
+ if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
return False;
return True;
}
/*******************************************************************
-inits a SAMR_R_QUERY_GROUPMEM structure.
+inits a SAM_USER_INFO_16 structure.
********************************************************************/
-void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
- uint32 num_entries, uint32 *rid,
- uint32 *attr, NTSTATUS status)
+void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
{
- DEBUG(5, ("init_samr_r_query_groupmem\n"));
-
- if (NT_STATUS_IS_OK(status)) {
- r_u->ptr = 1;
- r_u->num_entries = num_entries;
-
- r_u->ptr_attrs = attr != NULL ? 1 : 0;
- r_u->ptr_rids = rid != NULL ? 1 : 0;
-
- r_u->num_rids = num_entries;
- r_u->rid = rid;
-
- r_u->num_attrs = num_entries;
- r_u->attr = attr;
- } else {
- r_u->ptr = 0;
- r_u->num_entries = 0;
- }
+ DEBUG(5, ("init_sam_user_info16\n"));
- r_u->status = status;
+ usr->acb_info = acb_info;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
+ prs_struct *ps, int depth)
{
- uint32 i;
-
- if (r_u == NULL)
+ if (usr == NULL)
return False;
- if (UNMARSHALLING(ps))
- ZERO_STRUCTP(r_u);
-
- prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
+ prs_debug(ps, depth, desc, "samr_io_r_user_info16");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
- return False;
- if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
- return False;
-
- if (r_u->ptr != 0) {
- if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
- return False;
- if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
- return False;
-
- if (r_u->ptr_rids != 0) {
- if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
- return False;
- if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
- r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
- if (r_u->rid == NULL)
- return False;
- }
-
- for (i = 0; i < r_u->num_rids; i++) {
- if(!prs_uint32("", ps, depth, &r_u->rid[i]))
- return False;
- }
- }
-
- if (r_u->ptr_attrs != 0) {
- if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
- return False;
-
- if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
- r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
- if (r_u->attr == NULL)
- return False;
- }
-
- for (i = 0; i < r_u->num_attrs; i++) {
- if(!prs_uint32("", ps, depth, &r_u->attr[i]))
- return False;
- }
- }
- }
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
return False;
return True;
}
/*******************************************************************
-inits a SAMR_Q_QUERY_USERGROUPS structure.
+inits a SAM_USER_INFO_17 structure.
********************************************************************/
-void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
- POLICY_HND *hnd)
+void init_sam_user_info17(SAM_USER_INFO_17 * usr,
+ NTTIME * expiry,
+ char *mach_acct,
+ uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
{
- DEBUG(5, ("init_samr_q_query_usergroups\n"));
-
- q_u->pol = *hnd;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ DEBUG(5, ("init_sam_user_info17\n"));
-bool samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
+ memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
+ ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
- prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
- depth++;
+ usr->padding_2 = 0; /* 0 - padding 4 bytes */
- if(!prs_align(ps))
- return False;
+ usr->ptr_1 = 1; /* pointer */
+ ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
+ usr->padding_4 = 0; /* 0 - padding 4 bytes */
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
- return False;
+ usr->ptr_2 = 1; /* pointer */
+ usr->padding_5 = 0; /* 0 - padding 4 bytes */
- return True;
-}
+ usr->ptr_3 = 1; /* pointer */
+ ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
-/*******************************************************************
-inits a SAMR_R_QUERY_USERGROUPS structure.
-********************************************************************/
+ usr->rid_user = rid_user;
+ usr->rid_group = rid_group;
-void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
- uint32 num_gids, DOM_GID * gid,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_usergroups\n"));
+ usr->acct_ctrl = acct_ctrl;
+ usr->unknown_3 = 0x0000;
- if (NT_STATUS_IS_OK(status)) {
- r_u->ptr_0 = 1;
- r_u->num_entries = num_gids;
- r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
- r_u->num_entries2 = num_gids;
+ usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
+ usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
- r_u->gid = gid;
- } else {
- r_u->ptr_0 = 0;
- r_u->num_entries = 0;
- r_u->ptr_1 = 0;
- r_u->gid = NULL;
- }
+ ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
+ usr->padding_8 = 0; /* 0 - padding 4 bytes */
- r_u->status = status;
+ init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
+ init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
- prs_struct *ps, int depth)
+static bool sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
+ prs_struct *ps, int depth)
{
- uint32 i;
- if (gid == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_gids");
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("num_gids", ps, depth, num_gids))
+ if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
return False;
- if ((*num_gids) != 0) {
- if (UNMARSHALLING(ps)) {
- (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
- }
+ if(!smb_io_time("time", &usr->expiry, ps, depth))
+ return False;
- if ((*gid) == NULL) {
- return False;
- }
+ if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
+ return False;
- for (i = 0; i < (*num_gids); i++) {
- if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
- return False;
- }
- }
+ if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
+ return False;
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
+ if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
return False;
- prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
- depth++;
-
- if(!prs_align(ps))
+ if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
return False;
-
- if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
+ if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
return False;
- if (r_u->ptr_0 != 0) {
- if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
- return False;
- if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
- return False;
-
- if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
- if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
- return False;
- }
- }
-
- if(!prs_align(ps))
+ if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_ENUM_DOMAINS structure.
-********************************************************************/
-
-void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
- POLICY_HND *pol,
- uint32 start_idx, uint32 size)
-{
- DEBUG(5, ("init_samr_q_enum_domains\n"));
-
- q_e->pol = *pol;
- q_e->start_idx = start_idx;
- q_e->max_size = size;
-}
+ if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
+ return False;
+ if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
+ return False;
+ if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
+ return False;
-bool samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
- prs_struct *ps, int depth)
-{
- if (q_e == NULL)
+ if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
+ return False;
+ if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
+ return False;
+ if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
+ return False;
+ if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
+ return False;
+ if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
+ return False;
+ if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
return False;
- prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
- depth++;
+ if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
+ return False;
- if(!prs_align(ps))
+ if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
return False;
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
+ if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
return False;
- if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
+ if(!prs_align(ps))
return False;
- if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
+
+ if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
return False;
return True;
}
-/*******************************************************************
-inits a SAMR_R_ENUM_DOMAINS structure.
-********************************************************************/
+/*************************************************************************
+ init_sam_user_infoa
+ *************************************************************************/
-void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
- uint32 next_idx, uint32 num_sam_entries)
+void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
+ uint8 pw_len)
{
- DEBUG(5, ("init_samr_r_enum_domains\n"));
-
- r_u->next_idx = next_idx;
-
- if (num_sam_entries != 0) {
- r_u->ptr_entries1 = 1;
- r_u->ptr_entries2 = 1;
- r_u->num_entries2 = num_sam_entries;
- r_u->num_entries3 = num_sam_entries;
-
- r_u->num_entries4 = num_sam_entries;
- } else {
- r_u->ptr_entries1 = 0;
- r_u->num_entries2 = num_sam_entries;
- r_u->ptr_entries2 = 1;
- }
+ DEBUG(10, ("init_sam_user_info24:\n"));
+ memcpy(usr->pass, newpass, sizeof(usr->pass));
+ usr->pw_len = pw_len;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
- prs_struct *ps, int depth)
+static bool sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
+ prs_struct *ps, int depth)
{
- uint32 i;
-
- if (r_u == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
+ prs_debug(ps, depth, desc, "sam_io_user_info24");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
- return False;
- if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
+ if(!prs_uint8s(False, "password", ps, depth, usr->pass,
+ sizeof(usr->pass)))
return False;
-
- if (r_u->ptr_entries1 != 0) {
- if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
- return False;
- if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
- return False;
- if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
+
+ if (MARSHALLING(ps) && (usr->pw_len != 0)) {
+ if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
return False;
-
- if (UNMARSHALLING(ps) && r_u->num_entries2) {
- r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
- r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
- }
-
- if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
- DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
- r_u->num_entries4 = 0;
- r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
+ } else if (UNMARSHALLING(ps)) {
+ if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
return False;
- }
-
- for (i = 0; i < r_u->num_entries2; i++) {
- fstring tmp;
- slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
- if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
- return False;
- }
-
- for (i = 0; i < r_u->num_entries2; i++) {
- fstring tmp;
- slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
- if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
- r_u->sam[i].hdr_name.buffer, ps,
- depth))
- return False;
- }
-
}
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
return True;
}
-/*******************************************************************
-inits a SAMR_Q_ENUM_DOM_GROUPS structure.
-********************************************************************/
-
-void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
- POLICY_HND *pol,
- uint32 start_idx, uint32 size)
-{
- DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
-
- q_e->pol = *pol;
-
- q_e->start_idx = start_idx;
- q_e->max_size = size;
-}
-
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
+static bool sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
prs_struct *ps, int depth)
{
- if (q_e == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
+ prs_debug(ps, depth, desc, "sam_io_user_info26");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
- return False;
-
- if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
+ if(!prs_uint8s(False, "password", ps, depth, usr->pass,
+ sizeof(usr->pass)))
return False;
- if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
+
+ if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
return False;
return True;
}
-/*******************************************************************
-inits a SAMR_R_ENUM_DOM_GROUPS structure.
-********************************************************************/
-
-void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
- uint32 next_idx, uint32 num_sam_entries)
-{
- DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
-
- r_u->next_idx = next_idx;
-
- if (num_sam_entries != 0) {
- r_u->ptr_entries1 = 1;
- r_u->ptr_entries2 = 1;
- r_u->num_entries2 = num_sam_entries;
- r_u->num_entries3 = num_sam_entries;
-
- r_u->num_entries4 = num_sam_entries;
- } else {
- r_u->ptr_entries1 = 0;
- r_u->num_entries2 = num_sam_entries;
- r_u->ptr_entries2 = 1;
- }
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
- if (r_u == NULL)
- return False;
+/*************************************************************************
+ init_sam_user_info23
- prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
- depth++;
+ unknown_6 = 0x0000 04ec
- if(!prs_align(ps))
- return False;
+ *************************************************************************/
- if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
- return False;
- if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
- return False;
-
- if (r_u->ptr_entries1 != 0) {
- if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
- return False;
- if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
- return False;
- if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
- return False;
+void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
+ NTTIME * logoff_time, /* all zeros */
+ NTTIME * kickoff_time, /* all zeros */
+ NTTIME * pass_last_set_time, /* all zeros */
+ NTTIME * pass_can_change_time, /* all zeros */
+ NTTIME * pass_must_change_time, /* all zeros */
+ UNISTR2 *user_name,
+ UNISTR2 *full_name,
+ UNISTR2 *home_dir,
+ UNISTR2 *dir_drive,
+ UNISTR2 *log_scr,
+ UNISTR2 *prof_path,
+ UNISTR2 *desc,
+ UNISTR2 *wkstas,
+ UNISTR2 *unk_str,
+ UNISTR2 *mung_dial,
+ uint32 user_rid, /* 0x0000 0000 */
+ uint32 group_rid,
+ uint32 acb_info,
+ uint32 fields_present,
+ uint16 logon_divs,
+ LOGON_HRS * hrs,
+ uint16 bad_password_count,
+ uint16 logon_count,
+ char newpass[516])
+{
+ usr->logon_time = *logon_time; /* all zeros */
+ usr->logoff_time = *logoff_time; /* all zeros */
+ usr->kickoff_time = *kickoff_time; /* all zeros */
+ usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
+ usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
+ usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
- if (UNMARSHALLING(ps) && r_u->num_entries2) {
- r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
- r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
- }
+ ZERO_STRUCT(usr->nt_pwd);
+ ZERO_STRUCT(usr->lm_pwd);
- if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
- DEBUG(0,
- ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
- r_u->num_entries4 = 0;
- r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
- return False;
- }
+ usr->user_rid = user_rid; /* 0x0000 0000 */
+ usr->group_rid = group_rid;
+ usr->acb_info = acb_info;
+ usr->fields_present = fields_present; /* 09f8 27fa */
- for (i = 0; i < r_u->num_entries2; i++) {
- if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
- return False;
- }
+ usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
+ usr->ptr_logon_hrs = hrs ? 1 : 0;
- for (i = 0; i < r_u->num_entries2; i++) {
- if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
- r_u->sam[i].hdr_name.buffer, ps, depth))
- return False;
- }
+ if (nt_time_is_zero(pass_must_change_time)) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
+ } else {
+ usr->passmustchange=0;
}
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
- return True;
-}
+ usr->bad_password_count = bad_password_count;
+ usr->logon_count = logon_count;
-/*******************************************************************
-inits a SAMR_Q_ENUM_DOM_ALIASES structure.
-********************************************************************/
+ memcpy(usr->pass, newpass, sizeof(usr->pass));
-void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
- POLICY_HND *pol, uint32 start_idx,
- uint32 size)
-{
- DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
+ copy_unistr2(&usr->uni_user_name, user_name);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
- q_e->pol = *pol;
+ copy_unistr2(&usr->uni_full_name, full_name);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
- q_e->start_idx = start_idx;
- q_e->max_size = size;
-}
+ copy_unistr2(&usr->uni_home_dir, home_dir);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
+ copy_unistr2(&usr->uni_dir_drive, dir_drive);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ copy_unistr2(&usr->uni_logon_script, log_scr);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
-bool samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
- prs_struct *ps, int depth)
-{
- if (q_e == NULL)
- return False;
+ copy_unistr2(&usr->uni_profile_path, prof_path);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
- prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
- depth++;
+ copy_unistr2(&usr->uni_acct_desc, desc);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
- if(!prs_align(ps))
- return False;
+ copy_unistr2(&usr->uni_workstations, wkstas);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
- if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
- return False;
+ copy_unistr2(&usr->uni_comment, unk_str);
+ init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
- if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
- return False;
- if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
- return False;
+ copy_unistr2(&usr->uni_munged_dial, mung_dial);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
- return True;
+ if (hrs) {
+ memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
+ } else {
+ ZERO_STRUCT(usr->logon_hrs);
+ }
}
-/*******************************************************************
-inits a SAMR_R_ENUM_DOM_ALIASES structure.
-********************************************************************/
+/*************************************************************************
+ init_sam_user_info23
-void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
+ unknown_6 = 0x0000 04ec
+
+ *************************************************************************/
+
+void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
+ NTTIME * logoff_time, /* all zeros */
+ NTTIME * kickoff_time, /* all zeros */
+ NTTIME * pass_last_set_time, /* all zeros */
+ NTTIME * pass_can_change_time, /* all zeros */
+ NTTIME * pass_must_change_time, /* all zeros */
+ char *user_name, /* NULL */
+ char *full_name,
+ char *home_dir, char *dir_drive, char *log_scr,
+ char *prof_path, const char *desc, char *wkstas,
+ char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
+ uint32 group_rid, uint32 acb_info,
+ uint32 fields_present, uint16 logon_divs,
+ LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
+ char newpass[516])
{
- DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
+ DATA_BLOB blob = base64_decode_data_blob(mung_dial);
+
+ usr->logon_time = *logon_time; /* all zeros */
+ usr->logoff_time = *logoff_time; /* all zeros */
+ usr->kickoff_time = *kickoff_time; /* all zeros */
+ usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
+ usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
+ usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
- r_u->next_idx = next_idx;
+ ZERO_STRUCT(usr->nt_pwd);
+ ZERO_STRUCT(usr->lm_pwd);
- if (num_sam_entries != 0) {
- r_u->ptr_entries1 = 1;
- r_u->ptr_entries2 = 1;
- r_u->num_entries2 = num_sam_entries;
- r_u->num_entries3 = num_sam_entries;
+ usr->user_rid = user_rid; /* 0x0000 0000 */
+ usr->group_rid = group_rid;
+ usr->acb_info = acb_info;
+ usr->fields_present = fields_present; /* 09f8 27fa */
- r_u->num_entries4 = num_sam_entries;
+ usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
+ usr->ptr_logon_hrs = hrs ? 1 : 0;
+
+ if (nt_time_is_zero(pass_must_change_time)) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
} else {
- r_u->ptr_entries1 = 0;
- r_u->num_entries2 = num_sam_entries;
- r_u->ptr_entries2 = 1;
+ usr->passmustchange=0;
}
-}
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
-bool samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
+ usr->bad_password_count = bad_password_count;
+ usr->logon_count = logon_count;
- if (r_u == NULL)
- return False;
+ memcpy(usr->pass, newpass, sizeof(usr->pass));
- prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
- depth++;
+ init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
- if(!prs_align(ps))
- return False;
+ init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
- if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
- return False;
- if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
- return False;
+ init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
- if (r_u->ptr_entries1 != 0) {
- if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
- return False;
- if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
- return False;
- if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
- return False;
+ init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
- if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
- r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
- r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
- }
+ init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
- if (r_u->num_entries2 != 0 &&
- (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
- DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
- r_u->num_entries4 = 0;
- r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
- return False;
- }
+ init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
- for (i = 0; i < r_u->num_entries2; i++) {
- if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
- return False;
- }
+ init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
- for (i = 0; i < r_u->num_entries2; i++) {
- if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
- r_u->sam[i].hdr_name.buffer, ps,
- depth))
- return False;
- }
- }
+ init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
- return True;
+ init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
+
+ data_blob_free(&blob);
+
+ if (hrs) {
+ memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
+ } else {
+ ZERO_STRUCT(usr->logon_hrs);
+ }
}
-/*******************************************************************
-inits a ALIAS_INFO1 structure.
-********************************************************************/
-void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
+/*************************************************************************
+ init_samr_user_info25P
+ fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
+*************************************************************************/
+
+void init_sam_user_info25P(SAM_USER_INFO_25 * usr,
+ uint32 fields_present, uint32 acb_info,
+ char newpass[532])
{
- DEBUG(5, ("init_samr_alias_info1\n"));
+ usr->fields_present = fields_present;
+ ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
- init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
- al1->num_member = num_member;
- init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
+ usr->acb_info = acb_info;
+ memcpy(usr->pass, newpass, sizeof(usr->pass));
}
+
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
- prs_struct *ps, int depth)
+static bool sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
+ prs_struct *ps, int depth)
{
- if (al1 == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_alias_info1");
+ prs_debug(ps, depth, desc, "sam_io_user_info23");
depth++;
if(!prs_align(ps))
return False;
- if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
+ if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
return False;
- if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
+ if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
return False;
- if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
+ if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
return False;
- if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
+ if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
return False;
- if ( !prs_align(ps) )
+ if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
return False;
- if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
+ if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
return False;
- if ( !prs_align(ps) )
+ if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
+ return False;
+ if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
+ return False;
+ if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
+ return False;
+ if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
+ return False;
+ if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
return False;
- return True;
-}
-
-/*******************************************************************
-inits a ALIAS_INFO3 structure.
-********************************************************************/
-
-void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
-{
- DEBUG(5, ("init_samr_alias_info3\n"));
-
- init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
- prs_struct *ps, int depth)
-{
- if (al3 == NULL)
+ if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
+ return False;
+ if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
return False;
- prs_debug(ps, depth, desc, "samr_io_alias_info3");
- depth++;
+ if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
+ return False;
+ if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
+ return False;
+ if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
+ return False;
+ if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
+ return False;
+ if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
+ return False;
if(!prs_align(ps))
return False;
+ if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
+ return False;
- if (!prs_unistr4("description", ps, depth, &al3->description))
+ if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
+ return False;
+ if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
return False;
- return True;
-}
+ if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
+ return False;
+ if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
+ return False;
+ if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-bool samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
- prs_struct *ps, int depth)
-{
- if (al2 == NULL)
+ if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
return False;
- prs_debug(ps, depth, desc, "samr_io_alias_info2");
- depth++;
+ /* here begins pointed-to data */
- if(!prs_align(ps))
+ if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
return False;
- if (!prs_unistr4("name", ps, depth, &al2->name))
+ if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
return False;
- return True;
-}
+ if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
+ return False;
-bool samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
-{
- if ( !ctr )
+ if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
return False;
- prs_debug(ps, depth, desc, "samr_alias_info_ctr");
- depth++;
+ if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
+ return False;
- if ( !prs_uint16("level", ps, depth, &ctr->level) )
+ if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
return False;
- if(!prs_align(ps))
+ if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
return False;
- switch (ctr->level) {
- case 1:
- if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
- return False;
- break;
- case 2:
- if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
- return False;
- break;
- case 3:
- if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
- return False;
- break;
- default:
- DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
- break;
- }
- return True;
-}
+ if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
+ return False;
-/*******************************************************************
-inits a SAMR_Q_QUERY_ALIASINFO structure.
-********************************************************************/
+ if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
+ return False;
-void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
- POLICY_HND *pol, uint32 switch_level)
-{
- DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
+ /* ok, this is only guess-work (as usual) */
+ if (usr->ptr_logon_hrs) {
+ if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
+ return False;
+ }
- q_e->pol = *pol;
- q_e->level = switch_level;
+ return True;
}
/*******************************************************************
-reads or writes a structure.
+ reads or writes a structure.
+ NB. This structure is *definately* incorrect. It's my best guess
+ currently for W2K SP2. The password field is encrypted in a different
+ way than normal... And there are definately other problems. JRA.
********************************************************************/
-bool samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
- prs_struct *ps, int depth)
+static bool sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
{
- if ( !in )
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
+ prs_debug(ps, depth, desc, "sam_io_user_info25");
depth++;
if(!prs_align(ps))
return False;
- if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
+ if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
return False;
-
- if ( !prs_uint16("level", ps, depth, &in->level) )
+ if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
+ return False;
+ if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
return False;
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_QUERY_ALIASINFO structure.
-********************************************************************/
-
-void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
- ALIAS_INFO_CTR * ctr, NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
-
- out->ctr = ctr;
- out->status = status;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
- prs_struct *ps, int depth)
-{
- if ( !out )
+ if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
+ return False;
+ if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
+ return False;
+ if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
+ return False;
+ if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
+ return False;
+ if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
return False;
- prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
- depth++;
+ if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
+ return False;
+ if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
+ return False;
- if(!prs_align(ps))
+ if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
+ return False;
+ if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
+ return False;
+ if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
+ return False;
+ if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
return False;
- if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
+ if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
return False;
if(!prs_align(ps))
return False;
-
- if(!prs_ntstatus("status", ps, depth, &out->status))
+ if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
return False;
- return True;
-}
+ if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
+ return False;
+ if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
+ return False;
-/*******************************************************************
-inits a SAMR_Q_SET_ALIASINFO structure.
-********************************************************************/
+ if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
+ return False;
+ if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
+ return False;
+ if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
+ return False;
-void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
- POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
-{
- DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
- q_u->alias_pol = *hnd;
- q_u->ctr = *ctr;
-}
+ if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ /* here begins pointed-to data */
-bool samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
+ if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
return False;
- prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
- depth++;
-
- if(!prs_align(ps))
+ if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
return False;
- if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
+ if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
return False;
- if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
+
+ if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
return False;
- return True;
-}
+ if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
+ return False;
-bool samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
+ if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
return False;
- prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
- depth++;
+ if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
+ return False;
- if(!prs_align(ps))
+ if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+
+ if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
return False;
+ /* ok, this is only guess-work (as usual) */
+ if (usr->ptr_logon_hrs) {
+ if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
+ return False;
+ }
+
return True;
}
-/*******************************************************************
-inits a SAMR_Q_QUERY_USERALIASES structure.
-********************************************************************/
-
-void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
- POLICY_HND *hnd,
- uint32 num_sids,
- uint32 *ptr_sid, DOM_SID2 * sid)
-{
- DEBUG(5, ("init_samr_q_query_useraliases\n"));
-
- q_u->pol = *hnd;
- q_u->num_sids1 = num_sids;
- q_u->ptr = 1;
- q_u->num_sids2 = num_sids;
+/*************************************************************************
+ init_sam_user_info21W
- q_u->ptr_sid = ptr_sid;
- q_u->sid = sid;
-}
+ unknown_6 = 0x0000 04ec
-/*******************************************************************
-reads or writes a SAMR_Q_QUERY_USERALIASES structure.
-********************************************************************/
+ *************************************************************************/
-bool samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
- prs_struct *ps, int depth)
+void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
+ NTTIME * logon_time,
+ NTTIME * logoff_time,
+ NTTIME * kickoff_time,
+ NTTIME * pass_last_set_time,
+ NTTIME * pass_can_change_time,
+ NTTIME * pass_must_change_time,
+ UNISTR2 *user_name,
+ UNISTR2 *full_name,
+ UNISTR2 *home_dir,
+ UNISTR2 *dir_drive,
+ UNISTR2 *log_scr,
+ UNISTR2 *prof_path,
+ UNISTR2 *desc,
+ UNISTR2 *wkstas,
+ UNISTR2 *unk_str,
+ UNISTR2 *mung_dial,
+ uchar lm_pwd[16],
+ uchar nt_pwd[16],
+ uint32 user_rid,
+ uint32 group_rid,
+ uint32 acb_info,
+ uint32 fields_present,
+ uint16 logon_divs,
+ LOGON_HRS * hrs,
+ uint16 bad_password_count,
+ uint16 logon_count)
{
- fstring tmp;
- uint32 i;
+ usr->logon_time = *logon_time;
+ usr->logoff_time = *logoff_time;
+ usr->kickoff_time = *kickoff_time;
+ usr->pass_last_set_time = *pass_last_set_time;
+ usr->pass_can_change_time = *pass_can_change_time;
+ usr->pass_must_change_time = *pass_must_change_time;
- if (q_u == NULL)
- return False;
+ memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
+ memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
- prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
- depth++;
+ usr->user_rid = user_rid;
+ usr->group_rid = group_rid;
+ usr->acb_info = acb_info;
+ usr->fields_present = fields_present; /* 0x00ff ffff */
- if(!prs_align(ps))
- return False;
+ usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
+ usr->ptr_logon_hrs = hrs ? 1 : 0;
+ usr->bad_password_count = bad_password_count;
+ usr->logon_count = logon_count;
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
- return False;
+ if (nt_time_is_zero(pass_must_change_time)) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
+ } else {
+ usr->passmustchange=0;
+ }
- if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
- return False;
- if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
- return False;
+ ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
- if (q_u->ptr==0)
- return True;
+ copy_unistr2(&usr->uni_user_name, user_name);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
- if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
- return False;
+ copy_unistr2(&usr->uni_full_name, full_name);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
- if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
- q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
- if (q_u->ptr_sid == NULL)
- return False;
+ copy_unistr2(&usr->uni_home_dir, home_dir);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
- q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
- if (q_u->sid == NULL)
- return False;
- }
+ copy_unistr2(&usr->uni_dir_drive, dir_drive);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
- for (i = 0; i < q_u->num_sids2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
- if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
- return False;
- }
+ copy_unistr2(&usr->uni_logon_script, log_scr);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
- for (i = 0; i < q_u->num_sids2; i++) {
- if (q_u->ptr_sid[i] != 0) {
- slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
- if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
- return False;
- }
- }
+ copy_unistr2(&usr->uni_profile_path, prof_path);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
- return True;
-}
+ copy_unistr2(&usr->uni_acct_desc, desc);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
-/*******************************************************************
-inits a SAMR_R_QUERY_USERALIASES structure.
-********************************************************************/
+ copy_unistr2(&usr->uni_workstations, wkstas);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
-void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
- uint32 num_rids, uint32 *rid,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_useraliases\n"));
+ copy_unistr2(&usr->uni_comment, unk_str);
+ init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
- if (NT_STATUS_IS_OK(status)) {
- r_u->num_entries = num_rids;
- r_u->ptr = 1;
- r_u->num_entries2 = num_rids;
+ copy_unistr2(&usr->uni_munged_dial, mung_dial);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
- r_u->rid = rid;
+ if (hrs) {
+ memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
} else {
- r_u->num_entries = 0;
- r_u->ptr = 0;
- r_u->num_entries2 = 0;
+ ZERO_STRUCT(usr->logon_hrs);
}
-
- r_u->status = status;
}
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+/*************************************************************************
+ init_sam_user_info21
-bool samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
- prs_struct *ps, int depth)
-{
- fstring tmp;
- uint32 i;
- if (rid == NULL)
- return False;
+ unknown_6 = 0x0000 04ec
- prs_debug(ps, depth, desc, "samr_io_rids");
- depth++;
+ *************************************************************************/
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("num_rids", ps, depth, num_rids))
- return False;
-
- if ((*num_rids) != 0) {
- if (UNMARSHALLING(ps)) {
- /* reading */
- (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
- }
- if ((*rid) == NULL)
- return False;
-
- for (i = 0; i < (*num_rids); i++) {
- slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
- if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
- return False;
- }
- }
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
- prs_struct *ps, int depth)
+NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
- depth++;
+ NTTIME logon_time, logoff_time, kickoff_time,
+ pass_last_set_time, pass_can_change_time,
+ pass_must_change_time;
+
+ time_t must_change_time;
+ const char* user_name = pdb_get_username(pw);
+ const char* full_name = pdb_get_fullname(pw);
+ const char* home_dir = pdb_get_homedir(pw);
+ const char* dir_drive = pdb_get_dir_drive(pw);
+ const char* logon_script = pdb_get_logon_script(pw);
+ const char* profile_path = pdb_get_profile_path(pw);
+ const char* description = pdb_get_acct_desc(pw);
+ const char* workstations = pdb_get_workstations(pw);
+ const char* munged_dial = pdb_get_munged_dial(pw);
+ DATA_BLOB munged_dial_blob;
- if(!prs_align(ps))
- return False;
+ uint32 user_rid;
+ const DOM_SID *user_sid;
- if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
- return False;
- if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
- return False;
+ uint32 group_rid;
+ const DOM_SID *group_sid;
- if (r_u->ptr != 0) {
- if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
- return False;
+ if (munged_dial) {
+ munged_dial_blob = base64_decode_data_blob(munged_dial);
+ } else {
+ munged_dial_blob = data_blob_null;
}
- if(!prs_align(ps))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_OPEN_ALIAS structure.
-********************************************************************/
-
-void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
- uint32 access_mask, uint32 rid)
-{
- DEBUG(5, ("init_samr_q_open_alias\n"));
-
- q_u->dom_pol = *pol;
- q_u->access_mask = access_mask;
- q_u->rid_alias = rid;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_open_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
- return False;
-
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
- return False;
- if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_open_alias");
- depth++;
+ /* Create NTTIME structs */
+ unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
+ unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
+ unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
+ unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
+ unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
+ must_change_time = pdb_get_pass_must_change_time(pw);
+ if (must_change_time == get_time_t_max())
+ unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
+ else
+ unix_to_nt_time(&pass_must_change_time, must_change_time);
+
+ /* structure assignment */
+ usr->logon_time = logon_time;
+ usr->logoff_time = logoff_time;
+ usr->kickoff_time = kickoff_time;
+ usr->pass_last_set_time = pass_last_set_time;
+ usr->pass_can_change_time = pass_can_change_time;
+ usr->pass_must_change_time = pass_must_change_time;
- if(!prs_align(ps))
- return False;
+ ZERO_STRUCT(usr->nt_pwd);
+ ZERO_STRUCT(usr->lm_pwd);
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
- return False;
+ user_sid = pdb_get_user_sid(pw);
+
+ if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
+ DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
+ "the domain sid %s. Failing operation.\n",
+ user_name, sid_string_dbg(user_sid),
+ sid_string_dbg(domain_sid)));
+ data_blob_free(&munged_dial_blob);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ become_root();
+ group_sid = pdb_get_group_sid(pw);
+ unbecome_root();
- return True;
-}
+ if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
+ DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
+ "which conflicts with the domain sid %s. Failing operation.\n",
+ user_name, sid_string_dbg(group_sid),
+ sid_string_dbg(domain_sid)));
+ data_blob_free(&munged_dial_blob);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
-/*******************************************************************
-inits a SAMR_Q_LOOKUP_RIDS structure.
-********************************************************************/
+ usr->user_rid = user_rid;
+ usr->group_rid = group_rid;
+ usr->acb_info = pdb_get_acct_ctrl(pw);
-void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
- POLICY_HND *pol, uint32 flags,
- uint32 num_rids, uint32 *rid)
-{
- DEBUG(5, ("init_samr_q_lookup_rids\n"));
+ /*
+ Look at a user on a real NT4 PDC with usrmgr, press
+ 'ok'. Then you will see that fields_present is set to
+ 0x08f827fa. Look at the user immediately after that again,
+ and you will see that 0x00fffff is returned. This solves
+ the problem that you get access denied after having looked
+ at the user.
+ -- Volker
+ */
+ usr->fields_present = pdb_build_fields_present(pw);
- q_u->pol = *pol;
+ usr->logon_divs = pdb_get_logon_divs(pw);
+ usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
+ usr->bad_password_count = pdb_get_bad_password_count(pw);
+ usr->logon_count = pdb_get_logon_count(pw);
- q_u->num_rids1 = num_rids;
- q_u->flags = flags;
- q_u->ptr = 0;
- q_u->num_rids2 = num_rids;
- if (num_rids) {
- q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
- } else {
- q_u->rid = NULL;
- }
- if (q_u->rid == NULL) {
- q_u->num_rids1 = 0;
- q_u->num_rids2 = 0;
+ if (pdb_get_pass_must_change_time(pw) == 0) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
} else {
- memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
+ usr->passmustchange=0;
}
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
- fstring tmp;
- if (q_u == NULL)
- return False;
+ ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
- prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
- depth++;
+ init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
- if (UNMARSHALLING(ps))
- ZERO_STRUCTP(q_u);
+ init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
- if(!prs_align(ps))
- return False;
+ init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
- return False;
+ init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
- if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
- return False;
- if(!prs_uint32("flags ", ps, depth, &q_u->flags))
- return False;
- if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
- return False;
- if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
- return False;
+ init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
- if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
- q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
- if (q_u->rid == NULL)
- return False;
- }
+ init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
- for (i = 0; i < q_u->num_rids2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
- if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
- return False;
- }
+ init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
- return True;
-}
+ init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
-/*******************************************************************
-inits a SAMR_R_LOOKUP_RIDS structure.
-********************************************************************/
+ init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
-void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
- uint32 num_names, UNIHDR * hdr_name,
- UNISTR2 *uni_name, uint32 *type)
-{
- DEBUG(5, ("init_samr_r_lookup_rids\n"));
-
- r_u->hdr_name = NULL;
- r_u->uni_name = NULL;
- r_u->type = NULL;
-
- if (num_names != 0) {
- r_u->num_names1 = num_names;
- r_u->ptr_names = 1;
- r_u->num_names2 = num_names;
-
- r_u->num_types1 = num_names;
- r_u->ptr_types = 1;
- r_u->num_types2 = num_names;
-
- r_u->hdr_name = hdr_name;
- r_u->uni_name = uni_name;
- r_u->type = type;
- } else {
- r_u->num_names1 = num_names;
- r_u->ptr_names = 0;
- r_u->num_names2 = num_names;
-
- r_u->num_types1 = num_names;
- r_u->ptr_types = 0;
- r_u->num_types2 = num_names;
- }
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
- fstring tmp;
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
- return False;
- if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
- return False;
-
- if (r_u->ptr_names != 0) {
-
- if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
- return False;
-
-
- if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
- r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
- if (r_u->hdr_name == NULL)
- return False;
-
- r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
- if (r_u->uni_name == NULL)
- return False;
- }
-
- for (i = 0; i < r_u->num_names2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
- if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
- return False;
- }
- for (i = 0; i < r_u->num_names2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
- if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
- return False;
- }
-
- }
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
- return False;
- if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
- return False;
-
- if (r_u->ptr_types != 0) {
-
- if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
- return False;
-
- if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
- r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
- if (r_u->type == NULL)
- return False;
- }
-
- for (i = 0; i < r_u->num_types2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
- if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
- return False;
- }
- }
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_OPEN_ALIAS structure.
-********************************************************************/
-
-void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
-{
- DEBUG(5, ("init_samr_q_delete_alias\n"));
-
- q_u->alias_pol = *hnd;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_CREATE_DOM_ALIAS structure.
-********************************************************************/
-
-void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
- POLICY_HND *hnd, const char *acct_desc)
-{
- DEBUG(5, ("init_samr_q_create_dom_alias\n"));
-
- q_u->dom_pol = *hnd;
-
- init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
- init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
-
- q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
- return False;
-
- if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
- q_u->hdr_acct_desc.buffer, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
- return False;
-
- if(!prs_uint32("rid", ps, depth, &r_u->rid))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_ADD_ALIASMEM structure.
-********************************************************************/
-
-void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
- DOM_SID *sid)
-{
- DEBUG(5, ("init_samr_q_add_aliasmem\n"));
-
- q_u->alias_pol = *hnd;
- init_dom_sid2(&q_u->sid, sid);
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
- return False;
- if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_DEL_ALIASMEM structure.
-********************************************************************/
-
-void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
- DOM_SID *sid)
-{
- DEBUG(5, ("init_samr_q_del_aliasmem\n"));
-
- q_u->alias_pol = *hnd;
- init_dom_sid2(&q_u->sid, sid);
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
- return False;
- if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_DELETE_DOM_ALIAS structure.
-********************************************************************/
-
-void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
- POLICY_HND *hnd)
-{
- DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
-
- q_c->alias_pol = *hnd;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_DELETE_DOM_ALIAS structure.
-********************************************************************/
-
-void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
-
- r_u->status = status;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_QUERY_ALIASMEM structure.
-********************************************************************/
-
-void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
- POLICY_HND *hnd)
-{
- DEBUG(5, ("init_samr_q_query_aliasmem\n"));
-
- q_c->alias_pol = *hnd;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_QUERY_ALIASMEM structure.
-********************************************************************/
-
-void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
- uint32 num_sids, DOM_SID2 * sid,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_aliasmem\n"));
-
- if (NT_STATUS_IS_OK(status)) {
- r_u->num_sids = num_sids;
- r_u->ptr = (num_sids != 0) ? 1 : 0;
- r_u->num_sids1 = num_sids;
-
- r_u->sid = sid;
- } else {
- r_u->ptr = 0;
- r_u->num_sids = 0;
- }
-
- r_u->status = status;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
-
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
- return False;
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
- return False;
-
- if (r_u->ptr != 0 && r_u->num_sids != 0) {
- uint32 *ptr_sid = NULL;
-
- if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
- return False;
-
- /* We must always use talloc here even when marshalling. */
- if (r_u->num_sids1) {
- ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
- if (!ptr_sid) {
- return False;
- }
- } else {
- ptr_sid = NULL;
- }
-
- for (i = 0; i < r_u->num_sids1; i++) {
- ptr_sid[i] = 1;
- if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
- return False;
- }
-
- if (UNMARSHALLING(ps)) {
- if (r_u->num_sids1) {
- r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
- if (!r_u->sid) {
- return False;
- }
- } else {
- r_u->sid = NULL;
- }
- }
-
- for (i = 0; i < r_u->num_sids1; i++) {
- if (ptr_sid[i] != 0) {
- if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
- return False;
- }
- }
- }
-
- if(!prs_align(ps))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_LOOKUP_NAMES structure.
-********************************************************************/
-
-NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
- POLICY_HND *pol, uint32 flags,
- uint32 num_names, const char **name)
-{
- uint32 i;
-
- DEBUG(5, ("init_samr_q_lookup_names\n"));
-
- q_u->pol = *pol;
-
- q_u->num_names1 = num_names;
- q_u->flags = flags;
- q_u->ptr = 0;
- q_u->num_names2 = num_names;
-
- if (num_names) {
- if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
- return NT_STATUS_NO_MEMORY;
-
- if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
- return NT_STATUS_NO_MEMORY;
- } else {
- q_u->hdr_name = NULL;
- q_u->uni_name = NULL;
- }
-
- for (i = 0; i < num_names; i++) {
- init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
- init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
- }
-
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
-
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
- depth++;
-
- if (UNMARSHALLING(ps))
- ZERO_STRUCTP(q_u);
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
- return False;
-
- if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
- return False;
- if(!prs_uint32("flags ", ps, depth, &q_u->flags))
- return False;
- if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
- return False;
- if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
- return False;
-
- if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
- q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
- q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
- if (!q_u->hdr_name || !q_u->uni_name)
- return False;
- }
-
- for (i = 0; i < q_u->num_names2; i++) {
- if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
- return False;
- }
-
- for (i = 0; i < q_u->num_names2; i++) {
- if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_LOOKUP_NAMES structure.
-********************************************************************/
-
-NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
- uint32 num_rids,
- uint32 *rid, enum lsa_SidType *type,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_lookup_names\n"));
-
- if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
- uint32 i;
-
- r_u->num_types1 = num_rids;
- r_u->ptr_types = 1;
- r_u->num_types2 = num_rids;
-
- r_u->num_rids1 = num_rids;
- r_u->ptr_rids = 1;
- r_u->num_rids2 = num_rids;
-
- if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
- return NT_STATUS_NO_MEMORY;
- if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
- return NT_STATUS_NO_MEMORY;
-
- for (i = 0; i < num_rids; i++) {
- r_u->rids[i] = rid[i];
- r_u->types[i] = type[i];
- }
- } else {
-
- r_u->num_types1 = 0;
- r_u->ptr_types = 0;
- r_u->num_types2 = 0;
-
- r_u->num_rids1 = 0;
- r_u->ptr_rids = 0;
- r_u->num_rids2 = 0;
-
- r_u->rids = NULL;
- r_u->types = NULL;
- }
-
- r_u->status = status;
-
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
- prs_struct *ps, int depth)
-{
- uint32 i;
- fstring tmp;
-
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
- depth++;
-
- if (UNMARSHALLING(ps))
- ZERO_STRUCTP(r_u);
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
- return False;
- if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
- return False;
-
- if (r_u->ptr_rids != 0) {
- if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
- return False;
-
- if (r_u->num_rids2 != r_u->num_rids1) {
- /* RPC fault */
- return False;
- }
-
- if (UNMARSHALLING(ps) && r_u->num_rids2) {
- r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
-
- if (!r_u->rids) {
- DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
- return False;
- }
- }
-
- for (i = 0; i < r_u->num_rids2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
- if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
- return False;
- }
- }
-
- if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
- return False;
- if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
- return False;
-
- if (r_u->ptr_types != 0) {
- if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
- return False;
-
- if (r_u->num_types2 != r_u->num_types1) {
- /* RPC fault */
- return False;
- }
-
- if (UNMARSHALLING(ps) && r_u->num_types2) {
- r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
-
- if (!r_u->types) {
- DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
- return False;
- }
- }
-
- for (i = 0; i < r_u->num_types2; i++) {
- slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
- if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
- return False;
- }
- }
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_DELETE_DOM_USER structure.
-********************************************************************/
-
-void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
- POLICY_HND *hnd)
-{
- DEBUG(5, ("init_samr_q_delete_dom_user\n"));
-
- q_c->user_pol = *hnd;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
- POLICY_HND *pol,
- uint32 access_mask, uint32 rid)
-{
- DEBUG(5, ("samr_init_samr_q_open_user\n"));
-
- q_u->domain_pol = *pol;
- q_u->access_mask = access_mask;
- q_u->user_rid = rid;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_open_user");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
- return False;
-
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
- return False;
- if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_open_user");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
- POLICY_HND *pol,
- const char *name,
- uint32 acb_info, uint32 acct_flags)
-{
- DEBUG(5, ("samr_init_samr_q_create_user\n"));
-
- q_u->domain_pol = *pol;
-
- init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
- init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
-
- q_u->acb_info = acb_info;
- q_u->acct_flags = acct_flags;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_create_user");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
- return False;
-
- if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
- return False;
- if(!prs_uint32("acct_flags", ps, depth, &q_u->acct_flags))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_create_user");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
- return False;
-
- if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
- return False;
- if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_QUERY_USERINFO structure.
-********************************************************************/
-
-void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
- const POLICY_HND *hnd, uint16 switch_value)
-{
- DEBUG(5, ("init_samr_q_query_userinfo\n"));
-
- q_u->pol = *hnd;
- q_u->switch_value = switch_value;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
- return False;
-
- if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a LOGON_HRS structure.
-********************************************************************/
-
-static bool sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
- prs_struct *ps, int depth)
-{
- if (hrs == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_logon_hrs");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
- return False;
-
- if(!prs_uint32("offset", ps, depth, &hrs->offset))
- return False;
-
- if(!prs_uint32("len ", ps, depth, &hrs->len))
- return False;
-
- if (hrs->len > sizeof(hrs->hours)) {
- DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
- hrs->len = sizeof(hrs->hours);
- }
-
- if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAM_USER_INFO_18 structure.
-********************************************************************/
-
-void init_sam_user_info18(SAM_USER_INFO_18 * usr,
- const uint8 lm_pwd[16], const uint8 nt_pwd[16])
-{
- DEBUG(5, ("init_sam_user_info18\n"));
-
- usr->lm_pwd_active =
- memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
- usr->nt_pwd_active =
- memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
- prs_struct *ps, int depth)
-{
- if (u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_user_info18");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
- return False;
- if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
- return False;
-
- if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
- return False;
- if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAM_USER_INFO_7 structure.
-********************************************************************/
-
-void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
-{
- DEBUG(5, ("init_sam_user_info7\n"));
-
- init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
- init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
-
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_user_info7");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
- return False;
-
- if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAM_USER_INFO_9 structure.
-********************************************************************/
-
-void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
-{
- DEBUG(5, ("init_sam_user_info9\n"));
-
- usr->rid_group = rid_group;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_user_info9");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAM_USER_INFO_16 structure.
-********************************************************************/
-
-void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
-{
- DEBUG(5, ("init_sam_user_info16\n"));
-
- usr->acb_info = acb_info;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_user_info16");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAM_USER_INFO_17 structure.
-********************************************************************/
-
-void init_sam_user_info17(SAM_USER_INFO_17 * usr,
- NTTIME * expiry,
- char *mach_acct,
- uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
-{
- DEBUG(5, ("init_sam_user_info17\n"));
-
- memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
- ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
-
- usr->padding_2 = 0; /* 0 - padding 4 bytes */
-
- usr->ptr_1 = 1; /* pointer */
- ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
- usr->padding_4 = 0; /* 0 - padding 4 bytes */
-
- usr->ptr_2 = 1; /* pointer */
- usr->padding_5 = 0; /* 0 - padding 4 bytes */
-
- usr->ptr_3 = 1; /* pointer */
- ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
-
- usr->rid_user = rid_user;
- usr->rid_group = rid_group;
-
- usr->acct_ctrl = acct_ctrl;
- usr->unknown_3 = 0x0000;
-
- usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
- usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
-
- ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
- usr->padding_8 = 0; /* 0 - padding 4 bytes */
-
- init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
- init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
- return False;
-
- if(!smb_io_time("time", &usr->expiry, ps, depth))
- return False;
-
- if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
- return False;
-
- if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
- return False;
-
- if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
- return False;
-
- if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
- return False;
- if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
- return False;
-
- if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
- return False;
-
- if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
- return False;
- if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
- return False;
-
- if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
- return False;
- if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
- return False;
-
- if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
- return False;
- if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
- return False;
- if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
- return False;
- if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
- return False;
- if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
- return False;
- if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
- return False;
-
- if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
- return False;
-
- if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
- return False;
-
- if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
- return False;
-
- return True;
-}
-
-/*************************************************************************
- init_sam_user_infoa
- *************************************************************************/
-
-void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
- uint8 pw_len)
-{
- DEBUG(10, ("init_sam_user_info24:\n"));
- memcpy(usr->pass, newpass, sizeof(usr->pass));
- usr->pw_len = pw_len;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_user_info24");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint8s(False, "password", ps, depth, usr->pass,
- sizeof(usr->pass)))
- return False;
-
- if (MARSHALLING(ps) && (usr->pw_len != 0)) {
- if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
- return False;
- } else if (UNMARSHALLING(ps)) {
- if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_user_info26");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint8s(False, "password", ps, depth, usr->pass,
- sizeof(usr->pass)))
- return False;
-
- if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
- return False;
-
- return True;
-}
-
-
-/*************************************************************************
- init_sam_user_info23
-
- unknown_6 = 0x0000 04ec
-
- *************************************************************************/
-
-void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
- NTTIME * logoff_time, /* all zeros */
- NTTIME * kickoff_time, /* all zeros */
- NTTIME * pass_last_set_time, /* all zeros */
- NTTIME * pass_can_change_time, /* all zeros */
- NTTIME * pass_must_change_time, /* all zeros */
- UNISTR2 *user_name,
- UNISTR2 *full_name,
- UNISTR2 *home_dir,
- UNISTR2 *dir_drive,
- UNISTR2 *log_scr,
- UNISTR2 *prof_path,
- UNISTR2 *desc,
- UNISTR2 *wkstas,
- UNISTR2 *unk_str,
- UNISTR2 *mung_dial,
- uint32 user_rid, /* 0x0000 0000 */
- uint32 group_rid,
- uint32 acb_info,
- uint32 fields_present,
- uint16 logon_divs,
- LOGON_HRS * hrs,
- uint16 bad_password_count,
- uint16 logon_count,
- char newpass[516])
-{
- usr->logon_time = *logon_time; /* all zeros */
- usr->logoff_time = *logoff_time; /* all zeros */
- usr->kickoff_time = *kickoff_time; /* all zeros */
- usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
- usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
- usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
-
- ZERO_STRUCT(usr->nt_pwd);
- ZERO_STRUCT(usr->lm_pwd);
-
- usr->user_rid = user_rid; /* 0x0000 0000 */
- usr->group_rid = group_rid;
- usr->acb_info = acb_info;
- usr->fields_present = fields_present; /* 09f8 27fa */
-
- usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
- usr->ptr_logon_hrs = hrs ? 1 : 0;
-
- if (nt_time_is_zero(pass_must_change_time)) {
- usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
- } else {
- usr->passmustchange=0;
- }
-
- ZERO_STRUCT(usr->padding1);
- ZERO_STRUCT(usr->padding2);
-
- usr->bad_password_count = bad_password_count;
- usr->logon_count = logon_count;
-
- memcpy(usr->pass, newpass, sizeof(usr->pass));
-
- copy_unistr2(&usr->uni_user_name, user_name);
- init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
-
- copy_unistr2(&usr->uni_full_name, full_name);
- init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
-
- copy_unistr2(&usr->uni_home_dir, home_dir);
- init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
-
- copy_unistr2(&usr->uni_dir_drive, dir_drive);
- init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
-
- copy_unistr2(&usr->uni_logon_script, log_scr);
- init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
-
- copy_unistr2(&usr->uni_profile_path, prof_path);
- init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
-
- copy_unistr2(&usr->uni_acct_desc, desc);
- init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
-
- copy_unistr2(&usr->uni_workstations, wkstas);
- init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
-
- copy_unistr2(&usr->uni_comment, unk_str);
- init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
-
- copy_unistr2(&usr->uni_munged_dial, mung_dial);
- init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
-
- if (hrs) {
- memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
- } else {
- ZERO_STRUCT(usr->logon_hrs);
- }
-}
-
-/*************************************************************************
- init_sam_user_info23
-
- unknown_6 = 0x0000 04ec
-
- *************************************************************************/
-
-void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
- NTTIME * logoff_time, /* all zeros */
- NTTIME * kickoff_time, /* all zeros */
- NTTIME * pass_last_set_time, /* all zeros */
- NTTIME * pass_can_change_time, /* all zeros */
- NTTIME * pass_must_change_time, /* all zeros */
- char *user_name, /* NULL */
- char *full_name,
- char *home_dir, char *dir_drive, char *log_scr,
- char *prof_path, const char *desc, char *wkstas,
- char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
- uint32 group_rid, uint32 acb_info,
- uint32 fields_present, uint16 logon_divs,
- LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
- char newpass[516])
-{
- DATA_BLOB blob = base64_decode_data_blob(mung_dial);
-
- usr->logon_time = *logon_time; /* all zeros */
- usr->logoff_time = *logoff_time; /* all zeros */
- usr->kickoff_time = *kickoff_time; /* all zeros */
- usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
- usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
- usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
-
- ZERO_STRUCT(usr->nt_pwd);
- ZERO_STRUCT(usr->lm_pwd);
-
- usr->user_rid = user_rid; /* 0x0000 0000 */
- usr->group_rid = group_rid;
- usr->acb_info = acb_info;
- usr->fields_present = fields_present; /* 09f8 27fa */
-
- usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
- usr->ptr_logon_hrs = hrs ? 1 : 0;
-
- if (nt_time_is_zero(pass_must_change_time)) {
- usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
- } else {
- usr->passmustchange=0;
- }
-
- ZERO_STRUCT(usr->padding1);
- ZERO_STRUCT(usr->padding2);
-
- usr->bad_password_count = bad_password_count;
- usr->logon_count = logon_count;
-
- memcpy(usr->pass, newpass, sizeof(usr->pass));
-
- init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
-
- init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
-
- init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
-
- init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
-
- init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
-
- init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
-
- init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
-
- init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
-
- init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
- init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
-
- init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
- init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
-
- data_blob_free(&blob);
-
- if (hrs) {
- memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
- } else {
- ZERO_STRUCT(usr->logon_hrs);
- }
-}
-
-
-/*************************************************************************
- init_samr_user_info25P
- fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
-*************************************************************************/
-
-void init_sam_user_info25P(SAM_USER_INFO_25 * usr,
- uint32 fields_present, uint32 acb_info,
- char newpass[532])
-{
- usr->fields_present = fields_present;
- ZERO_STRUCT(usr->padding1);
- ZERO_STRUCT(usr->padding2);
-
- usr->acb_info = acb_info;
- memcpy(usr->pass, newpass, sizeof(usr->pass));
-}
-
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_user_info23");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
- return False;
- if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
- return False;
- if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
- return False;
- if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
- return False;
- if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
- return False;
- if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
- return False;
-
- if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
- return False;
- if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
- return False;
- if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
- return False;
- if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
- return False;
- if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
- return False;
-
- if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
- return False;
- if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
- return False;
-
- if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
- return False;
- if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
- return False;
- if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
- return False;
-
- if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
- return False;
- if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
- return False;
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
- return False;
-
- if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
- return False;
- if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
- return False;
-
- if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
- return False;
- if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
- return False;
- if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
- return False;
-
-
- if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
- return False;
-
- /* here begins pointed-to data */
-
- if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
- return False;
-
- if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
- return False;
-
- if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
- return False;
-
- /* ok, this is only guess-work (as usual) */
- if (usr->ptr_logon_hrs) {
- if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
- reads or writes a structure.
- NB. This structure is *definately* incorrect. It's my best guess
- currently for W2K SP2. The password field is encrypted in a different
- way than normal... And there are definately other problems. JRA.
-********************************************************************/
-
-static bool sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_user_info25");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
- return False;
- if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
- return False;
- if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
- return False;
- if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
- return False;
- if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
- return False;
- if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
- return False;
-
- if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
- return False;
- if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
- return False;
- if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
- return False;
- if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
- return False;
- if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
- return False;
-
- if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
- return False;
- if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
- return False;
-
- if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
- return False;
- if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
- return False;
- if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
- return False;
- if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
- return False;
-
- if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
- return False;
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
- return False;
-
- if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
- return False;
- if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
- return False;
-
- if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
- return False;
- if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
- return False;
- if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
- return False;
-
-
- if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
- return False;
-
- /* here begins pointed-to data */
-
- if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
- return False;
-
- if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
- return False;
-
- if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
- return False;
-
- if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
- return False;
-
- /* ok, this is only guess-work (as usual) */
- if (usr->ptr_logon_hrs) {
- if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
- return False;
- }
-
- return True;
-}
-
-
-/*************************************************************************
- init_sam_user_info21W
-
- unknown_6 = 0x0000 04ec
-
- *************************************************************************/
-
-void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
- NTTIME * logon_time,
- NTTIME * logoff_time,
- NTTIME * kickoff_time,
- NTTIME * pass_last_set_time,
- NTTIME * pass_can_change_time,
- NTTIME * pass_must_change_time,
- UNISTR2 *user_name,
- UNISTR2 *full_name,
- UNISTR2 *home_dir,
- UNISTR2 *dir_drive,
- UNISTR2 *log_scr,
- UNISTR2 *prof_path,
- UNISTR2 *desc,
- UNISTR2 *wkstas,
- UNISTR2 *unk_str,
- UNISTR2 *mung_dial,
- uchar lm_pwd[16],
- uchar nt_pwd[16],
- uint32 user_rid,
- uint32 group_rid,
- uint32 acb_info,
- uint32 fields_present,
- uint16 logon_divs,
- LOGON_HRS * hrs,
- uint16 bad_password_count,
- uint16 logon_count)
-{
- usr->logon_time = *logon_time;
- usr->logoff_time = *logoff_time;
- usr->kickoff_time = *kickoff_time;
- usr->pass_last_set_time = *pass_last_set_time;
- usr->pass_can_change_time = *pass_can_change_time;
- usr->pass_must_change_time = *pass_must_change_time;
-
- memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
- memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
-
- usr->user_rid = user_rid;
- usr->group_rid = group_rid;
- usr->acb_info = acb_info;
- usr->fields_present = fields_present; /* 0x00ff ffff */
-
- usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
- usr->ptr_logon_hrs = hrs ? 1 : 0;
- usr->bad_password_count = bad_password_count;
- usr->logon_count = logon_count;
-
- if (nt_time_is_zero(pass_must_change_time)) {
- usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
- } else {
- usr->passmustchange=0;
- }
-
- ZERO_STRUCT(usr->padding1);
- ZERO_STRUCT(usr->padding2);
-
- copy_unistr2(&usr->uni_user_name, user_name);
- init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
-
- copy_unistr2(&usr->uni_full_name, full_name);
- init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
-
- copy_unistr2(&usr->uni_home_dir, home_dir);
- init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
-
- copy_unistr2(&usr->uni_dir_drive, dir_drive);
- init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
-
- copy_unistr2(&usr->uni_logon_script, log_scr);
- init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
-
- copy_unistr2(&usr->uni_profile_path, prof_path);
- init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
-
- copy_unistr2(&usr->uni_acct_desc, desc);
- init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
-
- copy_unistr2(&usr->uni_workstations, wkstas);
- init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
-
- copy_unistr2(&usr->uni_comment, unk_str);
- init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
-
- copy_unistr2(&usr->uni_munged_dial, mung_dial);
- init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
-
- if (hrs) {
- memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
- } else {
- ZERO_STRUCT(usr->logon_hrs);
- }
-}
-
-/*************************************************************************
- init_sam_user_info21
-
- unknown_6 = 0x0000 04ec
-
- *************************************************************************/
-
-NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
-{
- NTTIME logon_time, logoff_time, kickoff_time,
- pass_last_set_time, pass_can_change_time,
- pass_must_change_time;
-
- time_t must_change_time;
- const char* user_name = pdb_get_username(pw);
- const char* full_name = pdb_get_fullname(pw);
- const char* home_dir = pdb_get_homedir(pw);
- const char* dir_drive = pdb_get_dir_drive(pw);
- const char* logon_script = pdb_get_logon_script(pw);
- const char* profile_path = pdb_get_profile_path(pw);
- const char* description = pdb_get_acct_desc(pw);
- const char* workstations = pdb_get_workstations(pw);
- const char* munged_dial = pdb_get_munged_dial(pw);
- DATA_BLOB munged_dial_blob;
-
- uint32 user_rid;
- const DOM_SID *user_sid;
-
- uint32 group_rid;
- const DOM_SID *group_sid;
-
- if (munged_dial) {
- munged_dial_blob = base64_decode_data_blob(munged_dial);
- } else {
- munged_dial_blob = data_blob_null;
- }
-
- /* Create NTTIME structs */
- unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
- unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
- unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
- unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
- unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
- must_change_time = pdb_get_pass_must_change_time(pw);
- if (must_change_time == get_time_t_max())
- unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
- else
- unix_to_nt_time(&pass_must_change_time, must_change_time);
-
- /* structure assignment */
- usr->logon_time = logon_time;
- usr->logoff_time = logoff_time;
- usr->kickoff_time = kickoff_time;
- usr->pass_last_set_time = pass_last_set_time;
- usr->pass_can_change_time = pass_can_change_time;
- usr->pass_must_change_time = pass_must_change_time;
-
- ZERO_STRUCT(usr->nt_pwd);
- ZERO_STRUCT(usr->lm_pwd);
-
- user_sid = pdb_get_user_sid(pw);
-
- if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
- DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
- "the domain sid %s. Failing operation.\n",
- user_name, sid_string_dbg(user_sid),
- sid_string_dbg(domain_sid)));
- data_blob_free(&munged_dial_blob);
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- become_root();
- group_sid = pdb_get_group_sid(pw);
- unbecome_root();
-
- if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
- DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
- "which conflicts with the domain sid %s. Failing operation.\n",
- user_name, sid_string_dbg(group_sid),
- sid_string_dbg(domain_sid)));
- data_blob_free(&munged_dial_blob);
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- usr->user_rid = user_rid;
- usr->group_rid = group_rid;
- usr->acb_info = pdb_get_acct_ctrl(pw);
-
- /*
- Look at a user on a real NT4 PDC with usrmgr, press
- 'ok'. Then you will see that fields_present is set to
- 0x08f827fa. Look at the user immediately after that again,
- and you will see that 0x00fffff is returned. This solves
- the problem that you get access denied after having looked
- at the user.
- -- Volker
- */
- usr->fields_present = pdb_build_fields_present(pw);
-
- usr->logon_divs = pdb_get_logon_divs(pw);
- usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
- usr->bad_password_count = pdb_get_bad_password_count(pw);
- usr->logon_count = pdb_get_logon_count(pw);
-
- if (pdb_get_pass_must_change_time(pw) == 0) {
- usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
- } else {
- usr->passmustchange=0;
- }
-
- ZERO_STRUCT(usr->padding1);
- ZERO_STRUCT(usr->padding2);
-
- init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
-
- init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
-
- init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
-
- init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
-
- init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
-
- init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
-
- init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
-
- init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
-
- init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
- init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
-
- init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
- init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
- data_blob_free(&munged_dial_blob);
-
- if (pdb_get_hours(pw)) {
- usr->logon_hrs.max_len = 1260;
- usr->logon_hrs.offset = 0;
- usr->logon_hrs.len = pdb_get_hours_len(pw);
- memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
- } else {
- usr->logon_hrs.max_len = 1260;
- usr->logon_hrs.offset = 0;
- usr->logon_hrs.len = 0;
- memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
- }
-
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_user_info21");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
- return False;
- if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
- return False;
- if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
- return False;
- if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
- return False;
- if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
- return False;
- if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
- return False;
-
- if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
- return False;
- if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
- return False;
- if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
- return False;
- if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
- return False;
- if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
- return False;
- if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
- return False;
-
- if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
- return False;
- if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
- return False;
-
- if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
- return False;
- if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
- return False;
- if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
- return False;
-
- if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
- return False;
- if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
- return False;
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
- return False;
-
- if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
- return False;
- if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
- return False;
-
- if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
- return False;
- if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
- return False;
- if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
- return False;
-
- /* here begins pointed-to data */
-
- if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
- return False;
- if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
- return False;
-
- /* ok, this is only guess-work (as usual) */
- if (usr->ptr_logon_hrs) {
- if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
- return False;
- }
-
- return True;
-}
-
-void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
-{
- const char *munged_dial = pdb_get_munged_dial(pw);
- DATA_BLOB blob;
-
- if (munged_dial) {
- blob = base64_decode_data_blob(munged_dial);
- } else {
- blob = data_blob_null;
- }
-
- init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
- init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
- data_blob_free(&blob);
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
- prs_struct *ps, int depth)
-{
- if (usr == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "sam_io_user_info20");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
- return False;
-
- if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAM_USERINFO_CTR structure.
-********************************************************************/
-
-NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
- uint16 switch_value,
- SAM_USER_INFO_21 * usr)
-{
- DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
-
- ctr->switch_value = switch_value;
- ctr->info.id = NULL;
-
- switch (switch_value) {
- case 16:
- ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
- if (ctr->info.id16 == NULL)
- return NT_STATUS_NO_MEMORY;
-
- init_sam_user_info16(ctr->info.id16, usr->acb_info);
- break;
-#if 0
-/* whoops - got this wrong. i think. or don't understand what's happening. */
- case 17:
- {
- NTTIME expire;
- info = (void *)&id11;
-
- expire.low = 0xffffffff;
- expire.high = 0x7fffffff;
-
- ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
- init_sam_user_info11(ctr->info.id17, &expire,
- "BROOKFIELDS$", /* name */
- 0x03ef, /* user rid */
- 0x201, /* group rid */
- 0x0080); /* acb info */
-
- break;
- }
-#endif
- case 18:
- ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
- if (ctr->info.id18 == NULL)
- return NT_STATUS_NO_MEMORY;
-
- init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
- break;
- case 21:
- {
- SAM_USER_INFO_21 *cusr;
- cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
- ctr->info.id21 = cusr;
- if (ctr->info.id21 == NULL)
- return NT_STATUS_NO_MEMORY;
- memcpy(cusr, usr, sizeof(*usr));
- memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
- memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
- break;
- }
- default:
- DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
- return NT_STATUS_INVALID_INFO_CLASS;
- }
-
- return NT_STATUS_OK;
-}
-
-/*******************************************************************
-inits a SAM_USERINFO_CTR structure.
-********************************************************************/
-
-static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
- uint16 switch_value, void *info)
-{
- DEBUG(5, ("init_samr_userinfo_ctr\n"));
-
- ctr->switch_value = switch_value;
- ctr->info.id = info;
-
- switch (switch_value) {
- case 0x18:
- SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
- dump_data(100, sess_key->data, sess_key->length);
- dump_data(100, ctr->info.id24->pass, 516);
- break;
- case 0x17:
- SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
- dump_data(100, sess_key->data, sess_key->length);
- dump_data(100, ctr->info.id23->pass, 516);
- break;
- case 0x07:
- break;
- default:
- DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
- }
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-static bool samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
- prs_struct *ps, int depth)
-{
- bool ret;
- SAM_USERINFO_CTR *ctr;
-
- prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
- depth++;
-
- if (UNMARSHALLING(ps)) {
- ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
- if (ctr == NULL)
- return False;
- *ppctr = ctr;
- } else {
- ctr = *ppctr;
- }
-
- /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
-
- if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
- return False;
- if(!prs_align(ps))
- return False;
-
- ret = False;
-
- switch (ctr->switch_value) {
- case 7:
- if (UNMARSHALLING(ps))
- ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
- if (ctr->info.id7 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
- break;
- case 9:
- if (UNMARSHALLING(ps))
- ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
- if (ctr->info.id9 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
- break;
- case 16:
- if (UNMARSHALLING(ps))
- ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
- if (ctr->info.id16 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
- break;
- case 17:
- if (UNMARSHALLING(ps))
- ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
-
- if (ctr->info.id17 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
- break;
- case 18:
- if (UNMARSHALLING(ps))
- ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
-
- if (ctr->info.id18 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
- break;
- case 20:
- if (UNMARSHALLING(ps))
- ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
-
- if (ctr->info.id20 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
- break;
- case 21:
- if (UNMARSHALLING(ps))
- ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
-
- if (ctr->info.id21 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
- break;
- case 23:
- if (UNMARSHALLING(ps))
- ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
-
- if (ctr->info.id23 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
- break;
- case 24:
- if (UNMARSHALLING(ps))
- ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
-
- if (ctr->info.id24 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
- break;
- case 25:
- if (UNMARSHALLING(ps))
- ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
-
- if (ctr->info.id25 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
- break;
- case 26:
- if (UNMARSHALLING(ps))
- ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
-
- if (ctr->info.id26 == NULL) {
- DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
- return False;
- }
- ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
- break;
- default:
- DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
- ret = False;
- break;
- }
-
- return ret;
-}
-
-/*******************************************************************
-inits a SAMR_R_QUERY_USERINFO structure.
-********************************************************************/
-
-void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
- SAM_USERINFO_CTR * ctr, NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_userinfo\n"));
-
- r_u->ptr = 0;
- r_u->ctr = NULL;
-
- if (NT_STATUS_IS_OK(status)) {
- r_u->ptr = 1;
- r_u->ctr = ctr;
- }
-
- r_u->status = status; /* return status */
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
- return False;
-
- if (r_u->ptr != 0) {
- if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
- return False;
- }
-
- if(!prs_align(ps))
- return False;
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_Q_SET_USERINFO structure.
-********************************************************************/
+ init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
+ data_blob_free(&munged_dial_blob);
-void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
- const POLICY_HND *hnd, DATA_BLOB *sess_key,
- uint16 switch_value, void *info)
-{
- DEBUG(5, ("init_samr_q_set_userinfo\n"));
+ if (pdb_get_hours(pw)) {
+ usr->logon_hrs.max_len = 1260;
+ usr->logon_hrs.offset = 0;
+ usr->logon_hrs.len = pdb_get_hours_len(pw);
+ memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
+ } else {
+ usr->logon_hrs.max_len = 1260;
+ usr->logon_hrs.offset = 0;
+ usr->logon_hrs.len = 0;
+ memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
+ }
- q_u->pol = *hnd;
- q_u->switch_value = switch_value;
- init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
+ return NT_STATUS_OK;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
+ prs_debug(ps, depth, desc, "sam_io_user_info21");
depth++;
if(!prs_align(ps))
return False;
- smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
-
- if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
+ if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
return False;
- if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
+ if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
+ return False;
+ if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
+ return False;
+ if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
+ return False;
+ if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
return False;
- return True;
-}
+ if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
+ return False;
+ if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
+ return False;
+ if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
+ return False;
+ if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
+ return False;
+ if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
+ return False;
+ if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
+ return False;
-/*******************************************************************
-inits a SAMR_R_SET_USERINFO structure.
-********************************************************************/
+ if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
+ return False;
+ if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
+ return False;
-void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_set_userinfo\n"));
+ if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
+ return False;
+ if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
+ return False;
+ if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
+ return False;
- r_u->status = status; /* return status */
-}
+ if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
+ return False;
+ if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
+ return False;
+ if(!prs_align(ps))
+ return False;
+ if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
+ return False;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
+ return False;
+ if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
+ return False;
-bool samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
+ if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
+ return False;
+ if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
+ return False;
+ if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
return False;
- prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
- depth++;
+ /* here begins pointed-to data */
- if(!prs_align(ps))
+ if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
+ if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
+ return False;
+ if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
return False;
+ /* ok, this is only guess-work (as usual) */
+ if (usr->ptr_logon_hrs) {
+ if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
+ return False;
+ }
+
return True;
}
-/*******************************************************************
-inits a SAMR_Q_SET_USERINFO2 structure.
-********************************************************************/
-
-void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
- const POLICY_HND *hnd, DATA_BLOB *sess_key,
- uint16 switch_value, SAM_USERINFO_CTR * ctr)
+void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
{
- DEBUG(5, ("init_samr_q_set_userinfo2\n"));
-
- q_u->pol = *hnd;
- q_u->switch_value = switch_value;
- q_u->ctr = ctr;
-
- q_u->ctr->switch_value = switch_value;
+ const char *munged_dial = pdb_get_munged_dial(pw);
+ DATA_BLOB blob;
- switch (switch_value) {
- case 18:
- SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
- SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
- dump_data(100, sess_key->data, sess_key->length);
- dump_data(100, ctr->info.id18->lm_pwd, 16);
- dump_data(100, ctr->info.id18->nt_pwd, 16);
- break;
+ if (munged_dial) {
+ blob = base64_decode_data_blob(munged_dial);
+ } else {
+ blob = data_blob_null;
}
+
+ init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
+ data_blob_free(&blob);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
- prs_struct *ps, int depth)
+static bool sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
+ if (usr == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
+ prs_debug(ps, depth, desc, "sam_io_user_info20");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
+ if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
return False;
- if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
- return False;
- if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
+ if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
return False;
return True;
}
/*******************************************************************
-inits a SAMR_R_SET_USERINFO2 structure.
+inits a SAM_USERINFO_CTR structure.
********************************************************************/
-void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
+NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
+ uint16 switch_value,
+ SAM_USER_INFO_21 * usr)
{
- DEBUG(5, ("init_samr_r_set_userinfo2\n"));
+ DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
- r_u->status = status; /* return status */
-}
+ ctr->switch_value = switch_value;
+ ctr->info.id = NULL;
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
+ switch (switch_value) {
+ case 16:
+ ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
+ if (ctr->info.id16 == NULL)
+ return NT_STATUS_NO_MEMORY;
-bool samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
+ init_sam_user_info16(ctr->info.id16, usr->acb_info);
+ break;
+#if 0
+/* whoops - got this wrong. i think. or don't understand what's happening. */
+ case 17:
+ {
+ NTTIME expire;
+ info = (void *)&id11;
- prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
- depth++;
+ expire.low = 0xffffffff;
+ expire.high = 0x7fffffff;
- if(!prs_align(ps))
- return False;
+ ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
+ init_sam_user_info11(ctr->info.id17, &expire,
+ "BROOKFIELDS$", /* name */
+ 0x03ef, /* user rid */
+ 0x201, /* group rid */
+ 0x0080); /* acb info */
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ break;
+ }
+#endif
+ case 18:
+ ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
+ if (ctr->info.id18 == NULL)
+ return NT_STATUS_NO_MEMORY;
+
+ init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
+ break;
+ case 21:
+ {
+ SAM_USER_INFO_21 *cusr;
+ cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
+ ctr->info.id21 = cusr;
+ if (ctr->info.id21 == NULL)
+ return NT_STATUS_NO_MEMORY;
+ memcpy(cusr, usr, sizeof(*usr));
+ memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
+ memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
+ break;
+ }
+ default:
+ DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
+ return NT_STATUS_INVALID_INFO_CLASS;
+ }
- return True;
+ return NT_STATUS_OK;
}
/*******************************************************************
-inits a SAMR_Q_CONNECT structure.
+inits a SAM_USERINFO_CTR structure.
********************************************************************/
-void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
- char *srv_name, uint32 access_mask)
+static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
+ uint16 switch_value, void *info)
{
- DEBUG(5, ("init_samr_q_connect\n"));
+ DEBUG(5, ("init_samr_userinfo_ctr\n"));
- /* make PDC server name \\server */
- q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
- init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
+ ctr->switch_value = switch_value;
+ ctr->info.id = info;
- /* example values: 0x0000 0002 */
- q_u->access_mask = access_mask;
+ switch (switch_value) {
+ case 0x18:
+ SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
+ dump_data(100, sess_key->data, sess_key->length);
+ dump_data(100, ctr->info.id24->pass, 516);
+ break;
+ case 0x17:
+ SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
+ dump_data(100, sess_key->data, sess_key->length);
+ dump_data(100, ctr->info.id23->pass, 516);
+ break;
+ case 0x07:
+ break;
+ default:
+ DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
- prs_struct *ps, int depth)
+static bool samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
+ prs_struct *ps, int depth)
{
- if (q_u == NULL)
- return False;
+ bool ret;
+ SAM_USERINFO_CTR *ctr;
- prs_debug(ps, depth, desc, "samr_io_q_connect");
+ prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
depth++;
- if(!prs_align(ps))
- return False;
+ if (UNMARSHALLING(ps)) {
+ ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
+ if (ctr == NULL)
+ return False;
+ *ppctr = ctr;
+ } else {
+ ctr = *ppctr;
+ }
- if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
- return False;
- if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
- return False;
+ /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
- if(!prs_align(ps))
+ if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
return False;
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
+ if(!prs_align(ps))
return False;
- return True;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
+ ret = False;
- prs_debug(ps, depth, desc, "samr_io_r_connect");
- depth++;
+ switch (ctr->switch_value) {
+ case 7:
+ if (UNMARSHALLING(ps))
+ ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
+ if (ctr->info.id7 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
+ break;
+ case 9:
+ if (UNMARSHALLING(ps))
+ ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
+ if (ctr->info.id9 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
+ break;
+ case 16:
+ if (UNMARSHALLING(ps))
+ ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
+ if (ctr->info.id16 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
+ break;
+ case 17:
+ if (UNMARSHALLING(ps))
+ ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
- if(!prs_align(ps))
- return False;
+ if (ctr->info.id17 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
+ break;
+ case 18:
+ if (UNMARSHALLING(ps))
+ ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
- if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
- return False;
+ if (ctr->info.id18 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
+ break;
+ case 20:
+ if (UNMARSHALLING(ps))
+ ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
+ if (ctr->info.id20 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
+ break;
+ case 21:
+ if (UNMARSHALLING(ps))
+ ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
- return True;
-}
+ if (ctr->info.id21 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
+ break;
+ case 23:
+ if (UNMARSHALLING(ps))
+ ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
-/*******************************************************************
-inits a SAMR_Q_CONNECT4 structure.
-********************************************************************/
+ if (ctr->info.id23 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
+ break;
+ case 24:
+ if (UNMARSHALLING(ps))
+ ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
-void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
- char *srv_name, uint32 access_mask)
-{
- DEBUG(5, ("init_samr_q_connect4\n"));
+ if (ctr->info.id24 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
+ break;
+ case 25:
+ if (UNMARSHALLING(ps))
+ ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
- /* make PDC server name \\server */
- q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
- init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
+ if (ctr->info.id25 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
+ break;
+ case 26:
+ if (UNMARSHALLING(ps))
+ ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
- /* Only value we've seen, possibly an address type ? */
- q_u->unk_0 = 2;
+ if (ctr->info.id26 == NULL) {
+ DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
+ return False;
+ }
+ ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
+ break;
+ default:
+ DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
+ ret = False;
+ break;
+ }
- /* example values: 0x0000 0002 */
- q_u->access_mask = access_mask;
+ return ret;
}
/*******************************************************************
-reads or writes a structure.
+inits a SAMR_R_QUERY_USERINFO structure.
********************************************************************/
-bool samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
- prs_struct *ps, int depth)
+void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
+ SAM_USERINFO_CTR * ctr, NTSTATUS status)
{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_connect4");
- depth++;
-
- if(!prs_align(ps))
- return False;
+ DEBUG(5, ("init_samr_r_query_userinfo\n"));
- if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
- return False;
- if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
- return False;
+ r_u->ptr = 0;
+ r_u->ctr = NULL;
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
- return False;
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
- return False;
+ if (NT_STATUS_IS_OK(status)) {
+ r_u->ptr = 1;
+ r_u->ctr = ctr;
+ }
- return True;
+ r_u->status = status; /* return status */
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
- prs_struct *ps, int depth)
+bool samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
+ prs_struct *ps, int depth)
{
if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_connect4");
+ prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
+ if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
return False;
+ if (r_u->ptr != 0) {
+ if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
+ return False;
+ }
+
+ if(!prs_align(ps))
+ return False;
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a SAMR_Q_CONNECT5 structure.
-********************************************************************/
-
-void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
- char *srv_name, uint32 access_mask)
-{
- DEBUG(5, ("init_samr_q_connect5\n"));
-
- /* make PDC server name \\server */
- q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
- init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
-
- /* example values: 0x0000 0002 */
- q_u->access_mask = access_mask;
-
- q_u->level = 1;
- q_u->info1_unk1 = 3;
- q_u->info1_unk2 = 0;
-}
-
-/*******************************************************************
-inits a SAMR_R_CONNECT5 structure.
+inits a SAMR_Q_SET_USERINFO structure.
********************************************************************/
-void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
+void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
+ const POLICY_HND *hnd, DATA_BLOB *sess_key,
+ uint16 switch_value, void *info)
{
- DEBUG(5, ("init_samr_q_connect5\n"));
-
- r_u->level = 1;
- r_u->info1_unk1 = 3;
- r_u->info1_unk2 = 0;
+ DEBUG(5, ("init_samr_q_set_userinfo\n"));
- r_u->connect_pol = *pol;
- r_u->status = status;
+ q_u->pol = *hnd;
+ q_u->switch_value = switch_value;
+ init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
- prs_struct *ps, int depth)
+bool samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
+ prs_struct *ps, int depth)
{
if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_connect5");
+ prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
- return False;
- if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
- return False;
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
- if(!prs_align(ps))
+ if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
return False;
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
+ if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
- return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
- return False;
- if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
- return False;
+ return True;
+}
+
+/*******************************************************************
+inits a SAMR_R_SET_USERINFO structure.
+********************************************************************/
- return True;
+void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
+{
+ DEBUG(5, ("init_samr_r_set_userinfo\n"));
+
+ r_u->status = status; /* return status */
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
- prs_struct *ps, int depth)
+bool samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
+ prs_struct *ps, int depth)
{
if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_connect5");
+ prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("level", ps, depth, &r_u->level))
- return False;
- if(!prs_uint32("level", ps, depth, &r_u->level))
- return False;
- if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
- return False;
- if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
- return False;
-
- if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
- return False;
-
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
}
/*******************************************************************
-inits a SAMR_Q_CONNECT_ANON structure.
+inits a SAMR_Q_SET_USERINFO2 structure.
********************************************************************/
-void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
+void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
+ const POLICY_HND *hnd, DATA_BLOB *sess_key,
+ uint16 switch_value, SAM_USERINFO_CTR * ctr)
{
- DEBUG(5, ("init_samr_q_connect_anon\n"));
+ DEBUG(5, ("init_samr_q_set_userinfo2\n"));
+
+ q_u->pol = *hnd;
+ q_u->switch_value = switch_value;
+ q_u->ctr = ctr;
+
+ q_u->ctr->switch_value = switch_value;
- q_u->ptr = 1;
- q_u->unknown_0 = 0x5c; /* server name (?!!) */
- q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
+ switch (switch_value) {
+ case 18:
+ SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
+ SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
+ dump_data(100, sess_key->data, sess_key->length);
+ dump_data(100, ctr->info.id18->lm_pwd, 16);
+ dump_data(100, ctr->info.id18->nt_pwd, 16);
+ break;
+ }
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
- prs_struct *ps, int depth)
+bool samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
+ prs_struct *ps, int depth)
{
if (q_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
+ prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
depth++;
if(!prs_align(ps))
return False;
- if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
+ if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
return False;
- if (q_u->ptr) {
- if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
- return False;
- }
- if(!prs_align(ps))
+
+ if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
return False;
- if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
+ if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
return False;
return True;
}
+/*******************************************************************
+inits a SAMR_R_SET_USERINFO2 structure.
+********************************************************************/
+
+void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
+{
+ DEBUG(5, ("init_samr_r_set_userinfo2\n"));
+
+ r_u->status = status; /* return status */
+}
+
/*******************************************************************
reads or writes a structure.
********************************************************************/
-bool samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
- prs_struct *ps, int depth)
+bool samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
+ prs_struct *ps, int depth)
{
if (r_u == NULL)
return False;
- prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
+ prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
depth++;
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
- return False;
-
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
return True;
}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
- POLICY_HND *domain_pol, uint16 switch_value)
-{
- DEBUG(5, ("init_samr_q_query_domain_info2\n"));
-
- q_u->domain_pol = *domain_pol;
- q_u->switch_value = switch_value;
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
- return False;
-
- if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_QUERY_DOMAIN_INFO structure.
-********************************************************************/
-
-void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
- uint16 switch_value, SAM_UNK_CTR * ctr,
- NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_query_domain_info2\n"));
-
- r_u->ptr_0 = 0;
- r_u->switch_value = 0;
- r_u->status = status; /* return status */
-
- if (NT_STATUS_IS_OK(status)) {
- r_u->switch_value = switch_value;
- r_u->ptr_0 = 1;
- r_u->ctr = ctr;
- }
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
- return False;
-
- if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
- if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
- return False;
- if(!prs_align(ps))
- return False;
-
- switch (r_u->switch_value) {
- case 0x0d:
- if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
- return False;
- break;
- case 0x0c:
- if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
- return False;
- break;
- case 0x09:
- if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
- return False;
- break;
- case 0x08:
- if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
- return False;
- break;
- case 0x07:
- if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
- return False;
- break;
- case 0x06:
- if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
- return False;
- break;
- case 0x05:
- if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
- return False;
- break;
- case 0x04:
- if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
- return False;
- break;
- case 0x03:
- if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
- return False;
- break;
- case 0x02:
- if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
- return False;
- break;
- case 0x01:
- if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
- return False;
- break;
- default:
- DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
- r_u->switch_value));
- r_u->status = NT_STATUS_INVALID_INFO_CLASS;
- return False;
- }
- }
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
- POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
-{
- DEBUG(5, ("init_samr_q_set_domain_info\n"));
-
- q_u->domain_pol = *domain_pol;
- q_u->switch_value0 = switch_value;
-
- q_u->switch_value = switch_value;
- q_u->ctr = ctr;
-
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
- prs_struct *ps, int depth)
-{
- if (q_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
- return False;
-
- if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
- return False;
-
- if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if (UNMARSHALLING(ps)) {
- if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
- return False;
- }
-
- switch (q_u->switch_value) {
-
- case 0x0c:
- if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
- return False;
- break;
- case 0x07:
- if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
- return False;
- break;
- case 0x06:
- if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
- return False;
- break;
- case 0x05:
- if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
- return False;
- break;
- case 0x03:
- if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
- return False;
- break;
- case 0x02:
- if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
- return False;
- break;
- case 0x01:
- if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
- return False;
- break;
- default:
- DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
- q_u->switch_value));
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
-inits a SAMR_R_QUERY_DOMAIN_INFO structure.
-********************************************************************/
-
-void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
-{
- DEBUG(5, ("init_samr_r_set_domain_info\n"));
-
- r_u->status = status; /* return status */
-}
-
-/*******************************************************************
-reads or writes a structure.
-********************************************************************/
-
-bool samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
- prs_struct *ps, int depth)
-{
- if (r_u == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_ntstatus("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
static bool api_eventlog_open_eventlog(pipes_struct *p)
{
- EVENTLOG_Q_OPEN_EVENTLOG q_u;
- EVENTLOG_R_OPEN_EVENTLOG r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!(eventlog_io_q_open_eventlog("", &q_u, data, 0))) {
- DEBUG(0, ("eventlog_io_q_open_eventlog: unable to unmarshall EVENTLOG_Q_OPEN_EVENTLOG.\n"));
- return False;
- }
-
- r_u.status = _eventlog_open_eventlog(p, &q_u, &r_u);
-
- if (!(eventlog_io_r_open_eventlog("", &r_u, rdata, 0))) {
- DEBUG(0, ("eventlog_io_r_open_eventlog: unable to marshall EVENTLOG_R_OPEN_EVENTLOG.\n"));
- return False;
- }
-
- return True;
+ return proxy_eventlog_call(p, NDR_EVENTLOG_OPENEVENTLOGW);
}
static bool api_eventlog_close_eventlog(pipes_struct *p)
static bool api_eventlog_get_num_records(pipes_struct *p)
{
- EVENTLOG_Q_GET_NUM_RECORDS q_u;
- EVENTLOG_R_GET_NUM_RECORDS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!(eventlog_io_q_get_num_records("", &q_u, data, 0))) {
- DEBUG(0, ("eventlog_io_q_get_num_records: unable to unmarshall EVENTLOG_Q_GET_NUM_RECORDS.\n"));
- return False;
- }
-
- r_u.status = _eventlog_get_num_records(p, &q_u, &r_u);
-
- if (!(eventlog_io_r_get_num_records("", &r_u, rdata, 0))) {
- DEBUG(0, ("eventlog_io_r_get_num_records: unable to marshall EVENTLOG_R_GET_NUM_RECORDS.\n"));
- return False;
- }
-
- return True;
+ return proxy_eventlog_call(p, NDR_EVENTLOG_GETNUMRECORDS);
}
static bool api_eventlog_get_oldest_entry(pipes_struct *p)
{
- EVENTLOG_Q_GET_OLDEST_ENTRY q_u;
- EVENTLOG_R_GET_OLDEST_ENTRY r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!(eventlog_io_q_get_oldest_entry("", &q_u, data, 0))) {
- DEBUG(0, ("eventlog_io_q_get_oldest_entry: unable to unmarshall EVENTLOG_Q_GET_OLDEST_ENTRY.\n"));
- return False;
- }
-
- r_u.status = _eventlog_get_oldest_entry(p, &q_u, &r_u);
-
- if (!(eventlog_io_r_get_oldest_entry("", &r_u, rdata, 0))) {
- DEBUG(0, ("eventlog_io_r_get_oldest_entry: unable to marshall EVENTLOG_R_GET_OLDEST_ENTRY.\n"));
- return False;
- }
-
- return True;
+ return proxy_eventlog_call(p, NDR_EVENTLOG_GETOLDESTRECORD);
}
static bool api_eventlog_read_eventlog(pipes_struct *p)
static bool api_eventlog_clear_eventlog(pipes_struct *p)
{
- EVENTLOG_Q_CLEAR_EVENTLOG q_u;
- EVENTLOG_R_CLEAR_EVENTLOG r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!(eventlog_io_q_clear_eventlog("", &q_u, data, 0))) {
- DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to unmarshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
- return False;
- }
-
- r_u.status = _eventlog_clear_eventlog(p, &q_u, &r_u);
-
- if (!(eventlog_io_r_clear_eventlog("", &r_u, rdata, 0))) {
- DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to marshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
- return False;
- }
-
- return True;
+ return proxy_eventlog_call(p, NDR_EVENTLOG_CLEAREVENTLOGW);
}
/*
********************************************************************/
static Eventlog_entry *read_package_entry( prs_struct * ps,
- EVENTLOG_Q_READ_EVENTLOG * q_u,
- EVENTLOG_R_READ_EVENTLOG * r_u,
Eventlog_entry * entry )
{
uint8 *offset;
}
/********************************************************************
+ _eventlog_OpenEventLogW
********************************************************************/
-NTSTATUS _eventlog_open_eventlog( pipes_struct * p,
- EVENTLOG_Q_OPEN_EVENTLOG * q_u,
- EVENTLOG_R_OPEN_EVENTLOG * r_u )
+NTSTATUS _eventlog_OpenEventLogW(pipes_struct *p,
+ struct eventlog_OpenEventLogW *r)
{
- fstring servername, logname;
+ const char *servername = "";
+ const char *logname = "";
EVENTLOG_INFO *info;
NTSTATUS result;
- fstrcpy( servername, "" );
- if ( q_u->servername.string ) {
- rpcstr_pull( servername, q_u->servername.string->buffer,
- sizeof( servername ),
- q_u->servername.string->uni_str_len * 2, 0 );
+ if (r->in.servername->string) {
+ servername = r->in.servername->string;
}
- fstrcpy( logname, "" );
- if ( q_u->logname.string ) {
- rpcstr_pull( logname, q_u->logname.string->buffer,
- sizeof( logname ),
- q_u->logname.string->uni_str_len * 2, 0 );
+ if (r->in.logname->string) {
+ logname = r->in.logname->string;
}
DEBUG( 10,("_eventlog_open_eventlog: Server [%s], Log [%s]\n",
/* according to MSDN, if the logfile cannot be found, we should
default to the "Application" log */
- if ( !NT_STATUS_IS_OK( result = elog_open( p, logname, &r_u->handle )) )
+ if ( !NT_STATUS_IS_OK( result = elog_open( p, logname, r->out.handle )) )
return result;
- if ( !(info = find_eventlog_info_by_hnd( p, &r_u->handle )) ) {
+ if ( !(info = find_eventlog_info_by_hnd( p, r->out.handle )) ) {
DEBUG(0,("_eventlog_open_eventlog: eventlog (%s) opened but unable to find handle!\n",
logname ));
- elog_close( p, &r_u->handle );
+ elog_close( p, r->out.handle );
return NT_STATUS_INVALID_HANDLE;
}
}
/********************************************************************
+ _eventlog_ClearEventLogW
This call still needs some work
********************************************************************/
-
-NTSTATUS _eventlog_clear_eventlog( pipes_struct * p,
- EVENTLOG_Q_CLEAR_EVENTLOG * q_u,
- EVENTLOG_R_CLEAR_EVENTLOG * r_u )
-{
- EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle );
- char *backup_file_name = NULL;
+/** The windows client seems to be doing something funny with the file name
+ A call like
+ ClearEventLog(handle, "backup_file")
+ on the client side will result in the backup file name looking like this on the
+ server side:
+ \??\${CWD of client}\backup_file
+ If an absolute path gets specified, such as
+ ClearEventLog(handle, "C:\\temp\\backup_file")
+ then it is still mangled by the client into this:
+ \??\C:\temp\backup_file
+ when it is on the wire.
+ I'm not sure where the \?? is coming from, or why the ${CWD} of the client process
+ would be added in given that the backup file gets written on the server side. */
+
+NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p,
+ struct eventlog_ClearEventLogW *r)
+{
+ EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle );
+ const char *backup_file_name = NULL;
if ( !info )
return NT_STATUS_INVALID_HANDLE;
- if (q_u->backupfile.string) {
- size_t len = rpcstr_pull_talloc(p->mem_ctx,
- &backup_file_name,
- q_u->backupfile.string->buffer,
- q_u->backupfile.string->uni_str_len * 2,
- 0 );
- if (len == (size_t)-1 || !backup_file_name) {
- return NT_STATUS_INVALID_PARAMETER;
- }
+ if (r->in.backupfile && r->in.backupfile->string) {
+
+ backup_file_name = r->in.backupfile->string;
DEBUG(8,( "_eventlog_clear_eventlog: Using [%s] as the backup "
"file name for log [%s].",
/* Now see if there is enough room to add */
- if ( !(ee_new = read_package_entry( ps, q_u, r_u, entry )) )
+ if ( !(ee_new = read_package_entry( ps, entry )) )
return NT_STATUS_NO_MEMORY;
if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) {
}
/********************************************************************
+ _eventlog_GetOldestRecord
********************************************************************/
-NTSTATUS _eventlog_get_oldest_entry( pipes_struct * p,
- EVENTLOG_Q_GET_OLDEST_ENTRY * q_u,
- EVENTLOG_R_GET_OLDEST_ENTRY * r_u )
+NTSTATUS _eventlog_GetOldestRecord(pipes_struct *p,
+ struct eventlog_GetOldestRecord *r)
{
- EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle );
+ EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle );
if (info == NULL) {
return NT_STATUS_INVALID_HANDLE;
if ( !( get_oldest_entry_hook( info ) ) )
return NT_STATUS_ACCESS_DENIED;
- r_u->oldest_entry = info->oldest_entry;
+ *r->out.oldest_entry = info->oldest_entry;
return NT_STATUS_OK;
}
/********************************************************************
+_eventlog_GetNumRecords
********************************************************************/
-NTSTATUS _eventlog_get_num_records( pipes_struct * p,
- EVENTLOG_Q_GET_NUM_RECORDS * q_u,
- EVENTLOG_R_GET_NUM_RECORDS * r_u )
+NTSTATUS _eventlog_GetNumRecords(pipes_struct *p,
+ struct eventlog_GetNumRecords *r)
{
- EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle );
+ EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle );
if (info == NULL) {
return NT_STATUS_INVALID_HANDLE;
if ( !( get_num_records_hook( info ) ) )
return NT_STATUS_ACCESS_DENIED;
- r_u->num_records = info->num_records;
+ *r->out.number = info->num_records;
return NT_STATUS_OK;
}
-NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, struct eventlog_ClearEventLogW *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _eventlog_BackupEventLogW(pipes_struct *p, struct eventlog_BackupEventLogW *r)
{
p->rng_fault_state = True;
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS _eventlog_GetNumRecords(pipes_struct *p, struct eventlog_GetNumRecords *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS _eventlog_GetOldestRecord(pipes_struct *p, struct eventlog_GetOldestRecord *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _eventlog_ChangeNotify(pipes_struct *p, struct eventlog_ChangeNotify *r)
{
p->rng_fault_state = True;
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS _eventlog_OpenEventLogW(pipes_struct *p, struct eventlog_OpenEventLogW *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _eventlog_RegisterEventSourceW(pipes_struct *p, struct eventlog_RegisterEventSourceW *r)
{
p->rng_fault_state = True;
static bool api_lsa_open_policy2(pipes_struct *p)
{
- LSA_Q_OPEN_POL2 q_u;
- LSA_R_OPEN_POL2 r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the server, object attributes and desired access flag...*/
- if(!lsa_io_q_open_pol2("", &q_u, data, 0)) {
- DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
- return False;
- }
-
- r_u.status = _lsa_open_policy2(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) {
- DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
- return False;
- }
-
- return True;
+ return proxy_lsa_call(p, NDR_LSA_OPENPOLICY2);
}
/***************************************************************************
static bool api_lsa_open_policy(pipes_struct *p)
{
- LSA_Q_OPEN_POL q_u;
- LSA_R_OPEN_POL r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the server, object attributes and desired access flag...*/
- if(!lsa_io_q_open_pol("", &q_u, data, 0)) {
- DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
- return False;
- }
-
- r_u.status = _lsa_open_policy(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) {
- DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
- return False;
- }
-
- return True;
+ return proxy_lsa_call(p, NDR_LSA_OPENPOLICY);
}
/***************************************************************************
static bool api_lsa_query_secobj(pipes_struct *p)
{
- LSA_Q_QUERY_SEC_OBJ q_u;
- LSA_R_QUERY_SEC_OBJ r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!lsa_io_q_query_sec_obj("", &q_u, data, 0)) {
- DEBUG(0,("api_lsa_query_secobj: failed to unmarshall LSA_Q_QUERY_SEC_OBJ.\n"));
- return False;
- }
-
- r_u.status = _lsa_query_secobj(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!lsa_io_r_query_sec_obj("", &r_u, rdata, 0)) {
- DEBUG(0,("api_lsa_query_secobj: Failed to marshall LSA_R_QUERY_SEC_OBJ.\n"));
- return False;
- }
-
- return True;
+ return proxy_lsa_call(p, NDR_LSA_QUERYSECURITY);
}
/***************************************************************************
static bool api_lsa_delete_object(pipes_struct *p)
{
- LSA_Q_DELETE_OBJECT q_u;
- LSA_R_DELETE_OBJECT r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!lsa_io_q_delete_object("", &q_u, data, 0)) {
- DEBUG(0,("api_lsa_delete_object: failed to unmarshall LSA_Q_DELETE_OBJECT.\n"));
- return False;
- }
-
- r_u.status = _lsa_delete_object(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!lsa_io_r_delete_object("", &r_u, rdata, 0)) {
- DEBUG(0,("api_lsa_delete_object: Failed to marshall LSA_R_DELETE_OBJECT.\n"));
- return False;
- }
-
- return True;
+ return proxy_lsa_call(p, NDR_LSA_DELETEOBJECT);
}
/***************************************************************************
/***************************************************************************
- _lsa_open_policy2.
+ _lsa_OpenPolicy2
***************************************************************************/
-NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u)
+NTSTATUS _lsa_OpenPolicy2(pipes_struct *p,
+ struct lsa_OpenPolicy2 *r)
{
struct lsa_info *info;
SEC_DESC *psd = NULL;
size_t sd_size;
- uint32 des_access=q_u->des_access;
+ uint32 des_access = r->in.access_mask;
uint32 acc_granted;
NTSTATUS status;
info->access = acc_granted;
/* set up the LSA QUERY INFO response */
- if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
}
/***************************************************************************
- _lsa_open_policy
+ _lsa_OpenPolicy
***************************************************************************/
-NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u)
+NTSTATUS _lsa_OpenPolicy(pipes_struct *p,
+ struct lsa_OpenPolicy *r)
{
struct lsa_info *info;
SEC_DESC *psd = NULL;
size_t sd_size;
- uint32 des_access=q_u->des_access;
+ uint32 des_access= r->in.access_mask;
uint32 acc_granted;
NTSTATUS status;
info->access = acc_granted;
/* set up the LSA QUERY INFO response */
- if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
}
/***************************************************************************
+ _lsa_DeleteObject
***************************************************************************/
-NTSTATUS _lsa_delete_object(pipes_struct *p, LSA_Q_DELETE_OBJECT *q_u, LSA_R_DELETE_OBJECT *r_u)
+NTSTATUS _lsa_DeleteObject(pipes_struct *p,
+ struct lsa_DeleteObject *r)
{
return NT_STATUS_ACCESS_DENIED;
}
}
/***************************************************************************
- For a given SID, remove some privileges.
+ _lsa_QuerySecurity
***************************************************************************/
-NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUERY_SEC_OBJ *r_u)
+NTSTATUS _lsa_QuerySecurity(pipes_struct *p,
+ struct lsa_QuerySecurity *r)
{
struct lsa_info *handle=NULL;
SEC_DESC *psd = NULL;
size_t sd_size;
NTSTATUS status;
- r_u->status = NT_STATUS_OK;
-
/* find the connection policy handle. */
- if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
+ if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
return NT_STATUS_INVALID_HANDLE;
/* check if the user have enough rights */
return NT_STATUS_ACCESS_DENIED;
- switch (q_u->sec_info) {
+ switch (r->in.sec_info) {
case 1:
/* SD contains only the owner */
return NT_STATUS_NO_MEMORY;
- if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
+ if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
return NT_STATUS_NO_MEMORY;
break;
case 4:
if(!NT_STATUS_IS_OK(status))
return NT_STATUS_NO_MEMORY;
- if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
+ if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
return NT_STATUS_NO_MEMORY;
break;
default:
return NT_STATUS_INVALID_LEVEL;
}
- r_u->ptr=1;
-
- return r_u->status;
+ return status;
}
#if 0 /* AD DC work in ongoing in Samba 4 */
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct lsa_QuerySecurity *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r)
{
p->rng_fault_state = True;
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS _lsa_OpenPolicy(pipes_struct *p, struct lsa_OpenPolicy *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct lsa_QueryInfoPolicy *r)
{
p->rng_fault_state = True;
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS _lsa_DeleteObject(pipes_struct *p, struct lsa_DeleteObject *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r)
{
p->rng_fault_state = True;
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, struct lsa_OpenPolicy2 *r)
-{
- p->rng_fault_state = True;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r)
{
p->rng_fault_state = True;
-/*
+/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Marc Jacobsen 1999,
* Copyright (C) Jean François Micouleau 1998-2001,
* Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002-2003.
- *
- * Split into interface and implementation modules by,
+ *
+ * Split into interface and implementation modules by,
*
* Copyright (C) Jeremy Allison 2001.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
static bool api_samr_open_domain(pipes_struct *p)
{
- SAMR_Q_OPEN_DOMAIN q_u;
- SAMR_R_OPEN_DOMAIN r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_open_domain("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_open_domain: unable to unmarshall SAMR_Q_OPEN_DOMAIN.\n"));
- return False;
- }
-
- r_u.status = _samr_open_domain(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_open_domain("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_open_domain: unable to marshall SAMR_R_OPEN_DOMAIN.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_OPENDOMAIN);
}
/*******************************************************************
static bool api_samr_get_usrdom_pwinfo(pipes_struct *p)
{
- SAMR_Q_GET_USRDOM_PWINFO q_u;
- SAMR_R_GET_USRDOM_PWINFO r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_get_usrdom_pwinfo("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_get_usrdom_pwinfo: unable to unmarshall SAMR_Q_GET_USRDOM_PWINFO.\n"));
- return False;
- }
-
- r_u.status = _samr_get_usrdom_pwinfo(p, &q_u, &r_u);
-
- if(!samr_io_r_get_usrdom_pwinfo("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_get_usrdom_pwinfo: unable to marshall SAMR_R_GET_USRDOM_PWINFO.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_GETUSERPWINFO);
}
/*******************************************************************
static bool api_samr_set_sec_obj(pipes_struct *p)
{
- SAMR_Q_SET_SEC_OBJ q_u;
- SAMR_R_SET_SEC_OBJ r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_set_sec_obj("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_set_sec_obj: unable to unmarshall SAMR_Q_SET_SEC_OBJ.\n"));
- return False;
- }
-
- r_u.status = _samr_set_sec_obj(p, &q_u, &r_u);
-
- if(!samr_io_r_set_sec_obj("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_set_sec_obj: unable to marshall SAMR_R_SET_SEC_OBJ.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_SETSECURITY);
}
/*******************************************************************
static bool api_samr_query_sec_obj(pipes_struct *p)
{
- SAMR_Q_QUERY_SEC_OBJ q_u;
- SAMR_R_QUERY_SEC_OBJ r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_query_sec_obj("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_query_sec_obj: unable to unmarshall SAMR_Q_QUERY_SEC_OBJ.\n"));
- return False;
- }
-
- r_u.status = _samr_query_sec_obj(p, &q_u, &r_u);
-
- if(!samr_io_r_query_sec_obj("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_query_sec_obj: unable to marshall SAMR_R_QUERY_SEC_OBJ.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_QUERYSECURITY);
}
/*******************************************************************
SAMR_R_ENUM_DOM_ALIASES r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
-
+
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
DEBUG(0,("api_samr_query_aliasinfo: unable to marshall SAMR_R_QUERY_ALIASINFO.\n"));
return False;
}
-
+
return True;
}
static bool api_samr_chgpasswd_user(pipes_struct *p)
{
- SAMR_Q_CHGPASSWD_USER q_u;
- SAMR_R_CHGPASSWD_USER r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* change password request */
- if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_chgpasswd_user: Failed to unmarshall SAMR_Q_CHGPASSWD_USER.\n"));
- return False;
- }
-
- r_u.status = _samr_chgpasswd_user(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_chgpasswd_user("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_chgpasswd_user: Failed to marshall SAMR_R_CHGPASSWD_USER.\n" ));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CHANGEPASSWORDUSER2);
}
/*******************************************************************
static bool api_samr_open_user(pipes_struct *p)
{
- SAMR_Q_OPEN_USER q_u;
- SAMR_R_OPEN_USER r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_open_user("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_open_user: unable to unmarshall SAMR_Q_OPEN_USER.\n"));
- return False;
- }
-
- r_u.status = _samr_open_user(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_open_user("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_open_user: unable to marshall SAMR_R_OPEN_USER.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_OPENUSER);
}
/*******************************************************************
static bool api_samr_query_domain_info(pipes_struct *p)
{
- SAMR_Q_QUERY_DOMAIN_INFO q_u;
- SAMR_R_QUERY_DOMAIN_INFO r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_query_domain_info("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_query_domain_info: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO.\n"));
- return False;
- }
-
- r_u.status = _samr_query_domain_info(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_query_domain_info("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_query_domain_info: unable to marshall SAMR_R_QUERY_DOMAIN_INFO.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_QUERYDOMAININFO);
}
/*******************************************************************
static bool api_samr_create_user(pipes_struct *p)
{
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- SAMR_Q_CREATE_USER q_u;
- SAMR_R_CREATE_USER r_u;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the samr create user */
- if (!samr_io_q_create_user("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n"));
- return False;
- }
-
- r_u.status=_samr_create_user(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_create_user("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_create_user: Unable to marshall SAMR_R_CREATE_USER.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CREATEUSER2);
}
/*******************************************************************
static bool api_samr_connect_anon(pipes_struct *p)
{
- SAMR_Q_CONNECT_ANON q_u;
- SAMR_R_CONNECT_ANON r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the samr open policy */
- if(!samr_io_q_connect_anon("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_connect_anon: unable to unmarshall SAMR_Q_CONNECT_ANON.\n"));
- return False;
- }
-
- r_u.status = _samr_connect_anon(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_connect_anon: unable to marshall SAMR_R_CONNECT_ANON.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CONNECT);
}
/*******************************************************************
static bool api_samr_connect(pipes_struct *p)
{
- SAMR_Q_CONNECT q_u;
- SAMR_R_CONNECT r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the samr open policy */
- if(!samr_io_q_connect("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_connect: unable to unmarshall SAMR_Q_CONNECT.\n"));
- return False;
- }
-
- r_u.status = _samr_connect(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_connect("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_connect: unable to marshall SAMR_R_CONNECT.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CONNECT2);
}
/*******************************************************************
static bool api_samr_connect4(pipes_struct *p)
{
- SAMR_Q_CONNECT4 q_u;
- SAMR_R_CONNECT4 r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the samr open policy */
- if(!samr_io_q_connect4("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_connect4: unable to unmarshall SAMR_Q_CONNECT4.\n"));
- return False;
- }
-
- r_u.status = _samr_connect4(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_connect4("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_connect4: unable to marshall SAMR_R_CONNECT4.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CONNECT4);
}
/*******************************************************************
static bool api_samr_connect5(pipes_struct *p)
{
- SAMR_Q_CONNECT5 q_u;
- SAMR_R_CONNECT5 r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the samr open policy */
- if(!samr_io_q_connect5("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_connect5: unable to unmarshall SAMR_Q_CONNECT5.\n"));
- return False;
- }
-
- r_u.status = _samr_connect5(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_connect5("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_connect5: unable to marshall SAMR_R_CONNECT5.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CONNECT5);
}
/**********************************************************************
static bool api_samr_lookup_domain(pipes_struct *p)
{
- SAMR_Q_LOOKUP_DOMAIN q_u;
- SAMR_R_LOOKUP_DOMAIN r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_lookup_domain("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_lookup_domain: Unable to unmarshall SAMR_Q_LOOKUP_DOMAIN.\n"));
- return False;
- }
-
- r_u.status = _samr_lookup_domain(p, &q_u, &r_u);
-
- if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)){
- DEBUG(0,("api_samr_lookup_domain: Unable to marshall SAMR_R_LOOKUP_DOMAIN.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_LOOKUPDOMAIN);
}
/**********************************************************************
SAMR_R_ENUM_DOMAINS r_u;
prs_struct *data = &p->in_data.data;
prs_struct *rdata = &p->out_data.rdata;
-
+
ZERO_STRUCT(q_u);
ZERO_STRUCT(r_u);
DEBUG(0,("api_samr_enum_domains: Unable to marshall SAMR_R_ENUM_DOMAINS.\n"));
return False;
}
-
+
return True;
}
static bool api_samr_open_alias(pipes_struct *p)
{
- SAMR_Q_OPEN_ALIAS q_u;
- SAMR_R_OPEN_ALIAS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- /* grab the samr open policy */
- if(!samr_io_q_open_alias("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_open_alias: Unable to unmarshall SAMR_Q_OPEN_ALIAS.\n"));
- return False;
- }
-
- r_u.status=_samr_open_alias(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_open_alias("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_open_alias: Unable to marshall SAMR_R_OPEN_ALIAS.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_OPENALIAS);
}
/*******************************************************************
static bool api_samr_query_useraliases(pipes_struct *p)
{
- SAMR_Q_QUERY_USERALIASES q_u;
- SAMR_R_QUERY_USERALIASES r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_query_useraliases("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_query_useraliases: Unable to unmarshall SAMR_Q_QUERY_USERALIASES.\n"));
- return False;
- }
-
- r_u.status = _samr_query_useraliases(p, &q_u, &r_u);
-
- if (! samr_io_r_query_useraliases("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_query_useraliases: Unable to nmarshall SAMR_R_QUERY_USERALIASES.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_GETALIASMEMBERSHIP);
}
/*******************************************************************
static bool api_samr_query_aliasmem(pipes_struct *p)
{
- SAMR_Q_QUERY_ALIASMEM q_u;
- SAMR_R_QUERY_ALIASMEM r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_query_aliasmem("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_query_aliasmem: unable to unmarshall SAMR_Q_QUERY_ALIASMEM.\n"));
- return False;
- }
-
- r_u.status = _samr_query_aliasmem(p, &q_u, &r_u);
-
- if (!samr_io_r_query_aliasmem("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_query_aliasmem: unable to marshall SAMR_R_QUERY_ALIASMEM.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_GETMEMBERSINALIAS);
}
/*******************************************************************
static bool api_samr_query_groupmem(pipes_struct *p)
{
- SAMR_Q_QUERY_GROUPMEM q_u;
- SAMR_R_QUERY_GROUPMEM r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_query_groupmem("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_query_groupmem: unable to unmarshall SAMR_Q_QUERY_GROUPMEM.\n"));
- return False;
- }
-
- r_u.status = _samr_query_groupmem(p, &q_u, &r_u);
-
- if (!samr_io_r_query_groupmem("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_query_groupmem: unable to marshall SAMR_R_QUERY_GROUPMEM.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_QUERYGROUPMEMBER);
}
/*******************************************************************
static bool api_samr_add_aliasmem(pipes_struct *p)
{
- SAMR_Q_ADD_ALIASMEM q_u;
- SAMR_R_ADD_ALIASMEM r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_add_aliasmem("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_add_aliasmem: unable to unmarshall SAMR_Q_ADD_ALIASMEM.\n"));
- return False;
- }
-
- r_u.status = _samr_add_aliasmem(p, &q_u, &r_u);
-
- if (!samr_io_r_add_aliasmem("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_add_aliasmem: unable to marshall SAMR_R_ADD_ALIASMEM.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_ADDALIASMEMBER);
}
/*******************************************************************
static bool api_samr_del_aliasmem(pipes_struct *p)
{
- SAMR_Q_DEL_ALIASMEM q_u;
- SAMR_R_DEL_ALIASMEM r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_del_aliasmem("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_del_aliasmem: unable to unmarshall SAMR_Q_DEL_ALIASMEM.\n"));
- return False;
- }
-
- r_u.status = _samr_del_aliasmem(p, &q_u, &r_u);
-
- if (!samr_io_r_del_aliasmem("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_del_aliasmem: unable to marshall SAMR_R_DEL_ALIASMEM.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_DELETEALIASMEMBER);
}
/*******************************************************************
static bool api_samr_add_groupmem(pipes_struct *p)
{
- SAMR_Q_ADD_GROUPMEM q_u;
- SAMR_R_ADD_GROUPMEM r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_add_groupmem("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_add_groupmem: unable to unmarshall SAMR_Q_ADD_GROUPMEM.\n"));
- return False;
- }
-
- r_u.status = _samr_add_groupmem(p, &q_u, &r_u);
-
- if (!samr_io_r_add_groupmem("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_add_groupmem: unable to marshall SAMR_R_ADD_GROUPMEM.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_ADDGROUPMEMBER);
}
/*******************************************************************
static bool api_samr_del_groupmem(pipes_struct *p)
{
- SAMR_Q_DEL_GROUPMEM q_u;
- SAMR_R_DEL_GROUPMEM r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_del_groupmem("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_del_groupmem: unable to unmarshall SAMR_Q_DEL_GROUPMEM.\n"));
- return False;
- }
-
- r_u.status = _samr_del_groupmem(p, &q_u, &r_u);
-
- if (!samr_io_r_del_groupmem("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_del_groupmem: unable to marshall SAMR_R_DEL_GROUPMEM.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_DELETEGROUPMEMBER);
}
/*******************************************************************
static bool api_samr_delete_dom_user(pipes_struct *p)
{
- SAMR_Q_DELETE_DOM_USER q_u;
- SAMR_R_DELETE_DOM_USER r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_delete_dom_user("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_delete_dom_user: unable to unmarshall SAMR_Q_DELETE_DOM_USER.\n"));
- return False;
- }
-
- r_u.status = _samr_delete_dom_user(p, &q_u, &r_u);
-
- if (!samr_io_r_delete_dom_user("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_delete_dom_user: unable to marshall SAMR_R_DELETE_DOM_USER.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_DELETEUSER);
}
/*******************************************************************
static bool api_samr_delete_dom_group(pipes_struct *p)
{
- SAMR_Q_DELETE_DOM_GROUP q_u;
- SAMR_R_DELETE_DOM_GROUP r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_delete_dom_group("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_delete_dom_group: unable to unmarshall SAMR_Q_DELETE_DOM_GROUP.\n"));
- return False;
- }
-
- r_u.status = _samr_delete_dom_group(p, &q_u, &r_u);
-
- if (!samr_io_r_delete_dom_group("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_delete_dom_group: unable to marshall SAMR_R_DELETE_DOM_GROUP.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_DELETEDOMAINGROUP);
}
/*******************************************************************
static bool api_samr_delete_dom_alias(pipes_struct *p)
{
- SAMR_Q_DELETE_DOM_ALIAS q_u;
- SAMR_R_DELETE_DOM_ALIAS r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_delete_dom_alias("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_delete_dom_alias: unable to unmarshall SAMR_Q_DELETE_DOM_ALIAS.\n"));
- return False;
- }
-
- r_u.status = _samr_delete_dom_alias(p, &q_u, &r_u);
-
- if (!samr_io_r_delete_dom_alias("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_delete_dom_alias: unable to marshall SAMR_R_DELETE_DOM_ALIAS.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_DELETEDOMALIAS);
}
/*******************************************************************
static bool api_samr_create_dom_group(pipes_struct *p)
{
- SAMR_Q_CREATE_DOM_GROUP q_u;
- SAMR_R_CREATE_DOM_GROUP r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_create_dom_group("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_create_dom_group: unable to unmarshall SAMR_Q_CREATE_DOM_GROUP.\n"));
- return False;
- }
-
- r_u.status = _samr_create_dom_group(p, &q_u, &r_u);
-
- if (!samr_io_r_create_dom_group("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_create_dom_group: unable to marshall SAMR_R_CREATE_DOM_GROUP.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CREATEDOMAINGROUP);
}
/*******************************************************************
static bool api_samr_create_dom_alias(pipes_struct *p)
{
- SAMR_Q_CREATE_DOM_ALIAS q_u;
- SAMR_R_CREATE_DOM_ALIAS r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_create_dom_alias("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_create_dom_alias: unable to unmarshall SAMR_Q_CREATE_DOM_ALIAS.\n"));
- return False;
- }
-
- r_u.status = _samr_create_dom_alias(p, &q_u, &r_u);
-
- if (!samr_io_r_create_dom_alias("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_create_dom_alias: unable to marshall SAMR_R_CREATE_DOM_ALIAS.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_CREATEDOMALIAS);
}
/*******************************************************************
static bool api_samr_open_group(pipes_struct *p)
{
- SAMR_Q_OPEN_GROUP q_u;
- SAMR_R_OPEN_GROUP r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_open_group("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_open_group: unable to unmarshall SAMR_Q_OPEN_GROUP.\n"));
- return False;
- }
-
- r_u.status = _samr_open_group(p, &q_u, &r_u);
-
- if (!samr_io_r_open_group("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_open_group: unable to marshall SAMR_R_OPEN_GROUP.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_OPENGROUP);
}
/*******************************************************************
static bool api_samr_remove_sid_foreign_domain(pipes_struct *p)
{
- SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN q_u;
- SAMR_R_REMOVE_SID_FOREIGN_DOMAIN r_u;
-
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!samr_io_q_remove_sid_foreign_domain("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_remove_sid_foreign_domain: unable to unmarshall SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN.\n"));
- return False;
- }
-
- r_u.status = _samr_remove_sid_foreign_domain(p, &q_u, &r_u);
-
- if (!samr_io_r_remove_sid_foreign_domain("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_remove_sid_foreign_domain: unable to marshall SAMR_R_REMOVE_SID_FOREIGN_DOMAIN.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_REMOVEMEMBERFROMFOREIGNDOMAIN);
}
/*******************************************************************
static bool api_samr_query_domain_info2(pipes_struct *p)
{
- SAMR_Q_QUERY_DOMAIN_INFO2 q_u;
- SAMR_R_QUERY_DOMAIN_INFO2 r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_query_domain_info2("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_query_domain_info2: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO2.\n"));
- return False;
- }
-
- r_u.status = _samr_query_domain_info2(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_query_domain_info2("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_query_domain_info2: unable to marshall SAMR_R_QUERY_DOMAIN_INFO2.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_QUERYDOMAININFO2);
}
/*******************************************************************
static bool api_samr_set_dom_info(pipes_struct *p)
{
- SAMR_Q_SET_DOMAIN_INFO q_u;
- SAMR_R_SET_DOMAIN_INFO r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!samr_io_q_set_domain_info("", &q_u, data, 0)) {
- DEBUG(0,("api_samr_set_dom_info: unable to unmarshall SAMR_Q_SET_DOMAIN_INFO.\n"));
- return False;
- }
-
- r_u.status = _samr_set_dom_info(p, &q_u, &r_u);
-
- /* store the response in the SMB stream */
- if(!samr_io_r_set_domain_info("", &r_u, rdata, 0)) {
- DEBUG(0,("api_samr_set_dom_info: unable to marshall SAMR_R_SET_DOMAIN_INFO.\n"));
- return False;
- }
-
- return True;
+ return proxy_samr_call(p, NDR_SAMR_SETDOMAININFO);
}
/*******************************************************************
{"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon },
{"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains },
{"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users },
-
+
{"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups },
{"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases },
{"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases},
{"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem },
{"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem },
{"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem },
-
+
{"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user },
{"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group },
{"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias },
{"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo },
{"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo },
{"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 },
-
+
{"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info},
{"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups },
{"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo },
{"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo },
{"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo },
-
+
{"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo },
{"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo },
{"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo },
{"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain },
{"SAMR_REMOVE_SID_FOREIGN_DOMAIN" , SAMR_REMOVE_SID_FOREIGN_DOMAIN , api_samr_remove_sid_foreign_domain },
{"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain },
-
+
{"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj },
{"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj },
{"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo},
/* add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */
init_sec_access(&mask, map->generic_all);
-
+
init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
init_sec_ace(&ace[i++], &global_sid_Builtin_Account_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
/* Add Full Access for Domain Admins if we are a DC */
-
+
if ( IS_DC ) {
sid_copy( &domadmin_sid, get_global_sam_sid() );
sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS );
level of access for further checks.
********************************************************************/
-static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token,
+static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token,
SE_PRIV *rights, uint32 rights_mask,
- uint32 des_access, uint32 *acc_granted,
+ uint32 des_access, uint32 *acc_granted,
const char *debug )
{
NTSTATUS status = NT_STATUS_ACCESS_DENIED;
uint32 saved_mask = 0;
- /* check privileges; certain SAM access bits should be overridden
- by privileges (mostly having to do with creating/modifying/deleting
+ /* check privileges; certain SAM access bits should be overridden
+ by privileges (mostly having to do with creating/modifying/deleting
users and groups) */
-
+
if ( rights && user_has_any_privilege( token, rights ) ) {
-
+
saved_mask = (des_access & rights_mask);
des_access &= ~saved_mask;
-
+
DEBUG(4,("access_check_samr_object: user rights access mask [0x%x]\n",
rights_mask));
}
-
-
+
+
/* check the security descriptor first */
-
+
if ( se_access_check(psd, token, des_access, acc_granted, &status) )
goto done;
-
+
/* give root a free pass */
-
+
if ( geteuid() == sec_initial_uid() ) {
-
+
DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", debug, des_access));
DEBUGADD(4,("but overritten by euid == sec_initial_uid()\n"));
-
+
*acc_granted = des_access;
-
+
status = NT_STATUS_OK;
goto done;
}
-
-
+
+
done:
- /* add in any bits saved during the privilege check (only
+ /* add in any bits saved during the privilege check (only
matters is status is ok) */
-
+
*acc_granted |= rights_mask;
- DEBUG(4,("%s: access %s (requested: 0x%08x, granted: 0x%08x)\n",
- debug, NT_STATUS_IS_OK(status) ? "GRANTED" : "DENIED",
+ DEBUG(4,("%s: access %s (requested: 0x%08x, granted: 0x%08x)\n",
+ debug, NT_STATUS_IS_OK(status) ? "GRANTED" : "DENIED",
des_access, *acc_granted));
-
+
return status;
}
static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug)
{
- DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n",
+ DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n",
debug, acc_granted, acc_required));
/* check the security descriptor first */
-
+
if ( (acc_granted&acc_required) == acc_required )
return NT_STATUS_OK;
-
+
/* give root a free pass */
if (geteuid() == sec_initial_uid()) {
-
+
DEBUG(4,("%s: ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
debug, acc_granted, acc_required));
DEBUGADD(4,("but overwritten by euid == 0\n"));
-
+
return NT_STATUS_OK;
}
-
- DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n",
+
+ DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n",
debug, acc_granted, acc_required));
-
+
return NT_STATUS_ACCESS_DENIED;
}
/* There are two cases to consider here:
1) The SID is a domain SID and we look for an equality match, or
- 2) This is an account SID and so we return the DISP_INFO* for our
+ 2) This is an account SID and so we return the DISP_INFO* for our
domain */
if (psid == NULL) {
return &builtin_dispinfo;
}
-
+
if (sid_check_is_domain(psid) || sid_check_is_in_our_domain(psid)) {
/*
* Necessary only once, but it does not really hurt.
struct samr_info *info;
fstring sid_str;
TALLOC_CTX *mem_ctx;
-
+
if (psid) {
sid_to_fstring(sid_str, psid);
} else {
static void samr_clear_sam_passwd(struct samu *sam_pass)
{
-
+
if (!sam_pass)
return;
}
/*******************************************************************
- samr_reply_open_domain
+ _samr_OpenDomain
********************************************************************/
-NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u)
+NTSTATUS _samr_OpenDomain(pipes_struct *p,
+ struct samr_OpenDomain *r)
{
struct samr_info *info;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->flags;
+ uint32 des_access = r->in.access_mask;
NTSTATUS status;
size_t sd_size;
SE_PRIV se_rights;
- r_u->status = NT_STATUS_OK;
-
/* find the connection policy handle. */
-
- if ( !find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info) )
+
+ if ( !find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info) )
return NT_STATUS_INVALID_HANDLE;
- status = access_check_samr_function( info->acc_granted,
- SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_open_domain" );
-
+ status = access_check_samr_function( info->acc_granted,
+ SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_OpenDomain" );
+
if ( !NT_STATUS_IS_OK(status) )
return status;
/*check if access can be granted as requested by client. */
-
+
make_samr_object_sd( p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0 );
se_map_generic( &des_access, &dom_generic_mapping );
-
+
se_priv_copy( &se_rights, &se_machine_account );
se_priv_add( &se_rights, &se_add_users );
- status = access_check_samr_object( psd, p->pipe_user.nt_user_token,
- &se_rights, GENERIC_RIGHTS_DOMAIN_WRITE, des_access,
- &acc_granted, "_samr_open_domain" );
-
+ status = access_check_samr_object( psd, p->pipe_user.nt_user_token,
+ &se_rights, GENERIC_RIGHTS_DOMAIN_WRITE, des_access,
+ &acc_granted, "_samr_OpenDomain" );
+
if ( !NT_STATUS_IS_OK(status) )
return status;
- if (!sid_check_is_domain(&q_u->dom_sid.sid) &&
- !sid_check_is_builtin(&q_u->dom_sid.sid)) {
+ if (!sid_check_is_domain(r->in.sid) &&
+ !sid_check_is_builtin(r->in.sid)) {
return NT_STATUS_NO_SUCH_DOMAIN;
}
/* associate the domain SID with the (unique) handle. */
- if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL)
+ if ((info = get_samr_info_by_sid(r->in.sid))==NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.domain_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(5,("samr_open_domain: %d\n", __LINE__));
+ DEBUG(5,("_samr_OpenDomain: %d\n", __LINE__));
- return r_u->status;
+ return NT_STATUS_OK;
}
/*******************************************************************
- _samr_get_usrdom_pwinfo
+ _samr_GetUserPwInfo
********************************************************************/
-NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u)
+NTSTATUS _samr_GetUserPwInfo(pipes_struct *p,
+ struct samr_GetUserPwInfo *r)
{
struct samr_info *info = NULL;
- r_u->status = NT_STATUS_OK;
-
/* find the policy handle. open a policy on it. */
- if (!find_policy_by_hnd(p, &q_u->user_pol, (void **)(void *)&info))
+ if (!find_policy_by_hnd(p, r->in.user_handle, (void **)(void *)&info))
return NT_STATUS_INVALID_HANDLE;
if (!sid_check_is_in_our_domain(&info->sid))
return NT_STATUS_OBJECT_TYPE_MISMATCH;
- init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_OK);
+ ZERO_STRUCTP(r->out.info);
- DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__));
+ DEBUG(5,("_samr_GetUserPwInfo: %d\n", __LINE__));
- /*
+ /*
* NT sometimes return NT_STATUS_ACCESS_DENIED
* I don't know yet why.
*/
- return r_u->status;
+ return NT_STATUS_OK;
}
/*******************************************************************
********************************************************************/
-static bool get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol,
+static bool get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol,
DOM_SID *sid, uint32 *acc_granted,
DISP_INFO **ppdisp_info)
{
}
/*******************************************************************
- _samr_set_sec_obj
+ _samr_SetSecurity
********************************************************************/
-NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u)
+NTSTATUS _samr_SetSecurity(pipes_struct *p,
+ struct samr_SetSecurity *r)
{
DOM_SID pol_sid;
uint32 acc_granted, i;
struct samu *sampass=NULL;
NTSTATUS status;
- r_u->status = NT_STATUS_OK;
-
- if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL))
+ if (!get_lsa_policy_samr_sid(p, r->in.handle, &pol_sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
if (!(sampass = samu_new( p->mem_ctx))) {
return NT_STATUS_INVALID_HANDLE;
}
- dacl = q_u->buf->sd->dacl;
+ dacl = r->in.sdbuf->sd->dacl;
for (i=0; i < dacl->num_aces; i++) {
if (sid_equal(&pol_sid, &dacl->aces[i].trustee)) {
- ret = pdb_set_pass_can_change(sampass,
- (dacl->aces[i].access_mask &
- SA_RIGHT_USER_CHANGE_PASSWORD) ?
+ ret = pdb_set_pass_can_change(sampass,
+ (dacl->aces[i].access_mask &
+ SA_RIGHT_USER_CHANGE_PASSWORD) ?
True: False);
break;
}
return NT_STATUS_ACCESS_DENIED;
}
- status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_set_sec_obj");
+ status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_SetSecurity");
if (NT_STATUS_IS_OK(status)) {
become_root();
status = pdb_update_sam_account(sampass);
/*******************************************************************
- _samr_query_sec_obj
+ _samr_QuerySecurity
********************************************************************/
-NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u)
+NTSTATUS _samr_QuerySecurity(pipes_struct *p,
+ struct samr_QuerySecurity *r)
{
+ NTSTATUS status;
DOM_SID pol_sid;
SEC_DESC * psd = NULL;
uint32 acc_granted;
size_t sd_size;
- r_u->status = NT_STATUS_OK;
-
/* Get the SID. */
- if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted, NULL))
+ if (!get_lsa_policy_samr_sid(p, r->in.handle, &pol_sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
- DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n",
+ DEBUG(10,("_samr_QuerySecurity: querying security on SID: %s\n",
sid_string_dbg(&pol_sid)));
/* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */
/* To query the security of the SAM it self an invalid SID with S-0-0 is passed to this function */
if (pol_sid.sid_rev_num == 0) {
- DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n"));
- r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
- } else if (sid_equal(&pol_sid,get_global_sam_sid())) {
+ DEBUG(5,("_samr_QuerySecurity: querying security on SAM\n"));
+ status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
+ } else if (sid_equal(&pol_sid,get_global_sam_sid())) {
/* check if it is our domain SID */
- DEBUG(5,("_samr_query_sec_obj: querying security on Domain "
+ DEBUG(5,("_samr_QuerySecurity: querying security on Domain "
"with SID: %s\n", sid_string_dbg(&pol_sid)));
- r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0);
+ status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0);
} else if (sid_equal(&pol_sid,&global_sid_Builtin)) {
/* check if it is the Builtin Domain */
/* TODO: Builtin probably needs a different SD with restricted write access*/
- DEBUG(5,("_samr_query_sec_obj: querying security on Builtin "
+ DEBUG(5,("_samr_QuerySecurity: querying security on Builtin "
"Domain with SID: %s\n", sid_string_dbg(&pol_sid)));
- r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0);
+ status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0);
} else if (sid_check_is_in_our_domain(&pol_sid) ||
sid_check_is_in_builtin(&pol_sid)) {
/* TODO: different SDs have to be generated for aliases groups and users.
Currently all three get a default user SD */
- DEBUG(10,("_samr_query_sec_obj: querying security on Object "
+ DEBUG(10,("_samr_QuerySecurity: querying security on Object "
"with SID: %s\n", sid_string_dbg(&pol_sid)));
if (check_change_pw_access(p->mem_ctx, &pol_sid)) {
- r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping,
+ status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping,
&pol_sid, SAMR_USR_RIGHTS_WRITE_PW);
} else {
- r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_nopwchange_generic_mapping,
+ status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_nopwchange_generic_mapping,
&pol_sid, SAMR_USR_RIGHTS_CANT_WRITE_PW);
}
} else {
return NT_STATUS_OBJECT_TYPE_MISMATCH;
}
- if ((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
+ if ((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
return NT_STATUS_NO_MEMORY;
- if (NT_STATUS_IS_OK(r_u->status))
- r_u->ptr = 1;
-
- return r_u->status;
+ return status;
}
/*******************************************************************
uint32 i;
SAM_ENTRY *sam;
UNISTR2 *uni_name;
-
+
*sam_pp = NULL;
*uni_name_pp = NULL;
samr_reply_enum_dom_users
********************************************************************/
-NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u,
+NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u,
SAMR_R_ENUM_DOM_USERS *r_u)
{
struct samr_info *info = NULL;
int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K;
uint32 max_entries = max_sam_entries;
struct samr_displayentry *entries = NULL;
-
+
r_u->status = NT_STATUS_OK;
/* find the policy handle. open a policy on it. */
if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
return NT_STATUS_INVALID_HANDLE;
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted,
- SA_RIGHT_DOMAIN_ENUM_ACCOUNTS,
+ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted,
+ SA_RIGHT_DOMAIN_ENUM_ACCOUNTS,
"_samr_enum_dom_users"))) {
return r_u->status;
}
-
+
DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__));
if (info->builtin_domain) {
}
r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam,
- &r_u->uni_acct_name,
+ &r_u->uni_acct_name,
num_account, enum_context,
entries);
num_groups = pdb_search_entries(info->disp_info->groups, q_u->start_idx,
MAX_SAM_ENTRIES, &groups);
unbecome_root();
-
+
/* Ensure we cache this enumeration. */
set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT);
num_aliases = pdb_search_entries(info->disp_info->aliases, q_u->start_idx,
MAX_SAM_ENTRIES, &aliases);
unbecome_root();
-
+
/* Ensure we cache this enumeration. */
set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT);
samr_reply_query_dispinfo
********************************************************************/
-NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
+NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
SAMR_R_QUERY_DISPINFO *r_u)
{
struct samr_info *info = NULL;
uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */
-
+
uint32 max_entries=q_u->max_entries;
uint32 enum_context=q_u->start_idx;
uint32 max_size=q_u->max_size;
/*
* calculate how many entries we will return.
- * based on
+ * based on
* - the number of entries the client asked
* - our limit on that
* - the starting point (enumeration context)
* return */
temp_size=max_entries*struct_size;
-
+
if (temp_size>max_size) {
max_entries=MIN((max_size/struct_size),max_entries);;
DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to "
become_root();
status = pdb_get_aliasinfo(&sid, &info);
unbecome_root();
-
+
if ( !NT_STATUS_IS_OK(status))
return status;
- if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) )
+ if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) )
return NT_STATUS_NO_MEMORY;
init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH);
return r_u->status;
}
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, 0, "_samr_lookup_names"))) { /* Don't know the acc_bits yet */
return r_u->status;
}
DEBUG(5,("_samr_lookup_names: looking name on SID %s\n",
sid_string_dbg(&pol_sid)));
-
+
for (i = 0; i < num_rids; i++) {
fstring name;
int ret;
}
/*******************************************************************
- _samr_chgpasswd_user
+ _samr_ChangePasswordUser2
********************************************************************/
+NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p,
+ struct samr_ChangePasswordUser2 *r)
-NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u)
{
+ NTSTATUS status;
fstring user_name;
fstring wks;
- DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__));
-
- r_u->status = NT_STATUS_OK;
+ DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__));
- rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0);
- rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0);
+ fstrcpy(user_name, r->in.account->string);
+ fstrcpy(wks, r->in.server->string);
- DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks));
+ DEBUG(5,("_samr_ChangePasswordUser2: user: %s wks: %s\n", user_name, wks));
/*
* Pass the user through the NT -> unix user mapping
* function.
*/
-
+
(void)map_username(user_name);
-
+
/*
- * UNIX username case mangling not required, pass_oem_change
+ * UNIX username case mangling not required, pass_oem_change
* is case insensitive.
*/
- r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash,
- q_u->nt_newpass.pass, q_u->nt_oldhash.hash, NULL);
-
- init_samr_r_chgpasswd_user(r_u, r_u->status);
+ status = pass_oem_change(user_name, r->in.lm_password->data, r->in.lm_verifier->hash,
+ r->in.nt_password->data, r->in.nt_verifier->hash, NULL);
- DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__));
+ DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__));
- return r_u->status;
+ return status;
}
/*******************************************************************
* Pass the user through the NT -> unix user mapping
* function.
*/
-
+
(void)map_username(user_name);
-
+
/*
- * UNIX username case mangling not required, pass_oem_change
+ * UNIX username case mangling not required, pass_oem_change
* is case insensitive.
*/
r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash,
q_u->nt_newpass.pass, q_u->nt_oldhash.hash, &reject_reason);
- if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION) ||
+ if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION) ||
NT_STATUS_EQUAL(r_u->status, NT_STATUS_ACCOUNT_RESTRICTION)) {
uint32 min_pass_len,pass_hist,password_properties;
u_min_age = account_policy_temp;
/* !AS ROOT */
-
+
unbecome_root();
unix_to_nt_time_abs(&nt_expire, u_expire);
unix_to_nt_time_abs(&nt_min_age, u_min_age);
- init_unk_info1(info, (uint16)min_pass_len, (uint16)pass_hist,
+ init_unk_info1(info, (uint16)min_pass_len, (uint16)pass_hist,
password_properties, nt_expire, nt_min_age);
reject->reject_reason = reject_reason;
}
-
+
init_samr_r_chgpasswd_user3(r_u, r_u->status, reject, info);
DEBUG(5,("_samr_chgpasswd_user3: %d\n", __LINE__));
}
/*******************************************************************
- _samr_open_user. Safe - gives out no passwd info.
- ********************************************************************/
+ _samr_OpenUser
+********************************************************************/
-NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u)
+NTSTATUS _samr_OpenUser(pipes_struct *p,
+ struct samr_OpenUser *r)
{
struct samu *sampass=NULL;
DOM_SID sid;
- POLICY_HND domain_pol = q_u->domain_pol;
- POLICY_HND *user_pol = &r_u->user_pol;
+ POLICY_HND domain_pol = *r->in.domain_handle;
+ POLICY_HND *user_pol = r->out.user_handle;
struct samr_info *info = NULL;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
size_t sd_size;
bool ret;
NTSTATUS nt_status;
SE_PRIV se_rights;
- r_u->status = NT_STATUS_OK;
-
/* find the domain policy handle and get domain SID / access bits in the domain policy. */
-
+
if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) )
return NT_STATUS_INVALID_HANDLE;
-
- nt_status = access_check_samr_function( acc_granted,
- SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_user" );
-
+
+ nt_status = access_check_samr_function( acc_granted,
+ SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenUser" );
+
if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status;
}
/* append the user's RID to it */
-
- if (!sid_append_rid(&sid, q_u->user_rid))
+
+ if (!sid_append_rid(&sid, r->in.rid))
return NT_STATUS_NO_SUCH_USER;
-
+
/* check if access can be granted as requested by client. */
-
+
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW);
se_map_generic(&des_access, &usr_generic_mapping);
-
+
se_priv_copy( &se_rights, &se_machine_account );
se_priv_add( &se_rights, &se_add_users );
-
- nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access,
- &acc_granted, "_samr_open_user");
-
+
+ nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access,
+ &acc_granted, "_samr_OpenUser");
+
if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status;
if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return r_u->status;
+ return NT_STATUS_OK;
}
/*************************************************************************
if ( !(smbpass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
}
-
+
become_root();
ret = pdb_getsampwsid(smbpass, user_sid);
unbecome_root();
/*************************************************************************
get_user_info_18. OK - this is the killer as it gives out password info.
Ensure that this is only allowed on an encrypted connection with a root
- user. JRA.
+ user. JRA.
*************************************************************************/
static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_18 * id18, DOM_SID *user_sid)
ZERO_STRUCTP(id18);
init_sam_user_info18(id18, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass));
-
+
TALLOC_FREE(smbpass);
return NT_STATUS_OK;
ZERO_STRUCTP(id20);
init_sam_user_info20A(id20, sampass);
-
+
TALLOC_FREE(sampass);
return NT_STATUS_OK;
get_user_info_21
*************************************************************************/
-static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21,
+static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21,
DOM_SID *user_sid, DOM_SID *domain_sid)
{
struct samu *sampass=NULL;
ZERO_STRUCTP(id21);
nt_status = init_sam_user_info21A(id21, sampass, domain_sid);
-
+
TALLOC_FREE(sampass);
return nt_status;
struct samr_info *info = NULL;
DOM_SID domain_sid;
uint32 rid;
-
+
r_u->status=NT_STATUS_OK;
/* search for the handle */
if (!NT_STATUS_IS_OK(r_u->status = get_user_info_18(p, p->mem_ctx, ctr->info.id18, &info->sid)))
return r_u->status;
break;
-
+
case 20:
ctr->info.id20 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_20);
if (ctr->info.id20 == NULL)
ctr->info.id21 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_21);
if (ctr->info.id21 == NULL)
return NT_STATUS_NO_MEMORY;
- if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21,
+ if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21,
&info->sid, &domain_sid)))
return r_u->status;
break;
init_samr_r_query_userinfo(r_u, ctr, r_u->status);
DEBUG(5,("_samr_query_userinfo: %d\n", __LINE__));
-
+
return r_u->status;
}
/* find the policy handle. open a policy on it. */
if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_USER_GET_GROUPS, "_samr_query_usergroups"))) {
return r_u->status;
}
result = pdb_enum_group_memberships(p->mem_ctx, sam_pass,
&sids, &unix_gids, &num_groups);
if ( NT_STATUS_IS_OK(result) ) {
- success = sid_peek_check_rid(get_global_sam_sid(),
+ success = sid_peek_check_rid(get_global_sam_sid(),
pdb_get_group_sid(sam_pass),
&primary_group_rid);
}
ADD_TO_ARRAY(p->mem_ctx, DOM_GID, dom_gid, &gids, &num_gids);
}
-
+
/* construct the response. lkclXXXX: gids are not copied! */
init_samr_r_query_usergroups(r_u, num_gids, gids, r_u->status);
-
+
DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__));
-
+
return r_u->status;
}
/*******************************************************************
- _samr_query_domain_info
+ samr_QueryDomainInfo_internal
********************************************************************/
-NTSTATUS _samr_query_domain_info(pipes_struct *p,
- SAMR_Q_QUERY_DOMAIN_INFO *q_u,
- SAMR_R_QUERY_DOMAIN_INFO *r_u)
+static NTSTATUS samr_QueryDomainInfo_internal(const char *fn_name,
+ pipes_struct *p,
+ struct policy_handle *handle,
+ uint32_t level,
+ union samr_DomainInfo **dom_info_ptr)
{
+ NTSTATUS status = NT_STATUS_OK;
struct samr_info *info = NULL;
- SAM_UNK_CTR *ctr;
+ union samr_DomainInfo *dom_info;
uint32 min_pass_len,pass_hist,password_properties;
time_t u_expire, u_min_age;
NTTIME nt_expire, nt_min_age;
uint32 num_users=0, num_groups=0, num_aliases=0;
- if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) {
+ DEBUG(5,("%s: %d\n", fn_name, __LINE__));
+
+ dom_info = TALLOC_ZERO_P(p->mem_ctx, union samr_DomainInfo);
+ if (!dom_info) {
return NT_STATUS_NO_MEMORY;
}
- ZERO_STRUCTP(ctr);
+ *dom_info_ptr = dom_info;
- r_u->status = NT_STATUS_OK;
-
- DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__));
-
/* find the policy handle. open a policy on it. */
- if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) {
+ if (!find_policy_by_hnd(p, handle, (void **)(void *)&info)) {
return NT_STATUS_INVALID_HANDLE;
}
-
- switch (q_u->switch_value) {
+
+ switch (level) {
case 0x01:
-
+
become_root();
/* AS ROOT !!! */
u_min_age = account_policy_temp;
/* !AS ROOT */
-
+
unbecome_root();
unix_to_nt_time_abs(&nt_expire, u_expire);
unix_to_nt_time_abs(&nt_min_age, u_min_age);
- init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist,
- password_properties, nt_expire, nt_min_age);
+ init_samr_DomInfo1(&dom_info->info1,
+ (uint16)min_pass_len,
+ (uint16)pass_hist,
+ password_properties,
+ nt_expire,
+ nt_min_age);
break;
case 0x02:
seq_num = time(NULL);
/* !AS ROOT */
-
+
unbecome_root();
server_role = ROLE_DOMAIN_PDC;
if (lp_server_role() == ROLE_DOMAIN_BDC)
server_role = ROLE_DOMAIN_BDC;
- init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num,
- num_users, num_groups, num_aliases, nt_logout, server_role);
+ init_samr_DomInfo2(&dom_info->info2,
+ nt_logout,
+ lp_serverstring(),
+ lp_workgroup(),
+ global_myname(),
+ seq_num,
+ 1,
+ server_role,
+ 1,
+ num_users,
+ num_groups,
+ num_aliases);
break;
case 0x03:
}
/* !AS ROOT */
-
+
unbecome_root();
unix_to_nt_time_abs(&nt_logout, u_logout);
-
- init_unk_info3(&ctr->info.inf3, nt_logout);
+
+ init_samr_DomInfo3(&dom_info->info3,
+ nt_logout);
+
break;
case 0x04:
- init_unk_info4(&ctr->info.inf4, lp_serverstring());
+ init_samr_DomInfo4(&dom_info->info4,
+ lp_serverstring());
break;
case 0x05:
- init_unk_info5(&ctr->info.inf5, get_global_sam_name());
+ init_samr_DomInfo5(&dom_info->info5,
+ get_global_sam_name());
break;
case 0x06:
/* NT returns its own name when a PDC. win2k and later
* only the name of the PDC if itself is a BDC (samba4
* idl) */
- init_unk_info6(&ctr->info.inf6, global_myname());
+ init_samr_DomInfo6(&dom_info->info6,
+ global_myname());
break;
case 0x07:
server_role = ROLE_DOMAIN_PDC;
if (lp_server_role() == ROLE_DOMAIN_BDC)
server_role = ROLE_DOMAIN_BDC;
- init_unk_info7(&ctr->info.inf7, server_role);
+ init_samr_DomInfo7(&dom_info->info7,
+ server_role);
break;
case 0x08:
}
/* !AS ROOT */
-
+
unbecome_root();
- init_unk_info8(&ctr->info.inf8, (uint32) seq_num);
+ init_samr_DomInfo8(&dom_info->info8,
+ seq_num,
+ 0);
break;
case 0x0c:
lockout = account_policy_temp;
/* !AS ROOT */
-
+
unbecome_root();
unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration);
unix_to_nt_time_abs(&nt_reset_time, u_reset_time);
-
- init_unk_info12(&ctr->info.inf12, nt_lock_duration, nt_reset_time, (uint16)lockout);
+
+ init_samr_DomInfo12(&dom_info->info12,
+ nt_lock_duration,
+ nt_reset_time,
+ (uint16)lockout);
break;
default:
return NT_STATUS_INVALID_INFO_CLASS;
- }
-
+ }
- init_samr_r_query_domain_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK);
-
- DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__));
-
- return r_u->status;
+ DEBUG(5,("%s: %d\n", fn_name, __LINE__));
+
+ return status;
+}
+
+/*******************************************************************
+ _samr_QueryDomainInfo
+ ********************************************************************/
+
+NTSTATUS _samr_QueryDomainInfo(pipes_struct *p,
+ struct samr_QueryDomainInfo *r)
+{
+ return samr_QueryDomainInfo_internal("_samr_QueryDomainInfo",
+ p,
+ r->in.domain_handle,
+ r->in.level,
+ r->out.info);
}
/* W2k3 seems to use the same check for all 3 objects that can be created via
}
/*******************************************************************
- _samr_create_user
- Create an account, can be either a normal user or a machine.
- This funcion will need to be updated for bdc/domain trusts.
+ _samr_CreateUser2
********************************************************************/
-NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u,
- SAMR_R_CREATE_USER *r_u)
+NTSTATUS _samr_CreateUser2(pipes_struct *p,
+ struct samr_CreateUser2 *r)
{
- char *account;
+ const char *account = NULL;
DOM_SID sid;
- POLICY_HND dom_pol = q_u->domain_pol;
- uint16 acb_info = q_u->acb_info;
- POLICY_HND *user_pol = &r_u->user_pol;
+ POLICY_HND dom_pol = *r->in.domain_handle;
+ uint32_t acb_info = r->in.acct_flags;
+ POLICY_HND *user_pol = r->out.user_handle;
struct samr_info *info = NULL;
NTSTATUS nt_status;
uint32 acc_granted;
nt_status = access_check_samr_function(acc_granted,
SA_RIGHT_DOMAIN_CREATE_USER,
- "_samr_create_user");
+ "_samr_CreateUser2");
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
if (!(acb_info == ACB_NORMAL || acb_info == ACB_DOMTRUST ||
- acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) {
- /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if
+ acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) {
+ /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if
this parameter is not an account type */
return NT_STATUS_INVALID_PARAMETER;
}
- account = rpcstr_pull_unistr2_talloc(p->mem_ctx, &q_u->uni_name);
+ account = r->in.account_name->string;
if (account == NULL) {
return NT_STATUS_NO_MEMORY;
}
}
/* determine which user right we need to check based on the acb_info */
-
+
if ( acb_info & ACB_WSTRUST )
{
se_priv_copy( &se_rights, &se_machine_account );
can_add_account = user_has_privileges(
p->pipe_user.nt_user_token, &se_rights );
- }
- /* usrmgr.exe (and net rpc trustdom grant) creates a normal user
+ }
+ /* usrmgr.exe (and net rpc trustdom grant) creates a normal user
account for domain trusts and changes the ACB flags later */
else if ( acb_info & ACB_NORMAL &&
(account[strlen(account)-1] != '$') )
se_priv_copy( &se_rights, &se_add_users );
can_add_account = user_has_privileges(
p->pipe_user.nt_user_token, &se_rights );
- }
+ }
else /* implicit assumption of a BDC or domain trust account here
* (we already check the flags earlier) */
{
DOMAIN_GROUP_RID_ADMINS );
}
}
-
- DEBUG(5, ("_samr_create_user: %s can add this account : %s\n",
+
+ DEBUG(5, ("_samr_CreateUser2: %s can add this account : %s\n",
uidtoname(p->pipe_user.ut.uid),
can_add_account ? "True":"False" ));
-
+
/********** BEGIN Admin BLOCK **********/
if ( can_add_account )
become_root();
nt_status = pdb_create_user(p->mem_ctx, account, acb_info,
- &r_u->user_rid);
+ r->out.rid);
if ( can_add_account )
unbecome_root();
/********** END Admin BLOCK **********/
-
+
/* now check for failure */
-
+
if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status;
-
+
/* Get the user's SID */
- sid_compose(&sid, get_global_sam_sid(), r_u->user_rid);
-
+ sid_compose(&sid, get_global_sam_sid(), *r->out.rid);
+
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping,
&sid, SAMR_USR_RIGHTS_WRITE_PW);
se_map_generic(&des_access, &usr_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access,
- &acc_granted, "_samr_create_user");
-
+
+ nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access,
+ &acc_granted, "_samr_CreateUser2");
+
if ( !NT_STATUS_IS_OK(nt_status) ) {
return nt_status;
}
/* After a "set" ensure we have no cached display info. */
force_flush_samr_cache(info->disp_info);
- r_u->access_granted = acc_granted;
+ *r->out.access_granted = acc_granted;
return NT_STATUS_OK;
}
/*******************************************************************
- samr_reply_connect_anon
+ _samr_Connect
********************************************************************/
-NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u)
+NTSTATUS _samr_Connect(pipes_struct *p,
+ struct samr_Connect *r)
{
struct samr_info *info = NULL;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
/* Access check */
if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_connect_anon\n"));
- r_u->status = NT_STATUS_ACCESS_DENIED;
- return r_u->status;
+ DEBUG(3, ("access denied to _samr_Connect\n"));
+ return NT_STATUS_ACCESS_DENIED;
}
/* set up the SAMR connect_anon response */
- r_u->status = NT_STATUS_OK;
-
/* associate the user's SID with the new handle. */
if ((info = get_samr_info_by_sid(NULL)) == NULL)
return NT_STATUS_NO_MEMORY;
/* don't give away the farm but this is probably ok. The SA_RIGHT_SAM_ENUM_DOMAINS
- was observed from a win98 client trying to enumerate users (when configured
+ was observed from a win98 client trying to enumerate users (when configured
user level access control on shares) --jerry */
-
+
if (des_access == MAXIMUM_ALLOWED_ACCESS) {
/* Map to max possible knowing we're filtered below. */
des_access = GENERIC_ALL_ACCESS;
se_map_generic( &des_access, &sam_generic_mapping );
info->acc_granted = des_access & (SA_RIGHT_SAM_ENUM_DOMAINS|SA_RIGHT_SAM_OPEN_DOMAIN);
-
- info->status = q_u->unknown_0;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return r_u->status;
+ return NT_STATUS_OK;
}
/*******************************************************************
- samr_reply_connect
+ _samr_Connect2
********************************************************************/
-NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u)
+NTSTATUS _samr_Connect2(pipes_struct *p,
+ struct samr_Connect2 *r)
{
struct samr_info *info = NULL;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
NTSTATUS nt_status;
size_t sd_size;
- DEBUG(5,("_samr_connect: %d\n", __LINE__));
+ DEBUG(5,("_samr_Connect2: %d\n", __LINE__));
/* Access check */
if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_connect\n"));
- r_u->status = NT_STATUS_ACCESS_DENIED;
- return r_u->status;
+ DEBUG(3, ("access denied to _samr_Connect2\n"));
+ return NT_STATUS_ACCESS_DENIED;
}
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
se_map_generic(&des_access, &sam_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- NULL, 0, des_access, &acc_granted, "_samr_connect");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
- return nt_status;
- r_u->status = NT_STATUS_OK;
+ nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ NULL, 0, des_access, &acc_granted, "_samr_Connect2");
+
+ if ( !NT_STATUS_IS_OK(nt_status) )
+ return nt_status;
/* associate the user's SID and access granted with the new handle. */
if ((info = get_samr_info_by_sid(NULL)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
- info->status = q_u->access_mask;
+ info->status = r->in.access_mask; /* this looks so wrong... - gd */
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(5,("_samr_connect: %d\n", __LINE__));
+ DEBUG(5,("_samr_Connect2: %d\n", __LINE__));
- return r_u->status;
+ return nt_status;
}
/*******************************************************************
- samr_connect4
+ _samr_Connect4
********************************************************************/
-NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 *r_u)
+NTSTATUS _samr_Connect4(pipes_struct *p,
+ struct samr_Connect4 *r)
{
struct samr_info *info = NULL;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
NTSTATUS nt_status;
size_t sd_size;
- DEBUG(5,("_samr_connect4: %d\n", __LINE__));
+ DEBUG(5,("_samr_Connect4: %d\n", __LINE__));
/* Access check */
if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_connect4\n"));
- r_u->status = NT_STATUS_ACCESS_DENIED;
- return r_u->status;
+ DEBUG(3, ("access denied to samr_Connect4\n"));
+ return NT_STATUS_ACCESS_DENIED;
}
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
se_map_generic(&des_access, &sam_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- NULL, 0, des_access, &acc_granted, "_samr_connect4");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
- return nt_status;
- r_u->status = NT_STATUS_OK;
+ nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ NULL, 0, des_access, &acc_granted, "_samr_Connect4");
+
+ if ( !NT_STATUS_IS_OK(nt_status) )
+ return nt_status;
/* associate the user's SID and access granted with the new handle. */
if ((info = get_samr_info_by_sid(NULL)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
- info->status = q_u->access_mask;
+ info->status = r->in.access_mask; /* ??? */
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(5,("_samr_connect: %d\n", __LINE__));
+ DEBUG(5,("_samr_Connect4: %d\n", __LINE__));
- return r_u->status;
+ return NT_STATUS_OK;
}
/*******************************************************************
- samr_connect5
+ _samr_Connect5
********************************************************************/
-NTSTATUS _samr_connect5(pipes_struct *p, SAMR_Q_CONNECT5 *q_u, SAMR_R_CONNECT5 *r_u)
+NTSTATUS _samr_Connect5(pipes_struct *p,
+ struct samr_Connect5 *r)
{
struct samr_info *info = NULL;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
NTSTATUS nt_status;
- POLICY_HND pol;
size_t sd_size;
+ struct samr_ConnectInfo1 info1;
-
- DEBUG(5,("_samr_connect5: %d\n", __LINE__));
-
- ZERO_STRUCTP(r_u);
+ DEBUG(5,("_samr_Connect5: %d\n", __LINE__));
/* Access check */
if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_connect5\n"));
- r_u->status = NT_STATUS_ACCESS_DENIED;
- return r_u->status;
+ DEBUG(3, ("access denied to samr_Connect5\n"));
+ return NT_STATUS_ACCESS_DENIED;
}
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
se_map_generic(&des_access, &sam_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- NULL, 0, des_access, &acc_granted, "_samr_connect5");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
+
+ nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ NULL, 0, des_access, &acc_granted, "_samr_Connect5");
+
+ if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status;
/* associate the user's SID and access granted with the new handle. */
return NT_STATUS_NO_MEMORY;
info->acc_granted = acc_granted;
- info->status = q_u->access_mask;
+ info->status = r->in.access_mask; /* ??? */
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(5,("_samr_connect: %d\n", __LINE__));
+ DEBUG(5,("_samr_Connect5: %d\n", __LINE__));
- init_samr_r_connect5(r_u, &pol, NT_STATUS_OK);
+ info1.client_version = SAMR_CONNECT_AFTER_W2K;
+ info1.unknown2 = 0;
- return r_u->status;
+ *r->out.level_out = 1;
+ r->out.info_out->info1 = info1;
+
+ return NT_STATUS_OK;
}
/**********************************************************************
- api_samr_lookup_domain
+ _samr_LookupDomain
**********************************************************************/
-
-NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u)
+NTSTATUS _samr_LookupDomain(pipes_struct *p,
+ struct samr_LookupDomain *r)
{
+ NTSTATUS status = NT_STATUS_OK;
struct samr_info *info;
- fstring domain_name;
- DOM_SID sid;
+ const char *domain_name;
+ DOM_SID *sid = NULL;
- r_u->status = NT_STATUS_OK;
-
- if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)(void *)&info))
+ if (!find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info))
return NT_STATUS_INVALID_HANDLE;
- /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here.
+ /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here.
Reverted that change so we will work with RAS servers again */
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted,
- SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_lookup_domain")))
- {
- return r_u->status;
+ status = access_check_samr_function(info->acc_granted,
+ SA_RIGHT_SAM_OPEN_DOMAIN,
+ "_samr_LookupDomain");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- rpcstr_pull(domain_name, q_u->uni_domain.buffer, sizeof(domain_name), q_u->uni_domain.uni_str_len*2, 0);
+ domain_name = r->in.domain_name->string;
- ZERO_STRUCT(sid);
+ sid = TALLOC_ZERO_P(p->mem_ctx, struct dom_sid2);
+ if (!sid) {
+ return NT_STATUS_NO_MEMORY;
+ }
if (strequal(domain_name, builtin_domain_name())) {
- sid_copy(&sid, &global_sid_Builtin);
+ sid_copy(sid, &global_sid_Builtin);
} else {
- if (!secrets_fetch_domain_sid(domain_name, &sid)) {
- r_u->status = NT_STATUS_NO_SUCH_DOMAIN;
+ if (!secrets_fetch_domain_sid(domain_name, sid)) {
+ status = NT_STATUS_NO_SUCH_DOMAIN;
}
}
DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name,
- sid_string_dbg(&sid)));
+ sid_string_dbg(sid)));
- init_samr_r_lookup_domain(r_u, &sid, r_u->status);
+ *r->out.sid = sid;
- return r_u->status;
+ return status;
}
/******************************************************************
const char *name;
r_u->status = NT_STATUS_OK;
-
+
if (!find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info))
return NT_STATUS_INVALID_HANDLE;
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_enum_domains"))) {
return r_u->status;
}
}
/*******************************************************************
- api_samr_open_alias
+ _samr_OpenAlias
********************************************************************/
-NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u)
+NTSTATUS _samr_OpenAlias(pipes_struct *p,
+ struct samr_OpenAlias *r)
{
DOM_SID sid;
- POLICY_HND domain_pol = q_u->dom_pol;
- uint32 alias_rid = q_u->rid_alias;
- POLICY_HND *alias_pol = &r_u->pol;
+ POLICY_HND domain_pol = *r->in.domain_handle;
+ uint32 alias_rid = r->in.rid;
+ POLICY_HND *alias_pol = r->out.alias_handle;
struct samr_info *info = NULL;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
size_t sd_size;
NTSTATUS status;
SE_PRIV se_rights;
- r_u->status = NT_STATUS_OK;
-
/* find the domain policy and get the SID / access bits stored in the domain policy */
-
+
if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) )
return NT_STATUS_INVALID_HANDLE;
-
- status = access_check_samr_function(acc_granted,
- SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_alias");
-
- if ( !NT_STATUS_IS_OK(status) )
+
+ status = access_check_samr_function(acc_granted,
+ SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenAlias");
+
+ if ( !NT_STATUS_IS_OK(status) )
return status;
/* append the alias' RID to it */
-
+
if (!sid_append_rid(&sid, alias_rid))
return NT_STATUS_NO_SUCH_ALIAS;
-
+
/*check if access can be granted as requested by client. */
-
+
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &ali_generic_mapping, NULL, 0);
se_map_generic(&des_access,&ali_generic_mapping);
-
+
se_priv_copy( &se_rights, &se_add_users );
-
-
- status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- &se_rights, GENERIC_RIGHTS_ALIAS_WRITE, des_access,
- &acc_granted, "_samr_open_alias");
-
+
+
+ status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ &se_rights, GENERIC_RIGHTS_ALIAS_WRITE, des_access,
+ &acc_granted, "_samr_OpenAlias");
+
if ( !NT_STATUS_IS_OK(status) )
return status;
}
/* make sure there is a mapping */
-
+
if ( !sid_to_gid( &sid, &gid ) ) {
return NT_STATUS_NO_SUCH_ALIAS;
}
/* associate the alias SID with the new handle. */
if ((info = get_samr_info_by_sid(&sid)) == NULL)
return NT_STATUS_NO_MEMORY;
-
+
info->acc_granted = acc_granted;
/* get a (unique) handle. open a policy on it. */
if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return r_u->status;
+ return NT_STATUS_OK;
}
/*******************************************************************
}
/* check to see if the new username already exists. Note: we can't
- reliably lock all backends, so there is potentially the
+ reliably lock all backends, so there is potentially the
possibility that a user can be created in between this check and
the rename. The rename should fail, but may not get the
exact same failure status code. I think this is small enough
TALLOC_FREE(pwd);
return False;
}
-
+
/* FIX ME: check if the value is really changed --metze */
if (!pdb_set_acct_ctrl(pwd, id16->acb_info, PDB_CHANGED)) {
TALLOC_FREE(pwd);
TALLOC_FREE(pwd);
return False;
}
-
+
if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd, PDB_CHANGED)) {
TALLOC_FREE(pwd);
return False;
}
if (!pdb_set_pass_last_set_time (pwd, time(NULL), PDB_CHANGED)) {
TALLOC_FREE(pwd);
- return False;
+ return False;
}
-
+
if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
TALLOC_FREE(pwd);
return False;
DEBUG(5, ("set_user_info_20: NULL id20\n"));
return False;
}
-
+
copy_id20_to_sam_passwd(pwd, id20);
/* write the change out */
{
fstring new_name;
NTSTATUS status;
-
+
if (id21 == NULL) {
DEBUG(5, ("set_user_info_21: NULL id21\n"));
return NT_STATUS_INVALID_PARAMETER;
}
/* we need to separately check for an account rename first */
-
- if (rpcstr_pull(new_name, id21->uni_user_name.buffer,
- sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0)
- && (!strequal(new_name, pdb_get_username(pwd))))
+
+ if (rpcstr_pull(new_name, id21->uni_user_name.buffer,
+ sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0)
+ && (!strequal(new_name, pdb_get_username(pwd))))
{
/* check to see if the new username already exists. Note: we can't
- reliably lock all backends, so there is potentially the
+ reliably lock all backends, so there is potentially the
possibility that a user can be created in between this check and
the rename. The rename should fail, but may not get the
exact same failure status code. I think this is small enough
status = pdb_rename_sam_account(pwd, new_name);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("set_user_info_21: failed to rename account: %s\n",
+ DEBUG(0,("set_user_info_21: failed to rename account: %s\n",
nt_errstr(status)));
TALLOC_FREE(pwd);
return status;
}
- /* set the new username so that later
+ /* set the new username so that later
functions can work on the new account */
pdb_set_username(pwd, new_name, PDB_SET);
}
copy_id21_to_sam_passwd(pwd, id21);
-
+
/*
* The funny part about the previous two calls is
* that pwd still has the password hashes from the
* passdb entry. These have not been updated from
* id21. I don't know if they need to be set. --jerry
*/
-
+
if ( IS_SAM_CHANGED(pwd, PDB_GROUPSID) ) {
status = pdb_set_unix_primary_group(mem_ctx, pwd);
if ( !NT_STATUS_IS_OK(status) ) {
return status;
}
}
-
+
/* Don't worry about writing out the user account since the
- primary group SID is generated solely from the user's Unix
+ primary group SID is generated solely from the user's Unix
primary group. */
/* write the change out */
struct samu *pwd)
{
NTSTATUS status;
-
+
if (id25 == NULL) {
DEBUG(5, ("set_user_info_25: NULL id25\n"));
return NT_STATUS_INVALID_PARAMETER;
}
copy_id25_to_sam_passwd(pwd, id25);
-
+
/* write the change out */
if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) {
TALLOC_FREE(pwd);
return status;
}
}
-
+
/* WARNING: No TALLOC_FREE(pwd), we are about to set the password
* hereafter! */
if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
- /* This is tricky. A WinXP domain join sets
+ /* This is tricky. A WinXP domain join sets
(SA_RIGHT_USER_SET_PASSWORD|SA_RIGHT_USER_SET_ATTRIBUTES|SA_RIGHT_USER_ACCT_FLAGS_EXPIRY)
- The MMC lusrmgr plugin includes these perms and more in the SamrOpenUser(). But the
- standard Win32 API calls just ask for SA_RIGHT_USER_SET_PASSWORD in the SamrOpenUser().
- This should be enough for levels 18, 24, 25,& 26. Info level 23 can set more so
+ The MMC lusrmgr plugin includes these perms and more in the SamrOpenUser(). But the
+ standard Win32 API calls just ask for SA_RIGHT_USER_SET_PASSWORD in the SamrOpenUser().
+ This should be enough for levels 18, 24, 25,& 26. Info level 23 can set more so
we'll use the set from the WinXP join as the basis. */
-
+
switch (switch_value) {
case 18:
case 24:
acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY;
break;
}
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) {
return r_u->status;
}
DEBUG(5, ("_samr_set_userinfo: NULL info level\n"));
return NT_STATUS_INVALID_INFO_CLASS;
}
-
+
if ( !(pwd = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
-
+
become_root();
ret = pdb_getsampwsid(pwd, &sid);
unbecome_root();
-
+
if ( !ret ) {
TALLOC_FREE(pwd);
return NT_STATUS_NO_SUCH_USER;
}
-
+
/* deal with machine password changes differently from userinfo changes */
/* check to see if we have the sufficient rights */
-
+
acb_info = pdb_get_acct_ctrl(pwd);
- if ( acb_info & ACB_WSTRUST )
+ if ( acb_info & ACB_WSTRUST )
has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account);
else if ( acb_info & ACB_NORMAL )
has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users );
if ( lp_enable_privileges() )
has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS );
}
-
+
DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n",
uidtoname(p->pipe_user.ut.uid),
has_enough_rights ? "" : " not"));
/* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */
-
- if ( has_enough_rights )
- become_root();
-
+
+ if ( has_enough_rights )
+ become_root();
+
/* ok! user info levels (lots: see MSDEV help), off we go... */
switch (switch_value) {
}
done:
-
- if ( has_enough_rights )
+
+ if ( has_enough_rights )
unbecome_root();
-
+
/* ================ END SeMachineAccountPrivilege BLOCK ================ */
if (NT_STATUS_IS_OK(r_u->status)) {
if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
+
#if 0 /* this really should be applied on a per info level basis --jerry */
/* observed when joining XP client to Samba domain */
#else
acc_required = SA_RIGHT_USER_SET_ATTRIBUTES;
#endif
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) {
return r_u->status;
}
become_root();
ret = pdb_getsampwsid(pwd, &sid);
unbecome_root();
-
+
if ( !ret ) {
TALLOC_FREE(pwd);
return NT_STATUS_NO_SUCH_USER;
}
-
+
acb_info = pdb_get_acct_ctrl(pwd);
- if ( acb_info & ACB_WSTRUST )
+ if ( acb_info & ACB_WSTRUST )
has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account);
else if ( acb_info & ACB_NORMAL )
has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users );
if ( lp_enable_privileges() )
has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS );
}
-
+
DEBUG(5, ("_samr_set_userinfo2: %s does%s possess sufficient rights\n",
uidtoname(p->pipe_user.ut.uid),
has_enough_rights ? "" : " not"));
/* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */
-
- if ( has_enough_rights )
- become_root();
-
+
+ if ( has_enough_rights )
+ become_root();
+
/* ok! user info levels (lots: see MSDEV help), off we go... */
-
+
switch (switch_value) {
case 7:
r_u->status = set_user_info_7(p->mem_ctx,
r_u->status = NT_STATUS_INVALID_INFO_CLASS;
}
- if ( has_enough_rights )
+ if ( has_enough_rights )
unbecome_root();
-
+
/* ================ END SeMachineAccountPrivilege BLOCK ================ */
if (NT_STATUS_IS_OK(r_u->status)) {
}
/*********************************************************************
- _samr_query_aliasmem
+ _samr_GetAliasMembership
*********************************************************************/
-NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u)
+NTSTATUS _samr_GetAliasMembership(pipes_struct *p,
+ struct samr_GetAliasMembership *r)
{
size_t num_alias_rids;
uint32 *alias_rids;
struct samr_info *info = NULL;
size_t i;
-
+
NTSTATUS ntstatus1;
NTSTATUS ntstatus2;
DOM_SID *members;
- r_u->status = NT_STATUS_OK;
-
- DEBUG(5,("_samr_query_useraliases: %d\n", __LINE__));
+ DEBUG(5,("_samr_GetAliasMembership: %d\n", __LINE__));
/* find the policy handle. open a policy on it. */
- if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
+ if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info))
return NT_STATUS_INVALID_HANDLE;
-
- ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases");
- ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_query_useraliases");
-
+
+ ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_GetAliasMembership");
+ ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_GetAliasMembership");
+
if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) {
if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) &&
!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus1))) {
return (NT_STATUS_IS_OK(ntstatus1)) ? ntstatus2 : ntstatus1;
}
- }
+ }
if (!sid_check_is_domain(&info->sid) &&
!sid_check_is_builtin(&info->sid))
return NT_STATUS_OBJECT_TYPE_MISMATCH;
- if (q_u->num_sids1) {
- members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, q_u->num_sids1);
+ if (r->in.sids->num_sids) {
+ members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, r->in.sids->num_sids);
if (members == NULL)
return NT_STATUS_NO_MEMORY;
members = NULL;
}
- for (i=0; i<q_u->num_sids1; i++)
- sid_copy(&members[i], &q_u->sid[i].sid);
+ for (i=0; i<r->in.sids->num_sids; i++)
+ sid_copy(&members[i], r->in.sids->sids[i].sid);
alias_rids = NULL;
num_alias_rids = 0;
become_root();
ntstatus1 = pdb_enum_alias_memberships(p->mem_ctx, &info->sid, members,
- q_u->num_sids1,
+ r->in.sids->num_sids,
&alias_rids, &num_alias_rids);
unbecome_root();
return ntstatus1;
}
- init_samr_r_query_useraliases(r_u, num_alias_rids, alias_rids,
- NT_STATUS_OK);
+ r->out.rids->count = num_alias_rids;
+ r->out.rids->ids = alias_rids;
+
return NT_STATUS_OK;
}
/*********************************************************************
- _samr_query_aliasmem
+ _samr_GetMembersInAlias
*********************************************************************/
-NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u)
+NTSTATUS _samr_GetMembersInAlias(pipes_struct *p,
+ struct samr_GetMembersInAlias *r)
{
NTSTATUS status;
size_t i;
size_t num_sids = 0;
- DOM_SID2 *sid;
- DOM_SID *sids=NULL;
+ struct lsa_SidPtr *sids = NULL;
+ DOM_SID *pdb_sids = NULL;
DOM_SID alias_sid;
uint32 acc_granted;
/* find the policy handle. open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, NULL))
+ if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status =
- access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_query_aliasmem"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_GetMembersInAlias");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid)));
become_root();
- status = pdb_enum_aliasmem(&alias_sid, &sids, &num_sids);
+ status = pdb_enum_aliasmem(&alias_sid, &pdb_sids, &num_sids);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
}
if (num_sids) {
- sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_sids);
- if (sid == NULL) {
- SAFE_FREE(sids);
+ sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr, num_sids);
+ if (sids == NULL) {
+ TALLOC_FREE(pdb_sids);
return NT_STATUS_NO_MEMORY;
}
- } else {
- sid = NULL;
}
for (i = 0; i < num_sids; i++) {
- init_dom_sid2(&sid[i], &sids[i]);
+ sids[i].sid = sid_dup_talloc(p->mem_ctx, &pdb_sids[i]);
+ if (!sids[i].sid) {
+ TALLOC_FREE(pdb_sids);
+ return NT_STATUS_NO_MEMORY;
+ }
}
- init_samr_r_query_aliasmem(r_u, num_sids, sid, NT_STATUS_OK);
+ r->out.sids->num_sids = num_sids;
+ r->out.sids->sids = sids;
- TALLOC_FREE(sids);
+ TALLOC_FREE(pdb_sids);
return NT_STATUS_OK;
}
/*********************************************************************
- _samr_query_groupmem
+ _samr_QueryGroupMember
*********************************************************************/
-NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u)
+NTSTATUS _samr_QueryGroupMember(pipes_struct *p,
+ struct samr_QueryGroupMember *r)
{
DOM_SID group_sid;
size_t i, num_members;
uint32 acc_granted;
- NTSTATUS result;
+ NTSTATUS status;
+ struct samr_RidTypeArray *rids = NULL;
+
+ rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidTypeArray);
+ if (!rids) {
+ return NT_STATUS_NO_MEMORY;
+ }
/* find the policy handle. open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted, NULL))
+ if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_query_groupmem"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_QueryGroupMember");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
+
DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid)));
if (!sid_check_is_in_our_domain(&group_sid)) {
DEBUG(10, ("lookup on Domain SID\n"));
become_root();
- result = pdb_enum_group_members(p->mem_ctx, &group_sid,
+ status = pdb_enum_group_members(p->mem_ctx, &group_sid,
&rid, &num_members);
unbecome_root();
- if (!NT_STATUS_IS_OK(result))
- return result;
+ if (!NT_STATUS_IS_OK(status))
+ return status;
if (num_members) {
attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members);
} else {
attr = NULL;
}
-
+
for (i=0; i<num_members; i++)
attr[i] = SID_NAME_USER;
- init_samr_r_query_groupmem(r_u, num_members, rid, attr, NT_STATUS_OK);
+ rids->count = num_members;
+ rids->types = attr;
+ rids->rids = rid;
+
+ *r->out.rids = rids;
return NT_STATUS_OK;
}
/*********************************************************************
- _samr_add_aliasmem
+ _samr_AddAliasMember
*********************************************************************/
-NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ALIASMEM *r_u)
+NTSTATUS _samr_AddAliasMember(pipes_struct *p,
+ struct samr_AddAliasMember *r)
{
DOM_SID alias_sid;
uint32 acc_granted;
SE_PRIV se_rights;
bool can_add_accounts;
- NTSTATUS ret;
+ NTSTATUS status;
DISP_INFO *disp_info = NULL;
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_add_aliasmem"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_AddAliasMember");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
+
DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid)));
-
+
se_priv_copy( &se_rights, &se_add_users );
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
-
- ret = pdb_add_aliasmem(&alias_sid, &q_u->sid.sid);
-
+
+ status = pdb_add_aliasmem(&alias_sid, r->in.sid);
+
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
- if (NT_STATUS_IS_OK(ret)) {
+
+ if (NT_STATUS_IS_OK(status)) {
force_flush_samr_cache(disp_info);
}
- return ret;
+ return status;
}
/*********************************************************************
- _samr_del_aliasmem
+ _samr_DeleteAliasMember
*********************************************************************/
-NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u)
+NTSTATUS _samr_DeleteAliasMember(pipes_struct *p,
+ struct samr_DeleteAliasMember *r)
{
DOM_SID alias_sid;
uint32 acc_granted;
SE_PRIV se_rights;
bool can_add_accounts;
- NTSTATUS ret;
+ NTSTATUS status;
DISP_INFO *disp_info = NULL;
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_del_aliasmem"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_DeleteAliasMember");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
+
DEBUG(10, ("_samr_del_aliasmem:sid is %s\n",
sid_string_dbg(&alias_sid)));
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
- ret = pdb_del_aliasmem(&alias_sid, &q_u->sid.sid);
-
+ status = pdb_del_aliasmem(&alias_sid, r->in.sid);
+
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
- if (NT_STATUS_IS_OK(ret)) {
+
+ if (NT_STATUS_IS_OK(status)) {
force_flush_samr_cache(disp_info);
}
- return ret;
+ return status;
}
/*********************************************************************
- _samr_add_groupmem
+ _samr_AddGroupMember
*********************************************************************/
-NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u)
+NTSTATUS _samr_AddGroupMember(pipes_struct *p,
+ struct samr_AddGroupMember *r)
{
+ NTSTATUS status;
DOM_SID group_sid;
uint32 group_rid;
uint32 acc_granted;
DISP_INFO *disp_info = NULL;
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_add_groupmem"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_AddGroupMember");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid)));
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
- r_u->status = pdb_add_groupmem(p->mem_ctx, group_rid, q_u->rid);
-
+ status = pdb_add_groupmem(p->mem_ctx, group_rid, r->in.rid);
+
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
+
force_flush_samr_cache(disp_info);
- return r_u->status;
+ return status;
}
/*********************************************************************
- _samr_del_groupmem
+ _samr_DeleteGroupMember
*********************************************************************/
-NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u)
+NTSTATUS _samr_DeleteGroupMember(pipes_struct *p,
+ struct samr_DeleteGroupMember *r)
+
{
+ NTSTATUS status;
DOM_SID group_sid;
uint32 group_rid;
uint32 acc_granted;
DISP_INFO *disp_info = NULL;
/*
- * delete the group member named q_u->rid
+ * delete the group member named r->in.rid
* who is a member of the sid associated with the handle
* the rid is a user's rid as the group is a domain group.
*/
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_del_groupmem"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_DeleteGroupMember");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid,
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
-
- r_u->status = pdb_del_groupmem(p->mem_ctx, group_rid, q_u->rid);
+
+ status = pdb_del_groupmem(p->mem_ctx, group_rid, r->in.rid);
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
+
force_flush_samr_cache(disp_info);
- return r_u->status;
+ return status;
}
/*********************************************************************
- _samr_delete_dom_user
+ _samr_DeleteUser
*********************************************************************/
-NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u )
+NTSTATUS _samr_DeleteUser(pipes_struct *p,
+ struct samr_DeleteUser *r)
{
+ NTSTATUS status;
DOM_SID user_sid;
struct samu *sam_pass=NULL;
uint32 acc_granted;
DISP_INFO *disp_info = NULL;
bool ret;
- DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__));
+ DEBUG(5, ("_samr_DeleteUser: %d\n", __LINE__));
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &user_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_user"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteUser");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
+
if (!sid_check_is_in_our_domain(&user_sid))
return NT_STATUS_CANNOT_DELETE;
unbecome_root();
if( !ret ) {
- DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n",
+ DEBUG(5,("_samr_DeleteUser: User %s doesn't exist.\n",
sid_string_dbg(&user_sid)));
TALLOC_FREE(sam_pass);
return NT_STATUS_NO_SUCH_USER;
}
-
+
acb_info = pdb_get_acct_ctrl(sam_pass);
/* For machine accounts it's the SeMachineAccountPrivilege that counts. */
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account );
} else {
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users );
- }
+ }
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
- r_u->status = pdb_delete_user(p->mem_ctx, sam_pass);
+ status = pdb_delete_user(p->mem_ctx, sam_pass);
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
- if ( !NT_STATUS_IS_OK(r_u->status) ) {
- DEBUG(5,("_samr_delete_dom_user: Failed to delete entry for "
+
+ if ( !NT_STATUS_IS_OK(status) ) {
+ DEBUG(5,("_samr_DeleteUser: Failed to delete entry for "
"user %s: %s.\n", pdb_get_username(sam_pass),
- nt_errstr(r_u->status)));
+ nt_errstr(status)));
TALLOC_FREE(sam_pass);
- return r_u->status;
+ return status;
}
TALLOC_FREE(sam_pass);
- if (!close_policy_hnd(p, &q_u->user_pol))
+ if (!close_policy_hnd(p, r->in.user_handle))
return NT_STATUS_OBJECT_NAME_INVALID;
force_flush_samr_cache(disp_info);
}
/*********************************************************************
- _samr_delete_dom_group
+ _samr_DeleteDomainGroup
*********************************************************************/
-NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u)
+NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p,
+ struct samr_DeleteDomainGroup *r)
{
+ NTSTATUS status;
DOM_SID group_sid;
uint32 group_rid;
uint32 acc_granted;
bool can_add_accounts;
DISP_INFO *disp_info = NULL;
- DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__));
+ DEBUG(5, ("samr_DeleteDomainGroup: %d\n", __LINE__));
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_group"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomainGroup");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid)));
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
- r_u->status = pdb_delete_dom_group(p->mem_ctx, group_rid);
+ status = pdb_delete_dom_group(p->mem_ctx, group_rid);
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
- if ( !NT_STATUS_IS_OK(r_u->status) ) {
- DEBUG(5,("_samr_delete_dom_group: Failed to delete mapping "
+
+ if ( !NT_STATUS_IS_OK(status) ) {
+ DEBUG(5,("_samr_DeleteDomainGroup: Failed to delete mapping "
"entry for group %s: %s\n",
sid_string_dbg(&group_sid),
- nt_errstr(r_u->status)));
- return r_u->status;
+ nt_errstr(status)));
+ return status;
}
-
- if (!close_policy_hnd(p, &q_u->group_pol))
+
+ if (!close_policy_hnd(p, r->in.group_handle))
return NT_STATUS_OBJECT_NAME_INVALID;
force_flush_samr_cache(disp_info);
}
/*********************************************************************
- _samr_delete_dom_alias
+ _samr_DeleteDomAlias
*********************************************************************/
-NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u)
+NTSTATUS _samr_DeleteDomAlias(pipes_struct *p,
+ struct samr_DeleteDomAlias *r)
{
DOM_SID alias_sid;
uint32 acc_granted;
NTSTATUS status;
DISP_INFO *disp_info = NULL;
- DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__));
+ DEBUG(5, ("_samr_DeleteDomAlias: %d\n", __LINE__));
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
+
/* copy the handle to the outgoing reply */
- memcpy( &r_u->pol, &q_u->alias_pol, sizeof(r_u->pol) );
+ memcpy(r->out.alias_handle, r->in.alias_handle, sizeof(r->out.alias_handle));
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) {
- return r_u->status;
+ status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomAlias");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid)));
if (!sid_check_is_in_our_domain(&alias_sid))
return NT_STATUS_NO_SUCH_ALIAS;
-
+
DEBUG(10, ("lookup on Local SID\n"));
se_priv_copy( &se_rights, &se_add_users );
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
/* Have passdb delete the alias */
status = pdb_delete_alias(&alias_sid);
-
+
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
if ( !NT_STATUS_IS_OK(status))
return status;
- if (!close_policy_hnd(p, &q_u->alias_pol))
+ if (!close_policy_hnd(p, r->in.alias_handle))
return NT_STATUS_OBJECT_NAME_INVALID;
force_flush_samr_cache(disp_info);
}
/*********************************************************************
- _samr_create_dom_group
+ _samr_CreateDomainGroup
*********************************************************************/
-NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u)
+NTSTATUS _samr_CreateDomainGroup(pipes_struct *p,
+ struct samr_CreateDomainGroup *r)
+
{
+ NTSTATUS status;
DOM_SID dom_sid;
DOM_SID info_sid;
const char *name;
DISP_INFO *disp_info = NULL;
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_create_dom_group"))) {
- return r_u->status;
+
+ status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_CreateDomainGroup");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
+
if (!sid_equal(&dom_sid, get_global_sam_sid()))
return NT_STATUS_ACCESS_DENIED;
- name = rpcstr_pull_unistr2_talloc(p->mem_ctx, &q_u->uni_acct_desc);
+ name = r->in.name->string;
if (name == NULL) {
return NT_STATUS_NO_MEMORY;
}
- r_u->status = can_create(p->mem_ctx, name);
- if (!NT_STATUS_IS_OK(r_u->status)) {
- return r_u->status;
+ status = can_create(p->mem_ctx, name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
se_priv_copy( &se_rights, &se_add_users );
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
-
+
/* check that we successfully create the UNIX group */
-
- r_u->status = pdb_create_dom_group(p->mem_ctx, name, &r_u->rid);
+
+ status = pdb_create_dom_group(p->mem_ctx, name, r->out.rid);
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
-
+
/* check if we should bail out here */
-
- if ( !NT_STATUS_IS_OK(r_u->status) )
- return r_u->status;
- sid_compose(&info_sid, get_global_sam_sid(), r_u->rid);
-
+ if ( !NT_STATUS_IS_OK(status) )
+ return status;
+
+ sid_compose(&info_sid, get_global_sam_sid(), *r->out.rid);
+
if ((info = get_samr_info_by_sid(&info_sid)) == NULL)
return NT_STATUS_NO_MEMORY;
info->acc_granted = GENERIC_RIGHTS_GROUP_ALL_ACCESS;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.group_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
force_flush_samr_cache(disp_info);
}
/*********************************************************************
- _samr_create_dom_alias
+ _samr_CreateDomAlias
*********************************************************************/
-NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u)
+NTSTATUS _samr_CreateDomAlias(pipes_struct *p,
+ struct samr_CreateDomAlias *r)
{
DOM_SID dom_sid;
DOM_SID info_sid;
- fstring name;
+ const char *name = NULL;
struct samr_info *info;
uint32 acc_granted;
gid_t gid;
DISP_INFO *disp_info = NULL;
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_create_alias"))) {
- return r_u->status;
+
+ result = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_CreateDomAlias");
+ if (!NT_STATUS_IS_OK(result)) {
+ return result;
}
-
+
if (!sid_equal(&dom_sid, get_global_sam_sid()))
return NT_STATUS_ACCESS_DENIED;
- unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name));
+ name = r->in.alias_name->string;
se_priv_copy( &se_rights, &se_add_users );
can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights );
}
/******** BEGIN SeAddUsers BLOCK *********/
-
+
if ( can_add_accounts )
become_root();
/* Have passdb create the alias */
- result = pdb_create_alias(name, &r_u->rid);
+ result = pdb_create_alias(name, r->out.rid);
if ( can_add_accounts )
unbecome_root();
-
+
/******** END SeAddUsers BLOCK *********/
if (!NT_STATUS_IS_OK(result)) {
}
sid_copy(&info_sid, get_global_sam_sid());
- sid_append_rid(&info_sid, r_u->rid);
+ sid_append_rid(&info_sid, *r->out.rid);
if (!sid_to_gid(&info_sid, &gid)) {
DEBUG(10, ("Could not find alias just created\n"));
info->acc_granted = GENERIC_RIGHTS_ALIAS_ALL_ACCESS;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.alias_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
force_flush_samr_cache(disp_info);
uint32 acc_granted;
bool ret;
- if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL))
+ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) {
return r_u->status;
}
-
+
become_root();
ret = get_domain_group_from_sid(group_sid, &map);
unbecome_root();
r_u->status = pdb_enum_group_members(
p->mem_ctx, &group_sid, &members, &num_members);
unbecome_root();
-
+
if (!NT_STATUS_IS_OK(r_u->status)) {
return r_u->status;
}
r_u->status = pdb_enum_group_members(
p->mem_ctx, &group_sid, &members, &num_members);
unbecome_root();
-
+
if (!NT_STATUS_IS_OK(r_u->status)) {
return r_u->status;
}
/*********************************************************************
_samr_set_groupinfo
-
+
update a domain group's comment.
*********************************************************************/
if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) {
return r_u->status;
}
unbecome_root();
if (!result)
return NT_STATUS_NO_SUCH_GROUP;
-
+
ctr=q_u->ctr;
switch (ctr->switch_value1) {
if ( can_mod_accounts )
become_root();
-
+
ret = pdb_update_group_mapping_entry(&map);
if ( can_mod_accounts )
/*********************************************************************
_samr_set_aliasinfo
-
+
update an alias's comment.
*********************************************************************/
if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
+
if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_SET_INFO, "_samr_set_aliasinfo"))) {
return r_u->status;
}
-
+
ctr=&q_u->ctr;
/* get the current group information */
fstring group_name, acct_name;
/* We currently do not support renaming groups in the
- the BUILTIN domain. Refer to util_builtin.c to understand
+ the BUILTIN domain. Refer to util_builtin.c to understand
why. The eventually needs to be fixed to be like Windows
where you can rename builtin groups, just not delete them */
/* There has to be a valid name (and it has to be different) */
- if ( !ctr->alias.info2.name.string )
+ if ( !ctr->alias.info2.name.string )
return NT_STATUS_INVALID_PARAMETER;
- unistr2_to_ascii( acct_name, ctr->alias.info2.name.string,
+ unistr2_to_ascii( acct_name, ctr->alias.info2.name.string,
sizeof(acct_name));
/* If the name is the same just reply "ok". Yes this
fstrcpy( info.acct_name, acct_name );
- /* make sure the name doesn't already exist as a user
+ /* make sure the name doesn't already exist as a user
or local group */
fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name );
status = can_create( p->mem_ctx, group_name );
- if ( !NT_STATUS_IS_OK( status ) )
+ if ( !NT_STATUS_IS_OK( status ) )
return status;
break;
}
case 3:
if ( ctr->alias.info3.description.string ) {
- unistr2_to_ascii( info.acct_desc,
- ctr->alias.info3.description.string,
+ unistr2_to_ascii( info.acct_desc,
+ ctr->alias.info3.description.string,
sizeof(info.acct_desc));
}
else
}
/*********************************************************************
- _samr_open_group
+ _samr_OpenGroup
*********************************************************************/
-NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u)
+NTSTATUS _samr_OpenGroup(pipes_struct *p,
+ struct samr_OpenGroup *r)
+
{
DOM_SID sid;
DOM_SID info_sid;
struct samr_info *info;
SEC_DESC *psd = NULL;
uint32 acc_granted;
- uint32 des_access = q_u->access_mask;
+ uint32 des_access = r->in.access_mask;
size_t sd_size;
NTSTATUS status;
fstring sid_string;
bool ret;
SE_PRIV se_rights;
- if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted, NULL))
+ if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &sid, &acc_granted, NULL))
return NT_STATUS_INVALID_HANDLE;
-
- status = access_check_samr_function(acc_granted,
- SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_group");
-
+
+ status = access_check_samr_function(acc_granted,
+ SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenGroup");
+
if ( !NT_STATUS_IS_OK(status) )
return status;
-
+
/*check if access can be granted as requested by client. */
make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &grp_generic_mapping, NULL, 0);
se_map_generic(&des_access,&grp_generic_mapping);
se_priv_copy( &se_rights, &se_add_users );
- status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
- &se_rights, GENERIC_RIGHTS_GROUP_WRITE, des_access,
- &acc_granted, "_samr_open_group");
-
- if ( !NT_STATUS_IS_OK(status) )
+ status = access_check_samr_object(psd, p->pipe_user.nt_user_token,
+ &se_rights, GENERIC_RIGHTS_GROUP_WRITE, des_access,
+ &acc_granted, "_samr_OpenGroup");
+
+ if ( !NT_STATUS_IS_OK(status) )
return status;
/* this should not be hard-coded like this */
-
+
if (!sid_equal(&sid, get_global_sam_sid()))
return NT_STATUS_ACCESS_DENIED;
sid_copy(&info_sid, get_global_sam_sid());
- sid_append_rid(&info_sid, q_u->rid_group);
+ sid_append_rid(&info_sid, r->in.rid);
sid_to_fstring(sid_string, &info_sid);
if ((info = get_samr_info_by_sid(&info_sid)) == NULL)
return NT_STATUS_NO_MEMORY;
-
+
info->acc_granted = acc_granted;
- DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string));
+ DEBUG(10, ("_samr_OpenGroup:Opening SID: %s\n", sid_string));
/* check if that group really exists */
become_root();
return NT_STATUS_NO_SUCH_GROUP;
/* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info))
+ if (!create_policy_hnd(p, r->out.group_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return NT_STATUS_OK;
}
/*********************************************************************
- _samr_remove_sid_foreign_domain
+ _samr_RemoveMemberFromForeignDomain
*********************************************************************/
-NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p,
- SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN *q_u,
- SAMR_R_REMOVE_SID_FOREIGN_DOMAIN *r_u)
+NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p,
+ struct samr_RemoveMemberFromForeignDomain *r)
{
DOM_SID delete_sid, domain_sid;
uint32 acc_granted;
NTSTATUS result;
DISP_INFO *disp_info = NULL;
- sid_copy( &delete_sid, &q_u->sid.sid );
+ sid_copy( &delete_sid, r->in.sid );
- DEBUG(5,("_samr_remove_sid_foreign_domain: removing SID [%s]\n",
+ DEBUG(5,("_samr_RemoveMemberFromForeignDomain: removing SID [%s]\n",
sid_string_dbg(&delete_sid)));
/* Find the policy handle. Open a policy on it. */
- if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &domain_sid,
- &acc_granted, &disp_info))
+ if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &domain_sid,
+ &acc_granted, &disp_info))
return NT_STATUS_INVALID_HANDLE;
-
- result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS,
- "_samr_remove_sid_foreign_domain");
-
- if (!NT_STATUS_IS_OK(result))
+
+ result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS,
+ "_samr_RemoveMemberFromForeignDomain");
+
+ if (!NT_STATUS_IS_OK(result))
return result;
-
- DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n",
+
+ DEBUG(8, ("_samr_RemoveMemberFromForeignDomain: sid is %s\n",
sid_string_dbg(&domain_sid)));
- /* we can only delete a user from a group since we don't have
+ /* we can only delete a user from a group since we don't have
nested groups anyways. So in the latter case, just say OK */
/* TODO: The above comment nowadays is bogus. Since we have nested
* other cases. */
if (!sid_check_is_builtin(&domain_sid)) {
- DEBUG(1,("_samr_remove_sid_foreign_domain: domain_sid = %s, "
+ DEBUG(1,("_samr_RemoveMemberFromForeignDomain: domain_sid = %s, "
"global_sam_sid() = %s\n",
sid_string_dbg(&domain_sid),
sid_string_dbg(get_global_sam_sid())));
}
/*******************************************************************
- _samr_query_domain_info2
+ _samr_QueryDomainInfo2
********************************************************************/
-NTSTATUS _samr_query_domain_info2(pipes_struct *p,
- SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
- SAMR_R_QUERY_DOMAIN_INFO2 *r_u)
+NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p,
+ struct samr_QueryDomainInfo2 *r)
{
- SAMR_Q_QUERY_DOMAIN_INFO q;
- SAMR_R_QUERY_DOMAIN_INFO r;
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__));
-
- q.domain_pol = q_u->domain_pol;
- q.switch_value = q_u->switch_value;
-
- r_u->status = _samr_query_domain_info(p, &q, &r);
-
- r_u->ptr_0 = r.ptr_0;
- r_u->switch_value = r.switch_value;
- r_u->ctr = r.ctr;
-
- return r_u->status;
+ return samr_QueryDomainInfo_internal("_samr_QueryDomainInfo2",
+ p,
+ r->in.domain_handle,
+ r->in.level,
+ r->out.info);
}
/*******************************************************************
- _samr_set_dom_info
+ _samr_SetDomainInfo
********************************************************************/
-NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R_SET_DOMAIN_INFO *r_u)
+NTSTATUS _samr_SetDomainInfo(pipes_struct *p,
+ struct samr_SetDomainInfo *r)
{
time_t u_expire, u_min_age;
time_t u_logout;
time_t u_lock_duration, u_reset_time;
- r_u->status = NT_STATUS_OK;
-
- DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__));
+ DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__));
/* find the policy handle. open a policy on it. */
- if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL))
+ if (!find_policy_by_hnd(p, r->in.domain_handle, NULL))
return NT_STATUS_INVALID_HANDLE;
- DEBUG(5,("_samr_set_dom_info: switch_value: %d\n", q_u->switch_value));
+ DEBUG(5,("_samr_SetDomainInfo: level: %d\n", r->in.level));
- switch (q_u->switch_value) {
+ switch (r->in.level) {
case 0x01:
- u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire);
- u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage);
-
- pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password);
- pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history);
- pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.password_properties);
+ u_expire=nt_time_to_unix_abs((NTTIME *)&r->in.info->info1.max_password_age);
+ u_min_age=nt_time_to_unix_abs((NTTIME *)&r->in.info->info1.min_password_age);
+ pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)r->in.info->info1.min_password_length);
+ pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)r->in.info->info1.password_history_length);
+ pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)r->in.info->info1.password_properties);
pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire);
pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age);
break;
case 0x02:
break;
case 0x03:
- u_logout=nt_time_to_unix_abs(&q_u->ctr->info.inf3.logout);
+ u_logout=nt_time_to_unix_abs((NTTIME *)&r->in.info->info3.force_logoff_time);
pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout);
break;
case 0x05:
case 0x07:
break;
case 0x0c:
- u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration);
+ u_lock_duration=nt_time_to_unix_abs((NTTIME *)&r->in.info->info12.lockout_duration);
if (u_lock_duration != -1)
u_lock_duration /= 60;
- u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60;
-
+ u_reset_time=nt_time_to_unix_abs((NTTIME *)&r->in.info->info12.lockout_window)/60;
+
pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration);
pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time);
- pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout);
+ pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)r->in.info->info12.lockout_threshold);
break;
default:
return NT_STATUS_INVALID_INFO_CLASS;
}
- init_samr_r_set_domain_info(r_u, NT_STATUS_OK);
-
- DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__));
+ DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__));
- return r_u->status;
+ return NT_STATUS_OK;
}
/****************************************************************
****************************************************************/
-NTSTATUS _samr_Connect(pipes_struct *p,
- struct samr_Connect *r)
+NTSTATUS _samr_Shutdown(pipes_struct *p,
+ struct samr_Shutdown *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_SetSecurity(pipes_struct *p,
- struct samr_SetSecurity *r)
+NTSTATUS _samr_EnumDomains(pipes_struct *p,
+ struct samr_EnumDomains *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_QuerySecurity(pipes_struct *p,
- struct samr_QuerySecurity *r)
+NTSTATUS _samr_EnumDomainGroups(pipes_struct *p,
+ struct samr_EnumDomainGroups *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_Shutdown(pipes_struct *p,
- struct samr_Shutdown *r)
+NTSTATUS _samr_CreateUser(pipes_struct *p,
+ struct samr_CreateUser *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_LookupDomain(pipes_struct *p,
- struct samr_LookupDomain *r)
+NTSTATUS _samr_EnumDomainUsers(pipes_struct *p,
+ struct samr_EnumDomainUsers *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_EnumDomains(pipes_struct *p,
- struct samr_EnumDomains *r)
+NTSTATUS _samr_EnumDomainAliases(pipes_struct *p,
+ struct samr_EnumDomainAliases *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_OpenDomain(pipes_struct *p,
- struct samr_OpenDomain *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_QueryDomainInfo(pipes_struct *p,
- struct samr_QueryDomainInfo *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_SetDomainInfo(pipes_struct *p,
- struct samr_SetDomainInfo *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_CreateDomainGroup(pipes_struct *p,
- struct samr_CreateDomainGroup *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_EnumDomainGroups(pipes_struct *p,
- struct samr_EnumDomainGroups *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_CreateUser(pipes_struct *p,
- struct samr_CreateUser *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_EnumDomainUsers(pipes_struct *p,
- struct samr_EnumDomainUsers *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_CreateDomAlias(pipes_struct *p,
- struct samr_CreateDomAlias *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_EnumDomainAliases(pipes_struct *p,
- struct samr_EnumDomainAliases *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_GetAliasMembership(pipes_struct *p,
- struct samr_GetAliasMembership *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_LookupNames(pipes_struct *p,
- struct samr_LookupNames *r)
+NTSTATUS _samr_LookupNames(pipes_struct *p,
+ struct samr_LookupNames *r)
{
p->rng_fault_state = true;
return NT_STATUS_NOT_IMPLEMENTED;
/****************************************************************
****************************************************************/
-NTSTATUS _samr_OpenGroup(pipes_struct *p,
- struct samr_OpenGroup *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_QueryGroupInfo(pipes_struct *p,
struct samr_QueryGroupInfo *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_AddGroupMember(pipes_struct *p,
- struct samr_AddGroupMember *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p,
- struct samr_DeleteDomainGroup *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_DeleteGroupMember(pipes_struct *p,
- struct samr_DeleteGroupMember *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_QueryGroupMember(pipes_struct *p,
- struct samr_QueryGroupMember *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p,
struct samr_SetMemberAttributesOfGroup *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_OpenAlias(pipes_struct *p,
- struct samr_OpenAlias *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_QueryAliasInfo(pipes_struct *p,
struct samr_QueryAliasInfo *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_DeleteDomAlias(pipes_struct *p,
- struct samr_DeleteDomAlias *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_AddAliasMember(pipes_struct *p,
- struct samr_AddAliasMember *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_DeleteAliasMember(pipes_struct *p,
- struct samr_DeleteAliasMember *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_GetMembersInAlias(pipes_struct *p,
- struct samr_GetMembersInAlias *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_OpenUser(pipes_struct *p,
- struct samr_OpenUser *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_DeleteUser(pipes_struct *p,
- struct samr_DeleteUser *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_QueryUserInfo(pipes_struct *p,
struct samr_QueryUserInfo *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_GetUserPwInfo(pipes_struct *p,
- struct samr_GetUserPwInfo *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p,
- struct samr_RemoveMemberFromForeignDomain *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p,
- struct samr_QueryDomainInfo2 *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_QueryUserInfo2(pipes_struct *p,
struct samr_QueryUserInfo2 *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_CreateUser2(pipes_struct *p,
- struct samr_CreateUser2 *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_QueryDisplayInfo3(pipes_struct *p,
struct samr_QueryDisplayInfo3 *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p,
- struct samr_ChangePasswordUser2 *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-NTSTATUS _samr_Connect2(pipes_struct *p,
- struct samr_Connect2 *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_SetUserInfo2(pipes_struct *p,
struct samr_SetUserInfo2 *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_Connect4(pipes_struct *p,
- struct samr_Connect4 *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_ChangePasswordUser3(pipes_struct *p,
struct samr_ChangePasswordUser3 *r)
{
/****************************************************************
****************************************************************/
-NTSTATUS _samr_Connect5(pipes_struct *p,
- struct samr_Connect5 *r)
-{
- p->rng_fault_state = true;
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
-/****************************************************************
-****************************************************************/
-
NTSTATUS _samr_RidToSid(pipes_struct *p,
struct samr_RidToSid *r)
{
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_secobj(cli, mem_ctx, &pol, sec_info, &sdb);
-
+ result = rpccli_lsa_QuerySecurity(cli, mem_ctx,
+ &pol,
+ sec_info,
+ &sdb);
if (!NT_STATUS_IS_OK(result))
goto done;
display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
done:
- if (&pol)
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
done:
- if (&pol)
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
done:
- if (&pol)
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
extern DOM_SID domain_sid;
+static void init_lsa_String(struct lsa_String *name, const char *s)
+{
+ name->string = s;
+}
+
/****************************************************************************
display sam_user_info_7 structure
****************************************************************************/
printf("\tDOMAIN_REFUSE_PASSWORD_CHANGE\n");
}
-static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1)
+static void display_sam_dom_info_1(struct samr_DomInfo1 *info1)
{
-
- printf("Minimum password length:\t\t\t%d\n", info1->min_length_password);
- printf("Password uniqueness (remember x passwords):\t%d\n", info1->password_history);
+ printf("Minimum password length:\t\t\t%d\n",
+ info1->min_password_length);
+ printf("Password uniqueness (remember x passwords):\t%d\n",
+ info1->password_history_length);
display_password_properties(info1->password_properties);
- printf("password expire in:\t\t\t\t%s\n", display_time(info1->expire));
- printf("Min password age (allow changing in x days):\t%s\n", display_time(info1->min_passwordage));
+ printf("password expire in:\t\t\t\t%s\n",
+ display_time(info1->max_password_age));
+ printf("Min password age (allow changing in x days):\t%s\n",
+ display_time(info1->min_password_age));
}
-static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2)
+static void display_sam_dom_info_2(struct samr_DomInfo2 *info2)
{
- fstring name;
-
- unistr2_to_ascii(name, &info2->uni_domain, sizeof(name));
- printf("Domain:\t\t%s\n", name);
-
- unistr2_to_ascii(name, &info2->uni_server, sizeof(name));
- printf("Server:\t\t%s\n", name);
+ printf("Domain:\t\t%s\n", info2->domain_name.string);
+ printf("Server:\t\t%s\n", info2->primary.string);
+ printf("Comment:\t%s\n", info2->comment.string);
- unistr2_to_ascii(name, &info2->uni_comment, sizeof(name));
- printf("Comment:\t%s\n", name);
+ printf("Total Users:\t%d\n", info2->num_users);
+ printf("Total Groups:\t%d\n", info2->num_groups);
+ printf("Total Aliases:\t%d\n", info2->num_aliases);
- printf("Total Users:\t%d\n", info2->num_domain_usrs);
- printf("Total Groups:\t%d\n", info2->num_domain_grps);
- printf("Total Aliases:\t%d\n", info2->num_local_grps);
-
- printf("Sequence No:\t%llu\n", (unsigned long long)info2->seq_num);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info2->sequence_num);
- printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info2->logout));
+ printf("Force Logoff:\t%d\n",
+ (int)nt_time_to_unix_abs(&info2->force_logoff_time));
- printf("Unknown 4:\t0x%x\n", info2->unknown_4);
- printf("Server Role:\t%s\n", server_role_str(info2->server_role));
- printf("Unknown 6:\t0x%x\n", info2->unknown_6);
+ printf("Unknown 2:\t0x%x\n", info2->unknown2);
+ printf("Server Role:\t%s\n", server_role_str(info2->role));
+ printf("Unknown 3:\t0x%x\n", info2->unknown3);
}
-static void display_sam_unk_info_3(SAM_UNK_INFO_3 *info3)
+static void display_sam_dom_info_3(struct samr_DomInfo3 *info3)
{
- printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info3->logout));
+ printf("Force Logoff:\t%d\n",
+ (int)nt_time_to_unix_abs(&info3->force_logoff_time));
}
-static void display_sam_unk_info_4(SAM_UNK_INFO_4 *info4)
+static void display_sam_dom_info_4(struct samr_DomInfo4 *info4)
{
- fstring name;
-
- unistr2_to_ascii(name, &info4->uni_comment, sizeof(name));
- printf("Comment:\t%s\n", name);
+ printf("Comment:\t%s\n", info4->comment.string);
}
-static void display_sam_unk_info_5(SAM_UNK_INFO_5 *info5)
+static void display_sam_dom_info_5(struct samr_DomInfo5 *info5)
{
- fstring name;
-
- unistr2_to_ascii(name, &info5->uni_domain, sizeof(name));
- printf("Domain:\t\t%s\n", name);
+ printf("Domain:\t\t%s\n", info5->domain_name.string);
}
-static void display_sam_unk_info_6(SAM_UNK_INFO_6 *info6)
+static void display_sam_dom_info_6(struct samr_DomInfo6 *info6)
{
- fstring name;
-
- unistr2_to_ascii(name, &info6->uni_server, sizeof(name));
- printf("Server:\t\t%s\n", name);
+ printf("Server:\t\t%s\n", info6->primary.string);
}
-static void display_sam_unk_info_7(SAM_UNK_INFO_7 *info7)
+static void display_sam_dom_info_7(struct samr_DomInfo7 *info7)
{
- printf("Server Role:\t%s\n", server_role_str(info7->server_role));
+ printf("Server Role:\t%s\n", server_role_str(info7->role));
}
-static void display_sam_unk_info_8(SAM_UNK_INFO_8 *info8)
+static void display_sam_dom_info_8(struct samr_DomInfo8 *info8)
{
- printf("Sequence No:\t%llu\n", (unsigned long long)info8->seq_num);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info8->sequence_num);
printf("Domain Create Time:\t%s\n",
http_timestring(nt_time_to_unix(info8->domain_create_time)));
}
-static void display_sam_unk_info_9(SAM_UNK_INFO_9 *info9)
+static void display_sam_dom_info_9(struct samr_DomInfo9 *info9)
{
printf("unknown:\t%d (0x%08x)\n", info9->unknown, info9->unknown);
}
-static void display_sam_unk_info_12(SAM_UNK_INFO_12 *info12)
+static void display_sam_dom_info_12(struct samr_DomInfo12 *info12)
{
- printf("Bad password lockout duration: %s\n", display_time(info12->duration));
- printf("Reset Lockout after: %s\n", display_time(info12->reset_count));
- printf("Lockout after bad attempts: %d\n", info12->bad_attempt_lockout);
+ printf("Bad password lockout duration: %s\n",
+ display_time(info12->lockout_duration));
+ printf("Reset Lockout after: %s\n",
+ display_time(info12->lockout_window));
+ printf("Lockout after bad attempts: %d\n",
+ info12->lockout_threshold);
}
-static void display_sam_unk_info_13(SAM_UNK_INFO_13 *info13)
+static void display_sam_dom_info_13(struct samr_DomInfo13 *info13)
{
- printf("Sequence No:\t%llu\n", (unsigned long long)info13->seq_num);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info13->sequence_num);
printf("Domain Create Time:\t%s\n",
http_timestring(nt_time_to_unix(info13->domain_create_time)));
printf("Unknown1:\t%d\n", info13->unknown1);
}
/****************************************************************************
- Try samr_connect4 first, then samr_conenct if it fails
+ Try samr_connect4 first, then samr_connect2 if it fails
****************************************************************************/
static NTSTATUS try_samr_connects(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 access_mask, POLICY_HND *connect_pol)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- result = rpccli_samr_connect4(cli, mem_ctx, access_mask, connect_pol);
+
+ result = rpccli_samr_Connect4(cli, mem_ctx,
+ cli->cli->desthost,
+ SAMR_CONNECT_W2K,
+ access_mask,
+ connect_pol);
if (!NT_STATUS_IS_OK(result)) {
- result = rpccli_samr_connect(cli, mem_ctx, access_mask,
- connect_pol);
+ result = rpccli_samr_Connect2(cli, mem_ctx,
+ cli->cli->desthost,
+ access_mask,
+ connect_pol);
}
return result;
}
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
-
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- access_mask,
- user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ user_rid,
+ &user_pol);
if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER) &&
(user_rid == 0)) {
&types);
if (NT_STATUS_IS_OK(result)) {
- result = rpccli_samr_open_user(cli, mem_ctx,
- &domain_pol,
- access_mask,
- rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ rids[0],
+ &user_pol);
}
}
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
- access_mask,
- group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- access_mask,
- user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_SID *sids;
size_t num_sids;
- uint32 num_aliases, *alias_rids;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
int i;
fstring server;
- DOM_SID2 *sid2;
+ struct lsa_SidArray sid_array;
+ struct samr_Ids alias_rids;
if (argc < 3) {
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
}
if (num_sids) {
- sid2 = TALLOC_ARRAY(mem_ctx, DOM_SID2, num_sids);
- if (sid2 == NULL)
+ sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
+ if (sid_array.sids == NULL)
return NT_STATUS_NO_MEMORY;
} else {
- sid2 = NULL;
+ sid_array.sids = NULL;
}
for (i=0; i<num_sids; i++) {
- sid_copy(&sid2[i].sid, &sids[i]);
- sid2[i].num_auths = sid2[i].sid.num_auths;
+ sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);
+ if (!sid_array.sids[i].sid) {
+ return NT_STATUS_NO_MEMORY;
+ }
}
+ sid_array.num_sids = num_sids;
+
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
goto done;
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid, &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &global_sid_Builtin,
- &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else {
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
return NT_STATUS_INVALID_PARAMETER;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_useraliases(cli, mem_ctx, &domain_pol,
- num_sids, sid2,
- &num_aliases, &alias_rids);
-
+ result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
+ &domain_pol,
+ &sid_array,
+ &alias_rids);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_aliases; i++) {
- printf("\tgroup rid:[0x%x]\n", alias_rids[i]);
+ for (i = 0; i < alias_rids.count; i++) {
+ printf("\tgroup rid:[0x%x]\n", alias_rids.ids[i]);
}
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
{
POLICY_HND connect_pol, domain_pol, group_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 num_members, *group_rids, *group_attrs, group_rid;
+ uint32 group_rid;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
int i;
fstring server;
unsigned int old_timeout;
-
+ struct samr_RidTypeArray *rids = NULL;
+
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s rid [access mask]\n", argv[0]);
return NT_STATUS_OK;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
- access_mask,
- group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Make sure to wait for our DC's reply */
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
- result = rpccli_samr_query_groupmem(cli, mem_ctx, &group_pol,
- &num_members, &group_rids,
- &group_attrs);
+ result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
+ &group_pol,
+ &rids);
cli_set_timeout(cli->cli, old_timeout);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_members; i++) {
- printf("\trid:[0x%x] attr:[0x%x]\n", group_rids[i],
- group_attrs[i]);
+ for (i = 0; i < rids->count; i++) {
+ printf("\trid:[0x%x] attr:[0x%x]\n", rids->rids[i],
+ rids->types[i]);
}
rpccli_samr_Close(cli, mem_ctx, &group_pol);
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Get domain policy handle */
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
{
POLICY_HND connect_pol, domain_pol, alias_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 alias_rid, num_members, i;
+ uint32 alias_rid, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- DOM_SID *alias_sids;
+ struct lsa_SidArray sid_array;
if ((argc < 3) || (argc > 4)) {
printf("Usage: %s builtin|domain rid [access mask]\n", argv[0]);
/* Open handle on domain */
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
/* Open handle on alias */
- result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol,
- access_mask,
- alias_rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ alias_rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_aliasmem(cli, mem_ctx, &alias_pol,
- &num_members, &alias_sids);
+ result = rpccli_samr_GetMembersInAlias(cli, mem_ctx,
+ &alias_pol,
+ &sid_array);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_members; i++) {
+ for (i = 0; i < sid_array.num_sids; i++) {
fstring sid_str;
- sid_to_fstring(sid_str, &alias_sids[i]);
+ sid_to_fstring(sid_str, sid_array.sids[i].sid);
printf("\tsid:[%s]\n", sid_str);
}
/* Open handle on domain */
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_INVALID_PARAMETER;
/* Open handle on alias */
- result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol,
- access_mask,
- alias_rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ alias_rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result) && (alias_rid == 0)) {
/* Probably this was a user name, try lookupnames */
uint32 num_rids;
&types);
if (NT_STATUS_IS_OK(result)) {
- result = rpccli_samr_open_alias(cli, mem_ctx,
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
&domain_pol,
access_mask,
- rids[0], &alias_pol);
+ rids[0],
+ &alias_pol);
}
}
- result = rpccli_samr_delete_dom_alias(cli, mem_ctx, &alias_pol);
+ result = rpccli_samr_DeleteDomAlias(cli, mem_ctx,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 switch_level = 2;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- SAM_UNK_CTR ctr;
+ union samr_DomainInfo *info = NULL;
if (argc > 3) {
printf("Usage: %s [info level] [access mask]\n", argv[0]);
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Query domain info */
- result = rpccli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
- switch_level, &ctr);
+ result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
+ &domain_pol,
+ switch_level,
+ &info);
if (!NT_STATUS_IS_OK(result))
goto done;
switch (switch_level) {
case 1:
- display_sam_unk_info_1(&ctr.info.inf1);
+ display_sam_dom_info_1(&info->info1);
break;
case 2:
- display_sam_unk_info_2(&ctr.info.inf2);
+ display_sam_dom_info_2(&info->info2);
break;
case 3:
- display_sam_unk_info_3(&ctr.info.inf3);
+ display_sam_dom_info_3(&info->info3);
break;
case 4:
- display_sam_unk_info_4(&ctr.info.inf4);
+ display_sam_dom_info_4(&info->info4);
break;
case 5:
- display_sam_unk_info_5(&ctr.info.inf5);
+ display_sam_dom_info_5(&info->info5);
break;
case 6:
- display_sam_unk_info_6(&ctr.info.inf6);
+ display_sam_dom_info_6(&info->info6);
break;
case 7:
- display_sam_unk_info_7(&ctr.info.inf7);
+ display_sam_dom_info_7(&info->info7);
break;
case 8:
- display_sam_unk_info_8(&ctr.info.inf8);
+ display_sam_dom_info_8(&info->info8);
break;
case 9:
- display_sam_unk_info_9(&ctr.info.inf9);
+ display_sam_dom_info_9(&info->info9);
break;
case 12:
- display_sam_unk_info_12(&ctr.info.inf12);
+ display_sam_dom_info_12(&info->info12);
break;
case 13:
- display_sam_unk_info_13(&ctr.info.inf13);
+ display_sam_dom_info_13(&info->info13);
break;
default:
{
POLICY_HND connect_pol, domain_pol, user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *acct_name;
+ struct lsa_String acct_name;
uint32 acb_info;
uint32 acct_flags, user_rid;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ uint32_t access_granted = 0;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s username [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
- acct_name = argv[1];
+ init_lsa_String(&acct_name, argv[1]);
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
SAMR_USER_ACCESS_GET_ATTRIBUTES |
SAMR_USER_ACCESS_SET_ATTRIBUTES;
- result = rpccli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
- acct_name, acb_info, acct_flags,
- &user_pol, &user_rid);
+ result = rpccli_samr_CreateUser2(cli, mem_ctx,
+ &domain_pol,
+ &acct_name,
+ acb_info,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
if (!NT_STATUS_IS_OK(result))
goto done;
{
POLICY_HND connect_pol, domain_pol, group_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *grp_name;
+ struct lsa_String grp_name;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ uint32_t rid = 0;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s groupname [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
- grp_name = argv[1];
-
+ init_lsa_String(&grp_name, argv[1]);
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Create domain user */
-
- result = rpccli_samr_create_dom_group(cli, mem_ctx, &domain_pol,
- grp_name, MAXIMUM_ALLOWED_ACCESS,
- &group_pol);
+ result = rpccli_samr_CreateDomainGroup(cli, mem_ctx,
+ &domain_pol,
+ &grp_name,
+ MAXIMUM_ALLOWED_ACCESS,
+ &group_pol,
+ &rid);
if (!NT_STATUS_IS_OK(result))
goto done;
{
POLICY_HND connect_pol, domain_pol, alias_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *alias_name;
+ struct lsa_String alias_name;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ uint32_t rid = 0;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s aliasname [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
- alias_name = argv[1];
-
+ init_lsa_String(&alias_name, argv[1]);
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Create domain user */
- result = rpccli_samr_create_dom_alias(cli, mem_ctx, &domain_pol,
- alias_name, &alias_pol);
+ result = rpccli_samr_CreateDomAlias(cli, mem_ctx,
+ &domain_pol,
+ &alias_name,
+ MAXIMUM_ALLOWED_ACCESS,
+ &alias_pol,
+ &rid);
if (!NT_STATUS_IS_OK(result))
goto done;
goto done;
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
goto done;
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
- access_mask,
- group_rids[0], &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ group_rids[0],
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
}
- /* Delete user */
+ /* Delete group */
- result = rpccli_samr_delete_dom_group(cli, mem_ctx, &group_pol);
+ result = rpccli_samr_DeleteDomainGroup(cli, mem_ctx,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- access_mask,
- user_rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ user_rids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Delete user */
- result = rpccli_samr_delete_dom_user(cli, mem_ctx, &user_pol);
+ result = rpccli_samr_DeleteUser(cli, mem_ctx,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
goto done;
if (domain || user_rid)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (user_rid)
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Query SAM security object */
- result = rpccli_samr_query_sec_obj(cli, mem_ctx, pol, sec_info, ctx,
- &sec_desc_buf);
+ result = rpccli_samr_QuerySecurity(cli, mem_ctx,
+ pol,
+ sec_info,
+ &sec_desc_buf);
if (!NT_STATUS_IS_OK(result))
goto done;
goto done;
}
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
return result;
}
-static void init_lsa_String(struct lsa_String *name, const char *s)
-{
- name->string = s;
-}
-
static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- fstring domain_name,sid_string;
- DOM_SID sid;
-
+ fstring sid_string;
+ struct lsa_String domain_name;
+ DOM_SID *sid = NULL;
+
if (argc != 2) {
printf("Usage: %s domain_name\n", argv[0]);
return NT_STATUS_OK;
}
-
- sscanf(argv[1], "%s", domain_name);
-
+
+ init_lsa_String(&domain_name, argv[1]);
+
result = try_samr_connects(cli, mem_ctx, access_mask, &connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask, &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
-
- result = rpccli_samr_lookup_domain(
- cli, mem_ctx, &connect_pol, domain_name, &sid);
+
+ result = rpccli_samr_LookupDomain(cli, mem_ctx,
+ &connect_pol,
+ &domain_name,
+ &sid);
if (NT_STATUS_IS_OK(result)) {
- sid_to_fstring(sid_string,&sid);
+ sid_to_fstring(sid_string, sid);
printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",
- domain_name,sid_string);
+ argv[1], sid_string);
}
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
result = rpccli_samr_chgpasswd3(cli, mem_ctx, user, newpass, oldpass, &info, &reject);
if (NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_RESTRICTION)) {
-
- display_sam_unk_info_1(&info);
+
+ /*display_sam_dom_info_1(&info);*/
switch (reject.reject_reason) {
case SAMR_REJECT_TOO_SHORT:
goto done;;
}
- printf("Succesfully set %s to driver %s.\n", argv[1], argv[2]);
+ printf("Successfully set %s to driver %s.\n", argv[1], argv[2]);
done:
/* Cleanup */
static int expect(int master, char *issue, char *expected)
{
char buffer[1024];
- int attempts, timeout, nread, len;
+ int attempts, timeout, nread;
+ size_t len;
bool match = False;
for (attempts = 0; attempts < 2; attempts++) {
DEBUG(100, ("expect: sending [%s]\n", issue));
if ((len = sys_write(master, issue, strlen(issue))) != strlen(issue)) {
- DEBUG(2,("expect: (short) write returned %d\n", len ));
+ DEBUG(2,("expect: (short) write returned %d\n",
+ (int)len ));
return False;
}
}
nread = 0;
buffer[nread] = 0;
- while ((len = read_socket_with_timeout(master, buffer + nread, 1,
- sizeof(buffer) - nread - 1,
- timeout, NULL)) > 0) {
+ while (True) {
+ NTSTATUS status;
+ status = read_socket_with_timeout(
+ master, buffer + nread, 1,
+ sizeof(buffer) - nread - 1,
+ timeout, &len);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ break;
+ }
nread += len;
buffer[nread] = 0;
where:
- usri11_name specifies the user name for which information is retireved
+ usri11_name specifies the user name for which information is retrieved
usri11_pad aligns the next data structure element to a word boundary
/* skip lines like 'user = ' */
- dosuserlist = str_list_make(dosname, NULL);
+ dosuserlist = str_list_make(talloc_tos(), dosname, NULL);
if (!dosuserlist) {
DEBUG(0,("Bad username map entry. Unable to build user list. Ignoring.\n"));
continue;
fstrcpy( user, unixname );
if ( return_if_mapped ) {
- str_list_free (&dosuserlist);
+ TALLOC_FREE(dosuserlist);
x_fclose(f);
return True;
}
}
- str_list_free (&dosuserlist);
+ TALLOC_FREE(dosuserlist);
}
x_fclose(f);
DEBUG(0,("irix_oplock_receive_message: read of kernel "
"notification failed. Error was %s.\n",
strerror(errno) ));
- set_smb_read_error(get_srv_read_error(), SMB_READ_ERROR);
return NULL;
}
*/
return NULL;
}
- set_smb_read_error(get_srv_read_error(), SMB_READ_ERROR);
return NULL;
}
ret = True;
if (lp_invalid_users(snum)) {
- str_list_copy(&invalid, lp_invalid_users(snum));
+ str_list_copy(talloc_tos(), &invalid, lp_invalid_users(snum));
if (invalid &&
str_list_substitute(invalid, "%S", lp_servicename(snum))) {
}
}
}
- if (invalid)
- str_list_free (&invalid);
+ TALLOC_FREE(invalid);
if (ret && lp_valid_users(snum)) {
- str_list_copy(&valid, lp_valid_users(snum));
+ str_list_copy(talloc_tos(), &valid, lp_valid_users(snum));
if ( valid &&
str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
}
}
}
- if (valid)
- str_list_free (&valid);
+ TALLOC_FREE(valid);
if (ret && lp_onlyuser(snum)) {
- char **user_list = str_list_make (lp_username(snum), NULL);
+ char **user_list = str_list_make(
+ talloc_tos(), lp_username(snum), NULL);
if (user_list &&
str_list_substitute(user_list, "%S",
lp_servicename(snum))) {
ret = user_in_list(user, (const char **)user_list);
}
- if (user_list) str_list_free (&user_list);
+ TALLOC_FREE(user_list);
}
return(ret);
extern int smb_echo_count;
-static enum smb_read_errors smb_read_error = SMB_READ_OK;
-
/*
* Size of data we can send to client. Set
* by the client for all protocols above CORE.
/* Accessor function for smb_read_error for smbd functions. */
-enum smb_read_errors *get_srv_read_error(void)
-{
- return &smb_read_error;
-}
-
/****************************************************************************
Send an smb to a fd.
****************************************************************************/
DEBUG(0,("Invalid packet length! (%lu bytes).\n",
(unsigned long)len));
if (len > BUFFER_SIZE + (SAFETY_MARGIN/2)) {
-
- /*
- * Correct fix. smb_read_error may have already been
- * set. Only set it here if not already set. Global
- * variables still suck :-). JRA.
- */
-
- cond_set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
return false;
}
}
return true;
}
-static ssize_t read_packet_remainder(int fd,
- char *buffer,
- unsigned int timeout,
- ssize_t len)
+static NTSTATUS read_packet_remainder(int fd, char *buffer,
+ unsigned int timeout, ssize_t len)
{
- ssize_t ret;
-
- if(len <= 0) {
- return len;
+ if (len <= 0) {
+ return NT_STATUS_OK;
}
- ret = read_socket_with_timeout(fd, buffer, len, len, timeout,
- get_srv_read_error());
-
- if (ret != len) {
- cond_set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
- return -1;
- }
-
- return len;
+ return read_socket_with_timeout(fd, buffer, len, len, timeout, NULL);
}
/****************************************************************************
(2*14) + /* word count (including bcc) */ \
1 /* pad byte */)
-static ssize_t receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
- const char lenbuf[4],
- int fd,
- char **buffer,
- unsigned int timeout,
- size_t *p_unread)
+static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
+ const char lenbuf[4],
+ int fd, char **buffer,
+ unsigned int timeout,
+ size_t *p_unread,
+ size_t *len_ret)
{
/* Size of a WRITEX call (+4 byte len). */
char writeX_header[4 + STANDARD_WRITE_AND_X_HEADER_SIZE];
ssize_t len = smb_len_large(lenbuf); /* Could be a UNIX large writeX. */
ssize_t toread;
- ssize_t ret;
+ NTSTATUS status;
memcpy(writeX_header, lenbuf, sizeof(lenbuf));
- ret = read_socket_with_timeout(fd, writeX_header + 4,
- STANDARD_WRITE_AND_X_HEADER_SIZE,
- STANDARD_WRITE_AND_X_HEADER_SIZE,
- timeout, get_srv_read_error());
+ status = read_socket_with_timeout(
+ fd, writeX_header + 4,
+ STANDARD_WRITE_AND_X_HEADER_SIZE,
+ STANDARD_WRITE_AND_X_HEADER_SIZE,
+ timeout, NULL);
- if (ret != STANDARD_WRITE_AND_X_HEADER_SIZE) {
- cond_set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
- return -1;
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
/*
if (*buffer == NULL) {
DEBUG(0, ("Could not allocate inbuf of length %d\n",
(int)sizeof(writeX_header)));
- cond_set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
- return -1;
+ return NT_STATUS_NO_MEMORY;
}
/* Work out the remaining bytes. */
*p_unread = len - STANDARD_WRITE_AND_X_HEADER_SIZE;
-
- return newlen + 4;
+ *len_ret = newlen + 4;
+ return NT_STATUS_OK;
}
if (!valid_packet_size(len)) {
- return -1;
+ return NT_STATUS_INVALID_PARAMETER;
}
/*
if (*buffer == NULL) {
DEBUG(0, ("Could not allocate inbuf of length %d\n",
(int)len+4));
- cond_set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
- return -1;
+ return NT_STATUS_NO_MEMORY;
}
/* Copy in what we already read. */
toread = len - STANDARD_WRITE_AND_X_HEADER_SIZE;
if(toread > 0) {
- ret = read_packet_remainder(fd,
- (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE,
- timeout,
- toread);
- if (ret != toread) {
- return -1;
+ status = read_packet_remainder(
+ fd, (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE,
+ timeout, toread);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
}
- return len + 4;
+ *len_ret = len + 4;
+ return NT_STATUS_OK;
}
-static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
- int fd,
- char **buffer,
- unsigned int timeout,
- size_t *p_unread)
+static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd,
+ char **buffer, unsigned int timeout,
+ size_t *p_unread, size_t *plen)
{
char lenbuf[4];
- ssize_t len,ret;
+ size_t len;
int min_recv_size = lp_min_receive_file_size();
+ NTSTATUS status;
- set_smb_read_error(get_srv_read_error(),SMB_READ_OK);
*p_unread = 0;
- len = read_smb_length_return_keepalive(fd, lenbuf,
- timeout, get_srv_read_error());
- if (len < 0) {
- DEBUG(10,("receive_smb_raw: length < 0!\n"));
-
- /*
- * Correct fix. smb_read_error may have already been
- * set. Only set it here if not already set. Global
- * variables still suck :-). JRA.
- */
-
- cond_set_smb_read_error(get_srv_read_error(),SMB_READ_ERROR);
- return -1;
+ status = read_smb_length_return_keepalive(fd, lenbuf, timeout, &len);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("receive_smb_raw: %s\n", nt_errstr(status)));
+ return status;
}
if (CVAL(lenbuf,0) == 0 &&
smb_len_large(lenbuf) > min_recv_size && /* Could be a UNIX large writeX. */
!srv_is_signing_active()) {
- return receive_smb_raw_talloc_partial_read(mem_ctx,
- lenbuf,
- fd,
- buffer,
- timeout,
- p_unread);
+ status = receive_smb_raw_talloc_partial_read(
+ mem_ctx, lenbuf, fd, buffer, timeout, p_unread, &len);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("receive_smb_raw: %s\n",
+ nt_errstr(status)));
+ return status;
+ }
}
if (!valid_packet_size(len)) {
- return -1;
+ return NT_STATUS_INVALID_PARAMETER;
}
/*
if (*buffer == NULL) {
DEBUG(0, ("Could not allocate inbuf of length %d\n",
(int)len+4));
- cond_set_smb_read_error(get_srv_read_error(),SMB_READ_ERROR);
- return -1;
+ return NT_STATUS_NO_MEMORY;
}
memcpy(*buffer, lenbuf, sizeof(lenbuf));
- ret = read_packet_remainder(fd, (*buffer)+4, timeout, len);
- if (ret != len) {
- return -1;
+ status = read_packet_remainder(fd, (*buffer)+4, timeout, len);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- return len + 4;
+ *plen = len + 4;
+ return NT_STATUS_OK;
}
-static ssize_t receive_smb_talloc(TALLOC_CTX *mem_ctx,
- int fd,
- char **buffer,
- unsigned int timeout,
- size_t *p_unread,
- bool *p_encrypted)
+static NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd,
+ char **buffer, unsigned int timeout,
+ size_t *p_unread, bool *p_encrypted,
+ size_t *p_len)
{
- ssize_t len;
+ size_t len = 0;
+ NTSTATUS status;
*p_encrypted = false;
- len = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout, p_unread);
-
- if (len < 0) {
- return -1;
+ status = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout,
+ p_unread, &len);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
if (is_encrypted_packet((uint8_t *)*buffer)) {
- NTSTATUS status = srv_decrypt_buffer(*buffer);
+ status = srv_decrypt_buffer(*buffer);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("receive_smb_talloc: SMB decryption failed on "
"incoming packet! Error %s\n",
nt_errstr(status) ));
- cond_set_smb_read_error(get_srv_read_error(),
- SMB_READ_BAD_DECRYPT);
- return -1;
+ return status;
}
*p_encrypted = true;
}
if (!srv_check_sign_mac(*buffer, true)) {
DEBUG(0, ("receive_smb: SMB Signature verification failed on "
"incoming packet!\n"));
- cond_set_smb_read_error(get_srv_read_error(),SMB_READ_BAD_SIG);
- return -1;
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- return len;
+ *p_len = len;
+ return NT_STATUS_OK;
}
/*
The timeout is in milliseconds
****************************************************************************/
-static bool receive_message_or_smb(TALLOC_CTX *mem_ctx,
- char **buffer,
- size_t *buffer_len,
- int timeout,
- size_t *p_unread,
- bool *p_encrypted)
+static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer,
+ size_t *buffer_len, int timeout,
+ size_t *p_unread, bool *p_encrypted)
{
fd_set r_fds, w_fds;
int selrtn;
struct timeval to;
int maxfd = 0;
- ssize_t len;
+ size_t len = 0;
+ NTSTATUS status;
*p_unread = 0;
- set_smb_read_error(get_srv_read_error(),SMB_READ_OK);
again:
msg->buf.length);
if (*buffer == NULL) {
DEBUG(0, ("talloc failed\n"));
- set_smb_read_error(get_srv_read_error(),SMB_READ_ERROR);
- return False;
+ return NT_STATUS_NO_MEMORY;
}
*buffer_len = msg->buf.length;
*p_encrypted = msg->encrypted;
/* We leave this message on the queue so the open code can
know this is a retry. */
DEBUG(5,("receive_message_or_smb: returning deferred open smb message.\n"));
- return True;
+ return NT_STATUS_OK;
}
}
/* Check if error */
if (selrtn == -1) {
/* something is wrong. Maybe the socket is dead? */
- set_smb_read_error(get_srv_read_error(),SMB_READ_ERROR);
- return False;
+ return map_nt_error_from_unix(errno);
}
/* Did we timeout ? */
if (selrtn == 0) {
- set_smb_read_error(get_srv_read_error(),SMB_READ_TIMEOUT);
- return False;
+ return NT_STATUS_IO_TIMEOUT;
}
/*
goto again;
}
- len = receive_smb_talloc(mem_ctx, smbd_server_fd(),
- buffer, 0, p_unread, p_encrypted);
+ status = receive_smb_talloc(mem_ctx, smbd_server_fd(), buffer, 0,
+ p_unread, p_encrypted, &len);
- if (len == -1) {
- return False;
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- *buffer_len = (size_t)len;
+ *buffer_len = len;
- return True;
+ return NT_STATUS_OK;
}
/*
Process any timeout housekeeping. Return False if the caller should exit.
****************************************************************************/
-static bool timeout_processing(int *select_timeout,
+static void timeout_processing(int *select_timeout,
time_t *last_timeout_processing_time)
{
time_t t;
- if (*get_srv_read_error() == SMB_READ_EOF) {
- DEBUG(3,("timeout_processing: End of file from client (client has disconnected).\n"));
- return false;
- }
-
- if (*get_srv_read_error() == SMB_READ_ERROR) {
- DEBUG(3,("timeout_processing: receive_smb error (%s) Exiting\n",
- strerror(errno)));
- return false;
- }
-
- if (*get_srv_read_error() == SMB_READ_BAD_SIG) {
- DEBUG(3,("timeout_processing: receive_smb error bad smb signature. Exiting\n"));
- return false;
- }
-
*last_timeout_processing_time = t = time(NULL);
/* become root again if waiting */
if (secrets_lock_trust_account_password(lp_workgroup(), True) == False) {
DEBUG(0,("process: unable to lock the machine account password for \
machine %s in domain %s.\n", global_myname(), lp_workgroup() ));
- return True;
+ return;
}
if(!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd_hash, &lct, NULL)) {
DEBUG(0,("process: unable to read the machine account password for \
machine %s in domain %s.\n", global_myname(), lp_workgroup()));
secrets_lock_trust_account_password(lp_workgroup(), False);
- return True;
+ return;
}
/*
if(t < lct + lp_machine_password_timeout()) {
global_machine_password_needs_changing = False;
secrets_lock_trust_account_password(lp_workgroup(), False);
- return True;
+ return;
}
/* always just contact the PDC here */
*select_timeout = setup_select_timeout();
- return True;
+ return;
}
/****************************************************************************
while (True) {
int select_timeout = setup_select_timeout();
int num_echos;
- char *inbuf;
- size_t inbuf_len;
+ char *inbuf = NULL;
+ size_t inbuf_len = 0;
bool encrypted = false;
TALLOC_CTX *frame = talloc_stackframe_pool(8192);
/* Did someone ask for immediate checks on things like blocking locks ? */
if (select_timeout == 0) {
- if(!timeout_processing(&select_timeout,
- &last_timeout_processing_time))
- return;
+ timeout_processing(&select_timeout,
+ &last_timeout_processing_time);
num_smbs = 0; /* Reset smb counter. */
}
run_events(smbd_event_context(), 0, NULL, NULL);
- while (!receive_message_or_smb(talloc_tos(), &inbuf, &inbuf_len,
- select_timeout,
- &unread_bytes,
- &encrypted)) {
- if(!timeout_processing(&select_timeout,
- &last_timeout_processing_time))
- return;
+ while (True) {
+ NTSTATUS status;
+
+ status = receive_message_or_smb(
+ talloc_tos(), &inbuf, &inbuf_len,
+ select_timeout, &unread_bytes, &encrypted);
+
+ if (NT_STATUS_IS_OK(status)) {
+ break;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ timeout_processing(
+ &select_timeout,
+ &last_timeout_processing_time);
+ continue;
+ }
+
+ DEBUG(3, ("receive_message_or_smb failed: %s, "
+ "exiting\n", nt_errstr(status)));
+ return;
+
num_smbs = 0; /* Reset smb counter. */
}
TALLOC_FREE(inbuf);
if (smb_echo_count != num_echos) {
- if(!timeout_processing( &select_timeout, &last_timeout_processing_time))
- return;
+ timeout_processing(&select_timeout,
+ &last_timeout_processing_time);
num_smbs = 0; /* Reset smb counter. */
}
if ((num_smbs % 200) == 0) {
time_t new_check_time = time(NULL);
if(new_check_time - last_timeout_processing_time >= (select_timeout/1000)) {
- if(!timeout_processing(
- &select_timeout,
- &last_timeout_processing_time))
- return;
+ timeout_processing(
+ &select_timeout,
+ &last_timeout_processing_time);
num_smbs = 0; /* Reset smb counter. */
last_timeout_processing_time = new_check_time; /* Reset time. */
}
}
/* Now read the raw data into the buffer and write it */
- if (read_smb_length(smbd_server_fd(),buf,
- SMB_SECONDARY_WAIT, get_srv_read_error()) == -1) {
+ status = read_smb_length(smbd_server_fd(), buf, SMB_SECONDARY_WAIT,
+ &numtowrite);
+ if (!NT_STATUS_IS_OK(status)) {
exit_server_cleanly("secondary writebraw failed");
}
- /*
- * Even though this is not an smb message,
- * smb_len returns the generic length of a packet.
- */
-
- numtowrite = smb_len(buf);
-
/* Set up outbuf to return the correct size */
reply_outbuf(req, 1, 0);
(int)tcount,(int)nwritten,(int)numtowrite));
}
- if (read_data(smbd_server_fd(), buf+4, numtowrite,get_srv_read_error())
- != numtowrite ) {
+ status = read_data(smbd_server_fd(), buf+4, numtowrite);
+
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reply_writebraw: Oversize secondary write "
- "raw read failed (%s). Terminating\n",
- strerror(errno) ));
+ "raw read failed (%s). Terminating\n",
+ nt_errstr(status)));
exit_server_cleanly("secondary writebraw failed");
}
goto done; \
}
+static void init_lsa_String(struct lsa_String *name, const char *s)
+{
+ name->string = s;
+}
+
/*******************************************************************
Leave an AD domain. Windows XP disables the machine account.
We'll try the same. The old code would do an LDAP delete.
return status;
}
- status = rpccli_samr_connect(pipe_hnd, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED, &sam_pol);
+ status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &sam_pol);
if ( !NT_STATUS_IS_OK(status) )
return status;
-
- status = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &sam_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED, dom_sid, &domain_pol);
+
+ status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &sam_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ dom_sid,
+ &domain_pol);
if ( !NT_STATUS_IS_OK(status) )
return status;
/* Open handle on user */
- status = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED, user_rid, &user_pol);
+ status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ user_rid,
+ &user_pol);
if ( !NT_STATUS_IS_OK(status) ) {
goto done;
}
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
char *acct_name;
const char *const_acct_name;
+ struct lsa_String lsa_acct_name;
uint32 user_rid;
uint32 num_rids, *name_types, *user_rids;
uint32 flags = 0x3e8;
uchar md5buffer[16];
DATA_BLOB digested_session_key;
uchar md4_trust_password[16];
+ uint32_t access_granted = 0;
/* Open the domain */
return status;
}
- status = rpccli_samr_connect(pipe_hnd, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED, &sam_pol);
+ status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &sam_pol);
if ( !NT_STATUS_IS_OK(status) )
return status;
-
- status = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &sam_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED, dom_sid, &domain_pol);
+
+ status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &sam_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ dom_sid,
+ &domain_pol);
if ( !NT_STATUS_IS_OK(status) )
return status;
strlower_m(acct_name);
const_acct_name = acct_name;
+ init_lsa_String(&lsa_acct_name, acct_name);
+
/* Don't try to set any acb_info flags other than ACB_WSTRUST */
acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
SEC_STD_WRITE_DAC | SEC_STD_DELETE |
DEBUG(10, ("Creating account with flags: %d\n",acct_flags));
- status = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol,
- acct_name, acb_info, acct_flags, &user_pol, &user_rid);
+ status = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &lsa_acct_name,
+ acb_info,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
if ( !NT_STATUS_IS_OK(status)
&& !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS))
/* Open handle on user */
- status = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED, user_rid, &user_pol);
+ status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
#include "includes.h"
#include "utils/net.h"
+static void init_lsa_String(struct lsa_String *name, const char *s)
+{
+ name->string = s;
+}
+
static int net_mode_share;
static bool sync_files(struct copy_clistate *cp_clistate, const char *mask);
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- SAM_UNK_CTR ctr;
+ union samr_DomainInfo *info = NULL;
fstring sid_str;
sid_to_fstring(sid_str, domain_sid);
- /* Get sam policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ /* Get sam policy handle */
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Could not connect to SAM: %s\n", nt_errstr(result));
goto done;
}
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Could not open domain: %s\n", nt_errstr(result));
goto done;
}
- ZERO_STRUCT(ctr);
- result = rpccli_samr_query_dom_info(pipe_hnd, mem_ctx, &domain_pol,
- 2, &ctr);
+ result = rpccli_samr_QueryDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 2,
+ &info);
if (NT_STATUS_IS_OK(result)) {
- TALLOC_CTX *ctx = talloc_init("rpc_info_internals");
- d_printf("Domain Name: %s\n", unistr2_to_ascii_talloc(ctx, &ctr.info.inf2.uni_domain));
+ d_printf("Domain Name: %s\n", info->info2.domain_name.string);
d_printf("Domain SID: %s\n", sid_str);
- d_printf("Sequence number: %llu\n", (unsigned long long)ctr.info.inf2.seq_num);
- d_printf("Num users: %u\n", ctr.info.inf2.num_domain_usrs);
- d_printf("Num domain groups: %u\n", ctr.info.inf2.num_domain_grps);
- d_printf("Num local groups: %u\n", ctr.info.inf2.num_local_grps);
- talloc_destroy(ctx);
+ d_printf("Sequence number: %llu\n",
+ (unsigned long long)info->info2.sequence_num);
+ d_printf("Num users: %u\n", info->info2.num_users);
+ d_printf("Num domain groups: %u\n", info->info2.num_groups);
+ d_printf("Num local groups: %u\n", info->info2.num_aliases);
}
done:
POLICY_HND connect_pol, domain_pol, user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
const char *acct_name;
+ struct lsa_String lsa_acct_name;
uint32 acb_info;
uint32 acct_flags, user_rid;
+ uint32_t access_granted = 0;
if (argc < 1) {
d_printf("User must be specified\n");
}
acct_name = argv[0];
+ init_lsa_String(&lsa_acct_name, acct_name);
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
SAMR_USER_ACCESS_GET_ATTRIBUTES |
SAMR_USER_ACCESS_SET_ATTRIBUTES;
- result = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol,
- acct_name, acb_info, acct_flags,
- &user_pol, &user_rid);
+ result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &lsa_acct_name,
+ acb_info,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
+
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
goto done;
}
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
d_fprintf(stderr, "Failed to set password for user %s - %s\n",
acct_name, nt_errstr(result));
- result = rpccli_samr_delete_dom_user(pipe_hnd, mem_ctx, &user_pol);
+ result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Failed to delete user %s - %s\n",
/* Get sam policy and domain handles */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
goto done;
}
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
/* Delete user */
- result = rpccli_samr_delete_dom_user(pipe_hnd, mem_ctx, &user_pol);
+ result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
ZERO_STRUCT(user_ctr);
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
+
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
}
/* Open domain user */
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS, user_rid[0], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rid[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
/* Get sam policy and domain handles */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
goto done;
}
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
return NT_STATUS_OK;
}
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Get handle on user */
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
result = rpccli_samr_query_usergroups(pipe_hnd, mem_ctx, &user_pol,
SAM_DISPINFO_1 info1;
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
goto done;
}
- result = rpccli_samr_connect(pipe_hnd, mem_ctx,
- MAXIMUM_ALLOWED_ACCESS, &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- ctx->domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ ctx->domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- rid, &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
bool group_is_primary = False;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 *group_rids, num_rids, *name_types, num_members,
- *group_attrs, group_rid;
+ uint32 *group_rids, num_rids, *name_types, group_rid;
+ struct samr_RidTypeArray *rids = NULL;
uint32 flags = 0x000003e8; /* Unknown */
/* char **names; */
int i;
return NT_STATUS_OK; /* ok? */
}
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Request samr_connect failed\n");
+ d_fprintf(stderr, "Request samr_Connect2 failed\n");
goto done;
}
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
-
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
+
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Request open_domain failed\n");
goto done;
switch (name_types[0])
{
case SID_NAME_DOM_GRP:
- result = rpccli_samr_open_group(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- group_rids[0], &group_pol);
+ result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ group_rids[0],
+ &group_pol);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Request open_group failed");
goto done;
}
group_rid = group_rids[0];
-
- result = rpccli_samr_query_groupmem(pipe_hnd, mem_ctx, &group_pol,
- &num_members, &group_rids,
- &group_attrs);
-
+
+ result = rpccli_samr_QueryGroupMember(pipe_hnd, mem_ctx,
+ &group_pol,
+ &rids);
+
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Unable to query group members of %s",argv[0]);
goto done;
if (opt_verbose) {
d_printf("Domain Group %s (rid: %d) has %d members\n",
- argv[0],group_rid,num_members);
+ argv[0],group_rid, rids->count);
}
/* Check if group is anyone's primary group */
- for (i = 0; i < num_members; i++)
+ for (i = 0; i < rids->count; i++)
{
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- group_rids[i], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rids->rids[i],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Unable to open group member %d\n",group_rids[i]);
+ d_fprintf(stderr, "Unable to open group member %d\n",
+ rids->rids[i]);
goto done;
}
21, &user_ctr);
if (!NT_STATUS_IS_OK(result)) {
- d_fprintf(stderr, "Unable to lookup userinfo for group member %d\n",group_rids[i]);
+ d_fprintf(stderr, "Unable to lookup userinfo for group member %d\n",
+ rids->rids[i]);
goto done;
}
}
/* remove all group members */
- for (i = 0; i < num_members; i++)
+ for (i = 0; i < rids->count; i++)
{
if (opt_verbose)
- d_printf("Remove group member %d...",group_rids[i]);
- result = rpccli_samr_del_groupmem(pipe_hnd, mem_ctx, &group_pol, group_rids[i]);
+ d_printf("Remove group member %d...",
+ rids->rids[i]);
+ result = rpccli_samr_DeleteGroupMember(pipe_hnd, mem_ctx,
+ &group_pol,
+ rids->rids[i]);
if (NT_STATUS_IS_OK(result)) {
if (opt_verbose)
}
}
- result = rpccli_samr_delete_dom_group(pipe_hnd, mem_ctx, &group_pol);
+ result = rpccli_samr_DeleteDomainGroup(pipe_hnd, mem_ctx,
+ &group_pol);
break;
/* removing a local group is easier... */
case SID_NAME_ALIAS:
- result = rpccli_samr_open_alias(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- group_rids[0], &group_pol);
+ result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ group_rids[0],
+ &group_pol);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Request open_alias failed\n");
goto done;
}
-
- result = rpccli_samr_delete_dom_alias(pipe_hnd, mem_ctx, &group_pol);
+
+ result = rpccli_samr_DeleteDomAlias(pipe_hnd, mem_ctx,
+ &group_pol);
break;
default:
d_fprintf(stderr, "%s is of type %s. This command is only for deleting local or global groups\n",
POLICY_HND connect_pol, domain_pol, group_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
GROUP_INFO_CTR group_info;
+ struct lsa_String grp_name;
+ uint32_t rid = 0;
if (argc != 1) {
d_printf("Group name must be specified\n");
return NT_STATUS_OK;
}
+ init_lsa_String(&grp_name, argv[0]);
+
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Create the group */
- result = rpccli_samr_create_dom_group(pipe_hnd, mem_ctx, &domain_pol,
- argv[0], MAXIMUM_ALLOWED_ACCESS,
- &group_pol);
+ result = rpccli_samr_CreateDomainGroup(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &grp_name,
+ MAXIMUM_ALLOWED_ACCESS,
+ &group_pol,
+ &rid);
if (!NT_STATUS_IS_OK(result)) goto done;
if (strlen(opt_comment) == 0) goto done;
POLICY_HND connect_pol, domain_pol, alias_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
ALIAS_INFO_CTR alias_info;
+ struct lsa_String alias_name;
+ uint32_t rid = 0;
if (argc != 1) {
d_printf("Alias name must be specified\n");
return NT_STATUS_OK;
}
+ init_lsa_String(&alias_name, argv[0]);
+
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
/* Create the group */
- result = rpccli_samr_create_dom_alias(pipe_hnd, mem_ctx, &domain_pol,
- argv[0], &alias_pol);
+ result = rpccli_samr_CreateDomAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &alias_name,
+ MAXIMUM_ALLOWED_ACCESS,
+ &alias_pol,
+ &rid);
if (!NT_STATUS_IS_OK(result)) goto done;
if (strlen(opt_comment) == 0) goto done;
return NT_STATUS_UNSUCCESSFUL;
}
- /* Get sam policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ /* Get sam policy handle */
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
return result;
}
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
return result;
}
goto done;
}
- result = rpccli_samr_open_group(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_add_groupmem(pipe_hnd, mem_ctx, &group_pol, rids[0]);
+ result = rpccli_samr_AddGroupMember(pipe_hnd, mem_ctx,
+ &group_pol,
+ rids[0],
+ 0x0005); /* unknown flags */
done:
rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);
return result;
}
- /* Get sam policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ /* Get sam policy handle */
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_alias(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- alias_rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ alias_rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result)) {
return result;
}
- result = rpccli_samr_add_aliasmem(pipe_hnd, mem_ctx, &alias_pol, &member_sid);
+ result = rpccli_samr_AddAliasMember(pipe_hnd, mem_ctx,
+ &alias_pol,
+ &member_sid);
if (!NT_STATUS_IS_OK(result)) {
return result;
if (!sid_split_rid(&sid, &group_rid))
return NT_STATUS_UNSUCCESSFUL;
- /* Get sam policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ /* Get sam policy handle */
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result))
return result;
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
return result;
goto done;
}
- result = rpccli_samr_open_group(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_del_groupmem(pipe_hnd, mem_ctx, &group_pol, rids[0]);
+ result = rpccli_samr_DeleteGroupMember(pipe_hnd, mem_ctx,
+ &group_pol,
+ rids[0]);
done:
rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);
return result;
}
- /* Get sam policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ /* Get sam policy handle */
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_alias(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- alias_rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ alias_rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
return result;
- result = rpccli_samr_del_aliasmem(pipe_hnd, mem_ctx, &alias_pol, &member_sid);
+ result = rpccli_samr_DeleteAliasMember(pipe_hnd, mem_ctx,
+ &alias_pol,
+ &member_sid);
if (!NT_STATUS_IS_OK(result))
return result;
}
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
POLICY_HND alias_pol;
ALIAS_INFO_CTR ctr;
- if ((NT_STATUS_IS_OK(rpccli_samr_open_alias(pipe_hnd, mem_ctx,
- &domain_pol,
- 0x8,
- groups[i].rid,
- &alias_pol))) &&
+ if ((NT_STATUS_IS_OK(rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 0x8,
+ groups[i].rid,
+ &alias_pol))) &&
(NT_STATUS_IS_OK(rpccli_samr_query_alias_info(pipe_hnd, mem_ctx,
&alias_pol, 3,
&ctr))) &&
} while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
/* Get builtin policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
POLICY_HND alias_pol;
ALIAS_INFO_CTR ctr;
- if ((NT_STATUS_IS_OK(rpccli_samr_open_alias(pipe_hnd, mem_ctx,
- &domain_pol,
- 0x8,
- groups[i].rid,
- &alias_pol))) &&
+ if ((NT_STATUS_IS_OK(rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 0x8,
+ groups[i].rid,
+ &alias_pol))) &&
(NT_STATUS_IS_OK(rpccli_samr_query_alias_info(pipe_hnd, mem_ctx,
&alias_pol, 3,
&ctr))) &&
{
NTSTATUS result;
POLICY_HND group_pol;
- uint32 num_members, *group_rids, *group_attrs;
+ uint32 num_members, *group_rids;
uint32 num_names;
char **names;
uint32 *name_types;
int i;
+ struct samr_RidTypeArray *rids = NULL;
fstring sid_str;
sid_to_fstring(sid_str, domain_sid);
- result = rpccli_samr_open_group(pipe_hnd, mem_ctx, domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- rid, &group_pol);
+ result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,
+ domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
return result;
- result = rpccli_samr_query_groupmem(pipe_hnd, mem_ctx, &group_pol,
- &num_members, &group_rids,
- &group_attrs);
+ result = rpccli_samr_QueryGroupMember(pipe_hnd, mem_ctx,
+ &group_pol,
+ &rids);
if (!NT_STATUS_IS_OK(result))
return result;
+ num_members = rids->count;
+ group_rids = rids->rids;
+
while (num_members > 0) {
int this_time = 512;
char **names;
enum lsa_SidType *types;
int i;
+ struct lsa_SidArray sid_array;
- result = rpccli_samr_open_alias(pipe_hnd, mem_ctx, domain_pol,
- MAXIMUM_ALLOWED_ACCESS, rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
return result;
- result = rpccli_samr_query_aliasmem(pipe_hnd, mem_ctx, &alias_pol,
- &num_members, &alias_sids);
+ result = rpccli_samr_GetMembersInAlias(pipe_hnd, mem_ctx,
+ &alias_pol,
+ &sid_array);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Couldn't list alias members\n");
return result;
}
+ num_members = sid_array.num_sids;
+
if (num_members == 0) {
return NT_STATUS_OK;
}
return result;
}
+ alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members);
+ if (!alias_sids) {
+ d_fprintf(stderr, "Out of memory\n");
+ cli_rpc_pipe_close(lsa_pipe);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; i<num_members; i++) {
+ sid_copy(&alias_sids[i], sid_array.sids[i].sid);
+ }
+
result = rpccli_lsa_lookup_sids(lsa_pipe, mem_ctx, &lsa_pol, num_members,
alias_sids,
&domains, &names, &types);
uint32 num_rids, *rids, *rid_types;
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result))
return result;
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
return result;
string_to_sid(&sid_Builtin, "S-1-5-32");
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &sid_Builtin,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Couldn't find group %s\n", argv[0]);
}
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result))
return result;
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
return result;
return NT_STATUS_UNSUCCESSFUL;
}
- result = rpccli_samr_open_group(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- rids[0], &group_pol);
+ result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rids[0],
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
return result;
POLICY_HND domain_pol;
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
return result;
POLICY_HND alias_pol;
struct full_alias alias;
- DOM_SID *members;
+ struct lsa_SidArray sid_array;
int j;
- result = rpccli_samr_open_alias(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- groups[i].rid,
- &alias_pol);
+ result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ groups[i].rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_aliasmem(pipe_hnd, mem_ctx,
- &alias_pol,
- &alias.num_members,
- &members);
+ result = rpccli_samr_GetMembersInAlias(pipe_hnd, mem_ctx,
+ &alias_pol,
+ &sid_array);
if (!NT_STATUS_IS_OK(result))
goto done;
+ alias.num_members = sid_array.num_sids;
+
result = rpccli_samr_Close(pipe_hnd, mem_ctx, &alias_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
for (j = 0; j < alias.num_members; j++)
sid_copy(&alias.members[j],
- &members[j]);
+ sid_array.sids[j].sid);
}
sid_copy(&alias.sid, domain_sid);
NTSTATUS result;
POLICY_HND connect_pol;
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
POLICY_HND connect_pol, domain_pol, user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
char *acct_name;
+ struct lsa_String lsa_acct_name;
uint32 acb_info;
uint32 acct_flags=0;
uint32 user_rid;
+ uint32_t access_granted = 0;
if (argc != 2) {
d_printf("Usage: net rpc trustdom add <domain_name> <pw>\n");
/*
* Make valid trusting domain account (ie. uppercased and with '$' appended)
*/
-
+
if (asprintf(&acct_name, "%s$", argv[0]) < 0) {
return NT_STATUS_NO_MEMORY;
}
strupper_m(acct_name);
+ init_lsa_String(&lsa_acct_name, acct_name);
+
/* Get samr policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
SAMR_USER_ACCESS_GET_ATTRIBUTES |
SAMR_USER_ACCESS_SET_ATTRIBUTES;
- result = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol,
- acct_name, acb_info, acct_flags,
- &user_pol, &user_rid);
+ result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &lsa_acct_name,
+ acb_info,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get samr policy handle */
- result = rpccli_samr_connect(pipe_hnd, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
goto done;
}
- result = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
/* remove the sid */
- result = rpccli_samr_remove_sid_foreign_domain(pipe_hnd, mem_ctx, &user_pol,
- &trust_acct_sid);
-
+ result = rpccli_samr_RemoveMemberFromForeignDomain(pipe_hnd, mem_ctx,
+ &user_pol,
+ &trust_acct_sid);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Delete user */
- result = rpccli_samr_delete_dom_user(pipe_hnd, mem_ctx, &user_pol);
+ result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
talloc_destroy(mem_ctx);
return -1;
};
-
- /* SamrConnect */
- nt_status = rpccli_samr_connect(pipe_hnd, mem_ctx, SA_RIGHT_SAM_OPEN_DOMAIN,
- &connect_hnd);
+
+ /* SamrConnect2 */
+ nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ SA_RIGHT_SAM_OPEN_DOMAIN,
+ &connect_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
-
+
/* SamrOpenDomain - we have to open domain policy handle in order to be
able to enumerate accounts*/
- nt_status = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_hnd,
- SA_RIGHT_DOMAIN_ENUM_ACCOUNTS,
- queried_dom_sid, &domain_hnd);
+ nt_status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_hnd,
+ SA_RIGHT_DOMAIN_ENUM_ACCOUNTS,
+ queried_dom_sid,
+ &domain_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't open domain object. Error was %s\n",
nt_errstr(nt_status)));
goto done; \
}
+static void init_lsa_String(struct lsa_String *name, const char *s)
+{
+ name->string = s;
+}
+
+
/**
* confirm that a domain join is still valid
*
uint32 flags = 0x3e8;
char *acct_name;
const char *const_acct_name;
+ struct lsa_String lsa_acct_name;
uint32 acct_flags=0;
+ uint32_t access_granted = 0;
/* check what type of join */
if (argc >= 0) {
goto done;
}
- CHECK_RPC_ERR(rpccli_samr_connect(pipe_hnd, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- &sam_pol),
+ CHECK_RPC_ERR(rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &sam_pol),
"could not connect to SAM database");
-
- CHECK_RPC_ERR(rpccli_samr_open_domain(pipe_hnd, mem_ctx, &sam_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- domain_sid, &domain_pol),
+
+ CHECK_RPC_ERR(rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &sam_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ domain_sid,
+ &domain_pol),
"could not open domain");
/* Create domain user */
strlower_m(acct_name);
const_acct_name = acct_name;
+ init_lsa_String(&lsa_acct_name, acct_name);
+
acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
SEC_STD_WRITE_DAC | SEC_STD_DELETE |
SAMR_USER_ACCESS_SET_PASSWORD |
DEBUG(10, ("Creating account with flags: %d\n",acct_flags));
- result = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol,
- acct_name, acb_info,
- acct_flags, &user_pol,
- &user_rid);
+ result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
+ &domain_pol,
+ &lsa_acct_name,
+ acb_info,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, NT_STATUS_USER_EXISTS)) {
/* Open handle on user */
CHECK_RPC_ERR_DEBUG(
- rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- user_rid, &user_pol),
+ rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ &domain_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ user_rid,
+ &user_pol),
("could not re-open existing user %s: %s\n",
acct_name, nt_errstr(result)));
int argc, const char **argv,
int (*fn)(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1,
- SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv))
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- SAM_UNK_CTR ctr1, ctr3, ctr12;
+ union samr_DomainInfo *info1 = NULL;
+ union samr_DomainInfo *info3 = NULL;
+ union samr_DomainInfo *info12 = NULL;
int store;
ZERO_STRUCT(connect_pol);
ZERO_STRUCT(domain_pol);
/* Get sam policy handle */
-
- result = rpccli_samr_connect(pipe_hnd, mem_ctx,
- MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+
+ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ pipe_hnd->cli->desthost,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
/* Get domain policy handle */
-
- result = rpccli_samr_open_domain(pipe_hnd, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- ctx->domain_sid, &domain_pol);
+
+ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ ctx->domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_query_dom_info(pipe_hnd, mem_ctx, &domain_pol,
- 1, &ctr1);
+ result = rpccli_samr_QueryDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 1,
+ &info1);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "query_domain_info level 1 failed: %s\n",
goto done;
}
- result = rpccli_samr_query_dom_info(pipe_hnd, mem_ctx, &domain_pol,
- 3, &ctr3);
+ result = rpccli_samr_QueryDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 3,
+ &info3);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "query_domain_info level 3 failed: %s\n",
goto done;
}
- result = rpccli_samr_query_dom_info(pipe_hnd, mem_ctx, &domain_pol,
- 12, &ctr12);
+ result = rpccli_samr_QueryDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 12,
+ &info12);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "query_domain_info level 12 failed: %s\n",
goto done;
}
- store = fn(mem_ctx, ctx, &ctr1.info.inf1, &ctr3.info.inf3,
- &ctr12.info.inf12, argc, argv);
+ store = fn(mem_ctx, ctx, &info1->info1, &info3->info3,
+ &info12->info12, argc, argv);
if (store <= 0) {
/* Don't save anything */
switch (store) {
case 1:
- result = rpccli_samr_set_domain_info(pipe_hnd, mem_ctx,
- &domain_pol, 1, &ctr1);
+ result = rpccli_samr_SetDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 1,
+ info1);
break;
case 3:
- result = rpccli_samr_set_domain_info(pipe_hnd, mem_ctx,
- &domain_pol, 3, &ctr3);
+ result = rpccli_samr_SetDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 3,
+ info3);
break;
case 12:
- result = rpccli_samr_set_domain_info(pipe_hnd, mem_ctx,
- &domain_pol, 12, &ctr12);
+ result = rpccli_samr_SetDomainInfo(pipe_hnd, mem_ctx,
+ &domain_pol,
+ 12,
+ info12);
break;
default:
d_fprintf(stderr, "Got unexpected info level %d\n", store);
}
static int account_show(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 0) {
return -1;
}
- d_printf("Minimum password length: %d\n", i1->min_length_password);
- d_printf("Password history length: %d\n", i1->password_history);
+ d_printf("Minimum password length: %d\n", i1->min_password_length);
+ d_printf("Password history length: %d\n", i1->password_history_length);
d_printf("Minimum password age: ");
- if (!nt_time_is_zero(&i1->min_passwordage)) {
- time_t t = nt_time_to_unix_abs(&i1->min_passwordage);
+ if (!nt_time_is_zero((NTTIME *)&i1->min_password_age)) {
+ time_t t = nt_time_to_unix_abs((NTTIME *)&i1->min_password_age);
d_printf("%d seconds\n", (int)t);
} else {
d_printf("not set\n");
}
d_printf("Maximum password age: ");
- if (nt_time_is_set(&i1->expire)) {
- time_t t = nt_time_to_unix_abs(&i1->expire);
+ if (nt_time_is_set((NTTIME *)&i1->max_password_age)) {
+ time_t t = nt_time_to_unix_abs((NTTIME *)&i1->max_password_age);
d_printf("%d seconds\n", (int)t);
} else {
d_printf("not set\n");
}
- d_printf("Bad logon attempts: %d\n", i12->bad_attempt_lockout);
+ d_printf("Bad logon attempts: %d\n", i12->lockout_threshold);
- if (i12->bad_attempt_lockout != 0) {
+ if (i12->lockout_threshold != 0) {
d_printf("Account lockout duration: ");
- if (nt_time_is_set(&i12->duration)) {
- time_t t = nt_time_to_unix_abs(&i12->duration);
+ if (nt_time_is_set(&i12->lockout_duration)) {
+ time_t t = nt_time_to_unix_abs(&i12->lockout_duration);
d_printf("%d seconds\n", (int)t);
} else {
d_printf("not set\n");
}
d_printf("Bad password count reset after: ");
- if (nt_time_is_set(&i12->reset_count)) {
- time_t t = nt_time_to_unix_abs(&i12->reset_count);
+ if (nt_time_is_set(&i12->lockout_window)) {
+ time_t t = nt_time_to_unix_abs(&i12->lockout_window);
d_printf("%d seconds\n", (int)t);
} else {
d_printf("not set\n");
}
d_printf("Disconnect users when logon hours expire: %s\n",
- nt_time_is_zero(&i3->logout) ? "yes" : "no");
+ nt_time_is_zero(&i3->force_logoff_time) ? "yes" : "no");
d_printf("User must logon to change password: %s\n",
(i1->password_properties & 0x2) ? "yes" : "no");
}
static int account_set_badpw(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- i12->bad_attempt_lockout = atoi(argv[0]);
+ i12->lockout_threshold = atoi(argv[0]);
d_printf("Setting bad password count to %d\n",
- i12->bad_attempt_lockout);
+ i12->lockout_threshold);
return 12;
}
static int account_set_lockduration(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- unix_to_nt_time_abs(&i12->duration, atoi(argv[0]));
+ unix_to_nt_time_abs(&i12->lockout_duration, atoi(argv[0]));
d_printf("Setting lockout duration to %d seconds\n",
- (int)nt_time_to_unix_abs(&i12->duration));
+ (int)nt_time_to_unix_abs(&i12->lockout_duration));
return 12;
}
static int account_set_resetduration(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- unix_to_nt_time_abs(&i12->reset_count, atoi(argv[0]));
+ unix_to_nt_time_abs(&i12->lockout_window, atoi(argv[0]));
d_printf("Setting bad password reset duration to %d seconds\n",
- (int)nt_time_to_unix_abs(&i12->reset_count));
+ (int)nt_time_to_unix_abs(&i12->lockout_window));
return 12;
}
static int account_set_minpwage(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- unix_to_nt_time_abs(&i1->min_passwordage, atoi(argv[0]));
+ unix_to_nt_time_abs((NTTIME *)&i1->min_password_age, atoi(argv[0]));
d_printf("Setting minimum password age to %d seconds\n",
- (int)nt_time_to_unix_abs(&i1->min_passwordage));
+ (int)nt_time_to_unix_abs((NTTIME *)&i1->min_password_age));
return 1;
}
static int account_set_maxpwage(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- unix_to_nt_time_abs(&i1->expire, atoi(argv[0]));
+ unix_to_nt_time_abs((NTTIME *)&i1->max_password_age, atoi(argv[0]));
d_printf("Setting maximum password age to %d seconds\n",
- (int)nt_time_to_unix_abs(&i1->expire));
+ (int)nt_time_to_unix_abs((NTTIME *)&i1->max_password_age));
return 1;
}
static int account_set_minpwlen(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- i1->min_length_password = atoi(argv[0]);
+ i1->min_password_length = atoi(argv[0]);
d_printf("Setting minimum password length to %d\n",
- i1->min_length_password);
+ i1->min_password_length);
return 1;
}
static int account_set_pwhistlen(TALLOC_CTX *mem_ctx,
struct rpc_sh_ctx *ctx,
- SAM_UNK_INFO_1 *i1, SAM_UNK_INFO_3 *i3,
- SAM_UNK_INFO_12 *i12,
+ struct samr_DomInfo1 *i1,
+ struct samr_DomInfo3 *i3,
+ struct samr_DomInfo12 *i12,
int argc, const char **argv)
{
if (argc != 1) {
return -1;
}
- i1->password_history = atoi(argv[0]);
+ i1->password_history_length = atoi(argv[0]);
d_printf("Setting password history length to %d\n",
- i1->password_history);
+ i1->password_history_length);
return 1;
}
if (num <= 0) continue;
if (c != -1 && FD_ISSET(c, &fds)) {
- if (!receive_smb_raw(c, packet, 0, 0, NULL)) {
+ size_t len;
+ if (!NT_STATUS_IS_OK(receive_smb_raw(
+ c, packet, 0, 0, &len))) {
d_printf("client closed connection\n");
exit(0);
}
}
}
if (s != -1 && FD_ISSET(s, &fds)) {
- if (!receive_smb_raw(s, packet, 0, 0, NULL)) {
+ size_t len;
+ if (!NT_STATUS_IS_OK(receive_smb_raw(
+ s, packet, 0, 0, &len))) {
d_printf("server closed connection\n");
exit(0);
}
int lang_num, i;
/* build the lang list */
- lang_list = str_list_make(lang_string, ", \t\r\n");
+ lang_list = str_list_make(talloc_tos(), lang_string, ", \t\r\n");
if (!lang_list) return;
/* sort the list by priority */
}
pl[i].string = SMB_STRDUP(lang_list[i]);
}
- str_list_free(&lang_list);
+ TALLOC_FREE(lang_list);
qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list);
NTSTATUS (*sequence_number)(struct winbindd_domain *domain, uint32 *seq);
/* return the lockout policy */
- NTSTATUS (*lockout_policy)(struct winbindd_domain *domain,
+ NTSTATUS (*lockout_policy)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_12 *lockout_policy);
-
+ struct samr_DomInfo12 *lockout_policy);
+
/* return the lockout policy */
- NTSTATUS (*password_policy)(struct winbindd_domain *domain,
+ NTSTATUS (*password_policy)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_1 *password_policy);
-
+ struct samr_DomInfo1 *password_policy);
+
/* enumerate trusted domains */
NTSTATUS (*trusted_domains)(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
enum lsa_SidType type) =
(void (*)(void *, bool, const DOM_SID *, enum lsa_SidType))c;
DOM_SID sid;
- struct lookupname_state *s = talloc_get_type_abort( private_data,
+ struct lookupname_state *s = talloc_get_type_abort( private_data,
struct lookupname_state );
-
if (!success) {
DEBUG(5, ("Could not trigger lookup_name\n"));
}
/********************************************************************
- This is the first callback after contacting our own domain
+ This is the first callback after contacting our own domain
********************************************************************/
static void lookupname_recv(TALLOC_CTX *mem_ctx, bool success,
enum lsa_SidType type) =
(void (*)(void *, bool, const DOM_SID *, enum lsa_SidType))c;
DOM_SID sid;
- struct lookupname_state *s = talloc_get_type_abort( private_data,
+ struct lookupname_state *s = talloc_get_type_abort( private_data,
struct lookupname_state );
if (!success) {
if (response->result != WINBINDD_OK) {
/* Try again using the forest root */
struct winbindd_domain *root_domain = find_root_domain();
- struct winbindd_request request;
-
+ struct winbindd_request request;
+
if ( !root_domain ) {
DEBUG(5,("lookupname_recv: unable to determine forest root\n"));
cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
request.cmd = WINBINDD_LOOKUPNAME;
fstrcpy( request.data.name.dom_name, s->dom_name );
- fstrcpy( request.data.name.name, s->name );
+ fstrcpy( request.data.name.name, s->name );
do_async_domain(mem_ctx, root_domain, &request, lookupname_recv2,
(void *)cont, s);
{
struct winbindd_request request;
struct winbindd_domain *domain;
- struct lookupname_state *s;
+ struct lookupname_state *s;
if ( (domain = find_lookup_domain_from_name(dom_name)) == NULL ) {
DEBUG(5, ("Could not find domain for name '%s'\n", dom_name));
s->dom_name = talloc_strdup( s, dom_name );
s->name = talloc_strdup( s, name );
+ if (!s->dom_name || !s->name) {
+ cont(private_data, False, NULL, SID_NAME_UNKNOWN);
+ return;
+ }
+
s->caller_private_data = private_data;
do_async_domain(mem_ctx, domain, &request, lookupname_recv,
centry_free(centry);
}
-static void wcache_save_lockout_policy(struct winbindd_domain *domain, NTSTATUS status, SAM_UNK_INFO_12 *lockout_policy)
+static void wcache_save_lockout_policy(struct winbindd_domain *domain,
+ NTSTATUS status,
+ struct samr_DomInfo12 *lockout_policy)
{
struct cache_entry *centry;
if (!centry)
return;
- centry_put_nttime(centry, lockout_policy->duration);
- centry_put_nttime(centry, lockout_policy->reset_count);
- centry_put_uint16(centry, lockout_policy->bad_attempt_lockout);
+ centry_put_nttime(centry, lockout_policy->lockout_duration);
+ centry_put_nttime(centry, lockout_policy->lockout_window);
+ centry_put_uint16(centry, lockout_policy->lockout_threshold);
centry_end(centry, "LOC_POL/%s", domain->name);
-
+
DEBUG(10,("wcache_save_lockout_policy: %s\n", domain->name));
centry_free(centry);
}
-static void wcache_save_password_policy(struct winbindd_domain *domain, NTSTATUS status, SAM_UNK_INFO_1 *policy)
+static void wcache_save_password_policy(struct winbindd_domain *domain,
+ NTSTATUS status,
+ struct samr_DomInfo1 *policy)
{
struct cache_entry *centry;
if (!centry)
return;
- centry_put_uint16(centry, policy->min_length_password);
- centry_put_uint16(centry, policy->password_history);
+ centry_put_uint16(centry, policy->min_password_length);
+ centry_put_uint16(centry, policy->password_history_length);
centry_put_uint32(centry, policy->password_properties);
- centry_put_nttime(centry, policy->expire);
- centry_put_nttime(centry, policy->min_passwordage);
+ centry_put_nttime(centry, policy->max_password_age);
+ centry_put_nttime(centry, policy->min_password_age);
centry_end(centry, "PWD_POL/%s", domain->name);
-
+
DEBUG(10,("wcache_save_password_policy: %s\n", domain->name));
centry_free(centry);
/* get lockout policy */
static NTSTATUS lockout_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_12 *policy){
+ struct samr_DomInfo12 *policy)
+{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
NTSTATUS status;
-
+
if (!cache->tdb)
goto do_query;
-
+
centry = wcache_fetch(cache, domain, "LOC_POL/%s", domain->name);
-
+
if (!centry)
goto do_query;
-
- policy->duration = centry_nttime(centry);
- policy->reset_count = centry_nttime(centry);
- policy->bad_attempt_lockout = centry_uint16(centry);
-
+
+ policy->lockout_duration = centry_nttime(centry);
+ policy->lockout_window = centry_nttime(centry);
+ policy->lockout_threshold = centry_uint16(centry);
+
status = centry->status;
-
+
DEBUG(10,("lockout_policy: [Cached] - cached info for domain %s status: %s\n",
domain->name, nt_errstr(status) ));
-
+
centry_free(centry);
return status;
-
+
do_query:
ZERO_STRUCTP(policy);
-
+
/* Return status value returned by seq number check */
if (!NT_STATUS_IS_OK(domain->last_status))
return domain->last_status;
-
+
DEBUG(10,("lockout_policy: [Cached] - doing backend query for info for domain %s\n",
domain->name ));
-
- status = domain->backend->lockout_policy(domain, mem_ctx, policy);
-
+
+ status = domain->backend->lockout_policy(domain, mem_ctx, policy);
+
/* and save it */
refresh_sequence_number(domain, false);
wcache_save_lockout_policy(domain, status, policy);
-
+
return status;
}
-
+
/* get password policy */
static NTSTATUS password_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_1 *policy)
+ struct samr_DomInfo1 *policy)
{
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
if (!cache->tdb)
goto do_query;
-
+
centry = wcache_fetch(cache, domain, "PWD_POL/%s", domain->name);
-
+
if (!centry)
goto do_query;
- policy->min_length_password = centry_uint16(centry);
- policy->password_history = centry_uint16(centry);
+ policy->min_password_length = centry_uint16(centry);
+ policy->password_history_length = centry_uint16(centry);
policy->password_properties = centry_uint32(centry);
- policy->expire = centry_nttime(centry);
- policy->min_passwordage = centry_nttime(centry);
+ policy->max_password_age = centry_nttime(centry);
+ policy->min_password_age = centry_nttime(centry);
status = centry->status;
if (!NT_STATUS_IS_OK(domain->last_status))
return domain->last_status;
-
+
DEBUG(10,("password_policy: [Cached] - doing backend query for info for domain %s\n",
domain->name ));
- status = domain->backend->password_policy(domain, mem_ctx, policy);
+ status = domain->backend->password_policy(domain, mem_ctx, policy);
/* and save it */
refresh_sequence_number(domain, false);
"pipe: user %s\\%s\n", domain->name,
domain_name, machine_account));
- result = rpccli_samr_connect(conn->samr_pipe, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- &conn->sam_connect_handle);
+ result = rpccli_samr_Connect2(conn->samr_pipe, mem_ctx,
+ conn->samr_pipe->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &conn->sam_connect_handle);
if (NT_STATUS_IS_OK(result)) {
goto open_domain;
}
- DEBUG(10,("cm_connect_sam: ntlmssp-sealed rpccli_samr_connect "
+ DEBUG(10,("cm_connect_sam: ntlmssp-sealed rpccli_samr_Connect2 "
"failed for domain %s, error was %s. Trying schannel\n",
domain->name, nt_errstr(result) ));
cli_rpc_pipe_close(conn->samr_pipe);
DEBUG(10,("cm_connect_sam: connected to SAMR pipe for domain %s using "
"schannel.\n", domain->name ));
- result = rpccli_samr_connect(conn->samr_pipe, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- &conn->sam_connect_handle);
+ result = rpccli_samr_Connect2(conn->samr_pipe, mem_ctx,
+ conn->samr_pipe->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &conn->sam_connect_handle);
if (NT_STATUS_IS_OK(result)) {
goto open_domain;
}
- DEBUG(10,("cm_connect_sam: schannel-sealed rpccli_samr_connect failed "
+ DEBUG(10,("cm_connect_sam: schannel-sealed rpccli_samr_Connect2 failed "
"for domain %s, error was %s. Trying anonymous\n",
domain->name, nt_errstr(result) ));
cli_rpc_pipe_close(conn->samr_pipe);
goto done;
}
- result = rpccli_samr_connect(conn->samr_pipe, mem_ctx,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- &conn->sam_connect_handle);
+ result = rpccli_samr_Connect2(conn->samr_pipe, mem_ctx,
+ conn->samr_pipe->cli->desthost,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &conn->sam_connect_handle);
if (!NT_STATUS_IS_OK(result)) {
- DEBUG(10,("cm_connect_sam: rpccli_samr_connect failed "
+ DEBUG(10,("cm_connect_sam: rpccli_samr_Connect2 failed "
"for domain %s Error was %s\n",
domain->name, nt_errstr(result) ));
goto done;
}
open_domain:
- result = rpccli_samr_open_domain(conn->samr_pipe,
- mem_ctx,
- &conn->sam_connect_handle,
- SEC_RIGHTS_MAXIMUM_ALLOWED,
- &domain->sid,
- &conn->sam_domain_handle);
+ result = rpccli_samr_OpenDomain(conn->samr_pipe,
+ mem_ctx,
+ &conn->sam_connect_handle,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &domain->sid,
+ &conn->sam_domain_handle);
done:
#define DBGC_CLASS DBGC_WINBIND
extern bool override_logfile;
+extern struct winbindd_methods cache_methods;
/* Read some data from a client connection */
static void child_read_request(struct winbindd_cli_state *state)
{
- ssize_t len;
+ NTSTATUS status;
/* Read data */
- len = read_data(state->sock, (char *)&state->request,
- sizeof(state->request), NULL);
+ status = read_data(state->sock, (char *)&state->request,
+ sizeof(state->request));
- if (len != sizeof(state->request)) {
- DEBUG(len > 0 ? 0 : 3, ("Got invalid request length: %d\n", (int)len));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(3, ("child_read_request: read_data failed: %s\n",
+ nt_errstr(status)));
state->finished = True;
return;
}
/* Ensure null termination */
state->request.extra_data.data[state->request.extra_len] = '\0';
- len = read_data(state->sock, state->request.extra_data.data,
- state->request.extra_len, NULL);
+ status= read_data(state->sock, state->request.extra_data.data,
+ state->request.extra_len);
- if (len != state->request.extra_len) {
- DEBUG(0, ("Could not read extra data\n"));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Could not read extra data: %s\n",
+ nt_errstr(status)));
state->finished = True;
return;
}
(struct winbindd_child *)private_data;
TALLOC_CTX *mem_ctx = NULL;
struct winbindd_methods *methods;
- SAM_UNK_INFO_12 lockout_policy;
+ struct samr_DomInfo12 lockout_policy;
NTSTATUS result;
DEBUG(10,("account_lockout_policy_handler called\n"));
child);
}
+ /* Special case for Winbindd on a Samba DC,
+ * We want to make sure the child can connect to smbd
+ * but not the main daemon */
+
+ if (child->domain && child->domain->internal && IS_DC) {
+ child->domain->internal = False;
+ child->domain->methods = &cache_methods;
+ child->domain->online = False;
+ }
+
while (1) {
int ret;
if (IS_DC) {
domain = find_domain_from_name_noinit(domain_name);
if (domain == NULL) {
- DEBUG(3, ("Authentication for domain [%s] refused"
+ DEBUG(3, ("Authentication for domain [%s] refused "
"as it is not a trusted domain\n",
domain_name));
}
{
struct winbindd_methods *methods;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- SAM_UNK_INFO_1 password_policy;
+ struct samr_DomInfo1 password_policy;
if ( !winbindd_can_contact_domain( domain ) ) {
DEBUG(5,("fillup_password_policy: No inbound trust to "
}
state->response.data.auth.policy.min_length_password =
- password_policy.min_length_password;
+ password_policy.min_password_length;
state->response.data.auth.policy.password_history =
- password_policy.password_history;
+ password_policy.password_history_length;
state->response.data.auth.policy.password_properties =
password_policy.password_properties;
state->response.data.auth.policy.expire =
- nt_time_to_unix_abs(&(password_policy.expire));
- state->response.data.auth.policy.min_passwordage =
- nt_time_to_unix_abs(&(password_policy.min_passwordage));
+ nt_time_to_unix_abs((NTTIME *)&(password_policy.max_password_age));
+ state->response.data.auth.policy.min_passwordage =
+ nt_time_to_unix_abs((NTTIME *)&(password_policy.min_password_age));
return NT_STATUS_OK;
}
static NTSTATUS get_max_bad_attempts_from_lockout_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- uint16 *max_allowed_bad_attempts)
+ uint16 *lockout_threshold)
{
struct winbindd_methods *methods;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- SAM_UNK_INFO_12 lockout_policy;
+ struct samr_DomInfo12 lockout_policy;
- *max_allowed_bad_attempts = 0;
+ *lockout_threshold = 0;
methods = domain->methods;
return status;
}
- *max_allowed_bad_attempts = lockout_policy.bad_attempt_lockout;
+ *lockout_threshold = lockout_policy.lockout_threshold;
return NT_STATUS_OK;
}
{
struct winbindd_methods *methods;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
- SAM_UNK_INFO_1 password_policy;
+ struct samr_DomInfo1 password_policy;
*password_properties = 0;
goto done;
}
- status_tmp = rpccli_samr_open_user(samr_pipe, state->mem_ctx,
- &samr_domain_handle,
- MAXIMUM_ALLOWED_ACCESS,
- my_info3->user_rid, &user_pol);
+ status_tmp = rpccli_samr_OpenUser(samr_pipe, state->mem_ctx,
+ &samr_domain_handle,
+ MAXIMUM_ALLOWED_ACCESS,
+ my_info3->user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(status_tmp)) {
DEBUG(3, ("could not open user handle on SAMR pipe: %s\n",
static NTSTATUS lockout_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_12 *policy)
+ struct samr_DomInfo12 *policy)
{
/* actually we have that */
return NT_STATUS_NOT_IMPLEMENTED;
static NTSTATUS password_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_1 *policy)
+ struct samr_DomInfo1 *policy)
{
uint32 min_pass_len,pass_hist,password_properties;
time_t u_expire, u_min_age;
NTTIME nt_expire, nt_min_age;
uint32 account_policy_temp;
- if ((policy = TALLOC_ZERO_P(mem_ctx, SAM_UNK_INFO_1)) == NULL) {
+ if ((policy = TALLOC_ZERO_P(mem_ctx, struct samr_DomInfo1)) == NULL) {
return NT_STATUS_NO_MEMORY;
}
unix_to_nt_time_abs(&nt_expire, u_expire);
unix_to_nt_time_abs(&nt_min_age, u_min_age);
- init_unk_info1(policy, (uint16)min_pass_len, (uint16)pass_hist,
- password_properties, nt_expire, nt_min_age);
+ init_samr_DomInfo1(policy,
+ (uint16)min_pass_len,
+ (uint16)pass_hist,
+ password_properties,
+ nt_expire,
+ nt_min_age);
return NT_STATUS_OK;
}
/* find the lockout policy of a domain */
static NTSTATUS lockout_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_12 *policy)
+ struct samr_DomInfo12 *policy)
{
NTSTATUS result;
/* find the password policy of a domain */
static NTSTATUS password_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_1 *policy)
+ struct samr_DomInfo1 *policy)
{
NTSTATUS result;
return result;
/* Get user handle */
- result = rpccli_samr_open_user(cli, mem_ctx, &dom_pol,
- SEC_RIGHTS_MAXIMUM_ALLOWED, user_rid,
- &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &dom_pol,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
return result;
return result;
/* Get user handle */
- result = rpccli_samr_open_user(cli, mem_ctx, &dom_pol,
- des_access, user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &dom_pol,
+ des_access,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
return result;
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND dom_pol;
- DOM_SID2 *query_sids;
uint32 num_query_sids = 0;
int i;
struct rpc_pipe_client *cli;
- uint32 *alias_rids_query, num_aliases_query;
+ struct samr_Ids alias_rids_query;
int rangesize = MAX_SAM_ENTRIES_W2K;
uint32 total_sids = 0;
int num_queries = 1;
do {
/* prepare query */
+ struct lsa_SidArray sid_array;
+
+ ZERO_STRUCT(sid_array);
num_query_sids = MIN(num_sids - total_sids, rangesize);
num_queries, num_query_sids));
if (num_query_sids) {
- query_sids = TALLOC_ARRAY(mem_ctx, DOM_SID2, num_query_sids);
- if (query_sids == NULL) {
+ sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_query_sids);
+ if (sid_array.sids == NULL) {
return NT_STATUS_NO_MEMORY;
}
} else {
- query_sids = NULL;
+ sid_array.sids = NULL;
}
for (i=0; i<num_query_sids; i++) {
- sid_copy(&query_sids[i].sid, &sids[total_sids++]);
- query_sids[i].num_auths = query_sids[i].sid.num_auths;
+ sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[total_sids++]);
+ if (sid_array.sids[i].sid) {
+ TALLOC_FREE(sid_array.sids);
+ return NT_STATUS_NO_MEMORY;
+ }
}
+ sid_array.num_sids = num_query_sids;
/* do request */
-
- result = rpccli_samr_query_useraliases(cli, mem_ctx, &dom_pol,
- num_query_sids, query_sids,
- &num_aliases_query,
- &alias_rids_query);
+ result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
+ &dom_pol,
+ &sid_array,
+ &alias_rids_query);
if (!NT_STATUS_IS_OK(result)) {
*num_aliases = 0;
*alias_rids = NULL;
- TALLOC_FREE(query_sids);
+ TALLOC_FREE(sid_array.sids);
goto done;
}
/* process output */
- for (i=0; i<num_aliases_query; i++) {
+ for (i=0; i<alias_rids_query.count; i++) {
size_t na = *num_aliases;
- if (!add_rid_to_array_unique(mem_ctx, alias_rids_query[i],
+ if (!add_rid_to_array_unique(mem_ctx, alias_rids_query.ids[i],
alias_rids, &na)) {
return NT_STATUS_NO_MEMORY;
}
*num_aliases = na;
}
- TALLOC_FREE(query_sids);
+ TALLOC_FREE(sid_array.sids);
num_queries++;
unsigned int j;
struct rpc_pipe_client *cli;
unsigned int orig_timeout;
+ struct samr_RidTypeArray *rids = NULL;
DEBUG(10,("rpc: lookup_groupmem %s sid=%s\n", domain->name,
sid_string_dbg(group_sid)));
if (!NT_STATUS_IS_OK(result))
return result;
- result = rpccli_samr_open_group(cli, mem_ctx, &dom_pol,
- des_access, group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &dom_pol,
+ des_access,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
return result;
orig_timeout = cli_set_timeout(cli->cli, 35000);
- result = rpccli_samr_query_groupmem(cli, mem_ctx,
- &group_pol, num_names, &rid_mem,
- name_types);
+ result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
+ &group_pol,
+ &rids);
/* And restore our original timeout. */
cli_set_timeout(cli->cli, orig_timeout);
if (!NT_STATUS_IS_OK(result))
return result;
+ *num_names = rids->count;
+ rid_mem = rids->rids;
+
if (!*num_names) {
names = NULL;
name_types = NULL;
static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
{
TALLOC_CTX *mem_ctx;
- SAM_UNK_CTR ctr;
+ union samr_DomainInfo *info = NULL;
NTSTATUS result;
POLICY_HND dom_pol;
bool got_seq_num = False;
/* Query domain info */
- result = rpccli_samr_query_dom_info(cli, mem_ctx, &dom_pol, 8, &ctr);
+ result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
+ &dom_pol,
+ 8,
+ &info);
if (NT_STATUS_IS_OK(result)) {
- *seq = ctr.info.inf8.seq_num;
+ *seq = info->info8.sequence_num;
got_seq_num = True;
goto seq_num;
}
/* retry with info-level 2 in case the dc does not support info-level 8
- * (like all older samba2 and samba3 dc's - Guenther */
+ * (like all older samba2 and samba3 dc's) - Guenther */
+
+ result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
+ &dom_pol,
+ 2,
+ &info);
- result = rpccli_samr_query_dom_info(cli, mem_ctx, &dom_pol, 2, &ctr);
-
if (NT_STATUS_IS_OK(result)) {
- *seq = ctr.info.inf2.seq_num;
+ *seq = info->info2.sequence_num;
got_seq_num = True;
}
}
/* find the lockout policy for a domain */
-NTSTATUS msrpc_lockout_policy(struct winbindd_domain *domain,
+NTSTATUS msrpc_lockout_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_12 *lockout_policy)
+ struct samr_DomInfo12 *lockout_policy)
{
NTSTATUS result;
struct rpc_pipe_client *cli;
POLICY_HND dom_pol;
- SAM_UNK_CTR ctr;
+ union samr_DomainInfo *info = NULL;
DEBUG(10,("rpc: fetch lockout policy for %s\n", domain->name));
goto done;
}
- result = rpccli_samr_query_dom_info(cli, mem_ctx, &dom_pol, 12, &ctr);
+ result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
+ &dom_pol,
+ 12,
+ &info);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- *lockout_policy = ctr.info.inf12;
+ *lockout_policy = info->info12;
- DEBUG(10,("msrpc_lockout_policy: bad_attempt_lockout %d\n",
- ctr.info.inf12.bad_attempt_lockout));
+ DEBUG(10,("msrpc_lockout_policy: lockout_threshold %d\n",
+ info->info12.lockout_threshold));
done:
}
/* find the password policy for a domain */
-NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
+NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
- SAM_UNK_INFO_1 *password_policy)
+ struct samr_DomInfo1 *password_policy)
{
NTSTATUS result;
struct rpc_pipe_client *cli;
POLICY_HND dom_pol;
- SAM_UNK_CTR ctr;
+ union samr_DomainInfo *info = NULL;
DEBUG(10,("rpc: fetch password policy for %s\n", domain->name));
goto done;
}
- result = rpccli_samr_query_dom_info(cli, mem_ctx, &dom_pol, 1, &ctr);
+ result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
+ &dom_pol,
+ 1,
+ &info);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- *password_policy = ctr.info.inf1;
+ *password_policy = info->info1;
- DEBUG(10,("msrpc_password_policy: min_length_password %d\n",
- ctr.info.inf1.min_length_password));
+ DEBUG(10,("msrpc_password_policy: min_length_password %d\n",
+ info->info1.min_password_length));
done:
if (sid == NULL)
return False;
- if ( IS_DC )
- return sid_check_is_builtin(sid);
-
return (sid_check_is_domain(sid) || sid_check_is_builtin(sid));
}
if (sid == NULL)
return False;
- if ( IS_DC )
- return sid_check_is_in_builtin(sid);
-
return (sid_check_is_in_our_domain(sid) || sid_check_is_in_builtin(sid));
}