summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in5
-rw-r--r--source3/include/proto.h143
-rw-r--r--source3/include/smb.h3
-rw-r--r--source3/lib/time.c12
-rw-r--r--source3/rpc_client/cli_samr.c72
-rw-r--r--source3/rpc_parse/parse_misc.c54
-rw-r--r--source3/rpc_parse/parse_samr.c440
-rw-r--r--source3/rpcclient/cmd_samr.c180
-rw-r--r--source3/rpcclient/display.c104
-rw-r--r--source3/rpcclient/rpcclient.c4
10 files changed, 839 insertions, 178 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 420a90d59e..3df658a5d6 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -114,7 +114,7 @@ RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_misc.o \
RPC_CLIENT_OBJ = rpc_client/cli_login.o rpc_client/cli_netlogon.o \
rpc_client/cli_pipe.o rpc_client/cli_lsarpc.o \
- rpc_client/cli_wkssvc.o
+ rpc_client/cli_wkssvc.o rpc_client/cli_samr.o
LOCKING_OBJ = locking/locking.o locking/locking_shm.o locking/locking_slow.o \
locking/shmem.o locking/shmem_sysv.o
@@ -179,12 +179,13 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
$(UBIQX_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(LIB_OBJ)
RPCCLIENT_OBJ = rpcclient/rpcclient.o \
+ rpcclient/display.o \
rpcclient/cmd_lsarpc.o \
rpcclient/cmd_wkssvc.o \
+ rpcclient/cmd_samr.o \
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
$(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ)
# rpcclient/cmd_netlogon.o \
-# rpcclient/cmd_samr.o \
# rpcclient/cmd_srvsvc.o \
CLIENT_OBJ = client/client.o client/clientutil.o client/clitar.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9d2f3a30a7..5c3dbc003b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -190,6 +190,7 @@ void GetTimeOfDay(struct timeval *tval);
void TimeInit(void);
int TimeDiff(time_t t);
struct tm *LocalTime(time_t *t);
+time_t interpret_nt_time(NTTIME *t);
time_t interpret_long_date(char *p);
void put_long_date(char *p,time_t t);
BOOL null_mtime(time_t mtime);
@@ -1213,6 +1214,42 @@ BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num,
BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, BOOL encrypted);
void cli_nt_session_close(struct cli_state *cli);
+/*The following definitions come from rpc_client/cli_samr.c */
+
+BOOL get_samr_query_usergroups(struct cli_state *cli,
+ POLICY_HND *pol_open_domain, uint32 user_rid,
+ uint32 *num_groups, DOM_GID *gid);
+BOOL get_samr_query_userinfo(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 info_level,
+ uint32 user_rid, SAM_USER_INFO_21 *usr);
+BOOL do_samr_unknown_8(struct cli_state *cli,
+ POLICY_HND *domain_pol, uint16 switch_value);
+BOOL do_samr_enum_dom_users(struct cli_state *cli,
+ POLICY_HND *pol, uint16 num_entries, uint16 unk_0,
+ uint16 acb_mask, uint16 unk_1, uint32 size,
+ struct acct_info sam[MAX_SAM_ENTRIES],
+ int *num_sam_users);
+BOOL do_samr_connect(struct cli_state *cli,
+ char *srv_name, uint32 unknown_0,
+ POLICY_HND *connect_pol);
+BOOL do_samr_open_user(struct cli_state *cli,
+ POLICY_HND *pol, uint32 unk_0, uint32 rid,
+ POLICY_HND *user_pol);
+BOOL do_samr_open_domain(struct cli_state *cli,
+ POLICY_HND *connect_pol, uint32 rid, DOM_SID *sid,
+ POLICY_HND *domain_pol);
+BOOL do_samr_query_unknown_12(struct cli_state *cli,
+ POLICY_HND *pol, uint32 rid, uint32 num_gids, uint32 *gids,
+ uint32 *num_aliases,
+ fstring als_names [MAX_LOOKUP_SIDS],
+ uint32 num_als_users[MAX_LOOKUP_SIDS]);
+BOOL do_samr_query_usergroups(struct cli_state *cli,
+ POLICY_HND *pol, uint32 *num_groups, DOM_GID *gid);
+BOOL do_samr_query_userinfo(struct cli_state *cli,
+ POLICY_HND *pol, uint16 switch_value, void* usr);
+BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd);
+
/*The following definitions come from rpc_client/cli_wkssvc.c */
BOOL do_wks_query_info(struct cli_state *cli,
@@ -1252,6 +1289,7 @@ uint32 get_enum_hnd(ENUM_HND *enh);
void make_enum_hnd(ENUM_HND *enh, uint32 hnd);
void smb_io_enum_hnd(char *desc, ENUM_HND *hnd, prs_struct *ps, int depth);
void smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth);
+void make_dom_sid(DOM_SID *sid, char *str_sid);
void make_dom_sid2(DOM_SID2 *sid2, DOM_SID *sid);
void smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth);
void make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer);
@@ -1440,11 +1478,20 @@ void smb_io_rpc_auth_ntlmssp_resp(char *desc, RPC_AUTH_NTLMSSP_RESP *rsp, prs_st
/*The following definitions come from rpc_parse/parse_samr.c */
+void make_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd);
void samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth);
void samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int depth);
+void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u,
+ POLICY_HND *connect_pol, uint32 rid,
+ DOM_SID *sid);
void samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth);
void samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps, int depth);
+void make_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
+ POLICY_HND *user_pol, uint16 switch_value);
void samr_io_q_unknown_3(char *desc, SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int depth);
+void make_samr_q_unknown_8(SAMR_Q_UNKNOWN_8 *q_u,
+ POLICY_HND *domain_pol, uint16 switch_value);
+void samr_io_q_unknown_8(char *desc, SAMR_Q_UNKNOWN_8 *q_u, prs_struct *ps, int depth);
void make_dom_sid3(DOM_SID3 *sid3, uint16 unk_0, uint16 unk_1, DOM_SID *sid);
void make_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
uint16 unknown_2, uint16 unknown_3,
@@ -1452,16 +1499,22 @@ void make_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS],
uint32 status);
void samr_io_r_unknown_3(char *desc, SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int depth);
+void make_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
+ uint16 req_num_entries, uint16 unk_0,
+ uint16 acb_mask, uint16 unk_1, uint32 size);
void samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth);
void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
uint16 total_num_entries, uint16 unk_0,
uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status);
void samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth);
+void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size);
void samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth);
void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
uint32 num_sam_entries, SAM_USER_INFO_21 grps[MAX_SAM_ENTRIES],
uint32 status);
void samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth);
+void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx, uint32 size);
void samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth);
void make_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
uint32 start_idx, uint32 num_sam_entries,
@@ -1472,12 +1525,17 @@ void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
void make_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status);
void samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth);
+void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx, uint32 size);
void samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth);
void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
uint32 start_idx, uint32 num_sam_entries,
SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES],
uint32 status);
void samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth);
+void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
+ POLICY_HND *pol,
+ uint16 switch_level);
void samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth);
void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u,
uint16 switch_value, char *acct_desc,
@@ -1496,12 +1554,19 @@ void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
uint32 num_aliases, fstring *als_name, uint32 *num_als_usrs,
uint32 status);
void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth);
+void make_samr_q_open_user(SAMR_Q_OPEN_USER *q_u,
+ POLICY_HND *pol,
+ uint32 unk_0, uint32 rid);
void samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER *q_u, prs_struct *ps, int depth);
void samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER *r_u, prs_struct *ps, int depth);
+void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
+ POLICY_HND *hnd);
void samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth);
void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
uint32 num_gids, DOM_GID *gid, uint32 status);
void samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth);
+void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
+ POLICY_HND *hnd, uint16 switch_value);
void samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth);
void make_sam_user_info21(SAM_USER_INFO_21 *usr,
@@ -1537,10 +1602,28 @@ void make_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO *r_u,
void samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO *r_u, prs_struct *ps, int depth);
void samr_io_q_unknown_32(char *desc, SAMR_Q_UNKNOWN_32 *q_u, prs_struct *ps, int depth);
void samr_io_r_unknown_32(char *desc, SAMR_R_UNKNOWN_32 *r_u, prs_struct *ps, int depth);
+void make_samr_q_connect(SAMR_Q_CONNECT *q_u,
+ char *srv_name, uint32 unknown_0);
void samr_io_q_connect(char *desc, SAMR_Q_CONNECT *q_u, prs_struct *ps, int depth);
void samr_io_r_connect(char *desc, SAMR_R_CONNECT *r_u, prs_struct *ps, int depth);
+void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
+ uint32 unknown_0, uint32 rid);
void samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth);
void samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth);
+void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name);
+void samr_io_q_unknown_38(char *desc, SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth);
+void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u,
+ uint16 level, uint32 status);
+void samr_io_r_unknown_38(char *desc, SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth);
+void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth);
+void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth);
+void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
+ POLICY_HND *pol, uint32 rid,
+ uint32 num_gids, uint32 *gid);
+void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
+ POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
+void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
+ POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
/*The following definitions come from rpc_parse/parse_srv.c */
@@ -1681,10 +1764,70 @@ BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data);
void cmd_lsa_query_info(struct client_info *info);
+/*The following definitions come from rpcclient/cmd_samr.c */
+
+void cmd_sam_test(struct client_info *info);
+void cmd_sam_enum_users(struct client_info *info);
+void cmd_sam_query_user(struct client_info *info);
+void cmd_sam_query_groups(struct client_info *info);
+void cmd_sam_enum_aliases(struct client_info *info);
+
/*The following definitions come from rpcclient/cmd_wkssvc.c */
void cmd_wks_query_info(struct client_info *info);
+/*The following definitions come from rpcclient/display.c */
+
+char *get_file_mode_str(uint32 share_mode);
+char *get_file_oplock_str(uint32 op_type);
+char *get_share_type_str(uint32 type);
+char *get_server_type_str(uint32 type);
+void display_srv_info_101(FILE *out_hnd, enum action_type action,
+ SRV_INFO_101 *sv101);
+void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *sv102);
+void display_srv_info_ctr(FILE *out_hnd, enum action_type action,SRV_INFO_CTR *ctr);
+void display_conn_info_0(FILE *out_hnd, enum action_type action,
+ CONN_INFO_0 *info0);
+void display_conn_info_1(FILE *out_hnd, enum action_type action,
+ CONN_INFO_1 *info1, CONN_INFO_1_STR *str1);
+void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_0 *ctr);
+void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_1 *ctr);
+void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_CTR *ctr);
+void display_share_info_1(FILE *out_hnd, enum action_type action,
+ SH_INFO_1 *info1, SH_INFO_1_STR *str1);
+void display_share_info_2(FILE *out_hnd, enum action_type action,
+ SH_INFO_2 *info2, SH_INFO_2_STR *str2);
+void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_1 *ctr);
+void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_2 *ctr);
+void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_CTR *ctr);
+void display_file_info_3(FILE *out_hnd, enum action_type action,
+ FILE_INFO_3 *info3, FILE_INFO_3_STR *str3);
+void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
+ SRV_FILE_INFO_3 *ctr);
+void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_FILE_INFO_CTR *ctr);
+void display_server(FILE *out_hnd, enum action_type action,
+ char *sname, uint32 type, char *comment);
+void display_share(FILE *out_hnd, enum action_type action,
+ char *sname, uint32 type, char *comment);
+void display_share2(FILE *out_hnd, enum action_type action,
+ char *sname, uint32 type, char *comment,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ char *path, char *passwd);
+void display_name(FILE *out_hnd, enum action_type action,
+ char *sname);
+void display_group_rid_info(FILE *out_hnd, enum action_type action,
+ uint32 num_gids, DOM_GID *gid);
+void display_alias_name_info(FILE *out_hnd, enum action_type action,
+ uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs);
+void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *usr);
+
/*The following definitions come from rpcclient/rpcclient.c */
void rpcclient_init(void);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 59a7a07e76..cc62234268 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1401,6 +1401,9 @@ enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMB
/* case handling */
enum case_handling {CASE_LOWER,CASE_UPPER};
+/* display info */
+enum action_type { ACTION_HEADER, ACTION_ENUMERATE, ACTION_FOOTER };
+
#ifdef WITH_SSL
/* SSL version options */
enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
diff --git a/source3/lib/time.c b/source3/lib/time.c
index 7b7ca51204..89a83ebfc1 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -236,6 +236,17 @@ struct tm *LocalTime(time_t *t)
return(gmtime(&t2));
}
+/****************************************************************************
+take an NTTIME structure, containing high / low time. convert to unix time.
+lkclXXXX this may need 2 SIVALs not a memcpy. we'll see...
+****************************************************************************/
+time_t interpret_nt_time(NTTIME *t)
+{
+ char data[8];
+ memcpy(data, t, sizeof(data));
+ return interpret_long_date(data);
+}
+
#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
@@ -532,3 +543,4 @@ time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs)
*/
return ret;
}
+
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 7089cd09fa..158270ca2e 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -36,7 +36,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
do a SAMR query user groups
****************************************************************************/
-BOOL get_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL get_samr_query_usergroups(struct cli_state *cli,
POLICY_HND *pol_open_domain, uint32 user_rid,
uint32 *num_groups, DOM_GID *gid)
{
@@ -44,7 +44,7 @@ BOOL get_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
if (pol_open_domain == NULL || num_groups == NULL || gid == NULL) return False;
/* send open domain (on user sid) */
- if (!do_samr_open_user(cli, t_idx, fnum,
+ if (!do_samr_open_user(cli,
pol_open_domain,
0x02011b, user_rid,
&pol_open_user))
@@ -53,20 +53,20 @@ BOOL get_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
}
/* send user groups query */
- if (!do_samr_query_usergroups(cli, t_idx, fnum,
+ if (!do_samr_query_usergroups(cli,
&pol_open_user,
num_groups, gid))
{
DEBUG(5,("do_samr_query_usergroups: error in query user groups\n"));
}
- return do_samr_close(cli, t_idx, fnum, &pol_open_user);
+ return do_samr_close(cli, &pol_open_user);
}
/****************************************************************************
do a SAMR query user info
****************************************************************************/
-BOOL get_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL get_samr_query_userinfo(struct cli_state *cli,
POLICY_HND *pol_open_domain,
uint32 info_level,
uint32 user_rid, SAM_USER_INFO_21 *usr)
@@ -77,7 +77,7 @@ BOOL get_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
bzero(usr, sizeof(*usr));
/* send open domain (on user sid) */
- if (!do_samr_open_user(cli, t_idx, fnum,
+ if (!do_samr_open_user(cli,
pol_open_domain,
0x02011b, user_rid,
&pol_open_user))
@@ -86,7 +86,7 @@ BOOL get_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
}
/* send user info query */
- if (!do_samr_query_userinfo(cli, t_idx, fnum,
+ if (!do_samr_query_userinfo(cli,
&pol_open_user,
info_level, (void*)usr))
{
@@ -94,13 +94,13 @@ BOOL get_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
info_level));
}
- return do_samr_close(cli, t_idx, fnum, &pol_open_user);
+ return do_samr_close(cli, &pol_open_user);
}
/****************************************************************************
do a SAMR unknown 0x8 command
****************************************************************************/
-BOOL do_samr_unknown_8(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_unknown_8(struct cli_state *cli,
POLICY_HND *domain_pol, uint16 switch_value)
{
prs_struct data;
@@ -116,7 +116,7 @@ BOOL do_samr_unknown_8(struct cli_state *cli, int t_idx, uint16 fnum,
DEBUG(4,("SAMR Unknown 8 switch:%d\n", switch_value));
- if (domain_pol == NULL || fnum == 0xffff) return False;
+ if (domain_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_unknown_8(&q_e, domain_pol, switch_value);
@@ -125,7 +125,7 @@ BOOL do_samr_unknown_8(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_unknown_8("", &q_e, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_UNKNOWN_8, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_UNKNOWN_8, &data, &rdata))
{
#if 0
@@ -158,7 +158,7 @@ BOOL do_samr_unknown_8(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR enumerate users
****************************************************************************/
-BOOL do_samr_enum_dom_users(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_enum_dom_users(struct cli_state *cli,
POLICY_HND *pol, uint16 num_entries, uint16 unk_0,
uint16 acb_mask, uint16 unk_1, uint32 size,
struct acct_info sam[MAX_SAM_ENTRIES],
@@ -177,7 +177,7 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli, int t_idx, uint16 fnum,
DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
- if (pol == NULL || sam == NULL || num_sam_users == NULL || fnum == 0xffff) return False;
+ if (pol == NULL || sam == NULL || num_sam_users == NULL || cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_enum_dom_users(&q_e, pol,
@@ -188,7 +188,7 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_enum_dom_users("", &q_e, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_ENUM_DOM_USERS, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_ENUM_DOM_USERS, &data, &rdata))
{
SAMR_R_ENUM_DOM_USERS r_e;
BOOL p;
@@ -245,7 +245,7 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Connect
****************************************************************************/
-BOOL do_samr_connect(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_connect(struct cli_state *cli,
char *srv_name, uint32 unknown_0,
POLICY_HND *connect_pol)
{
@@ -263,7 +263,7 @@ BOOL do_samr_connect(struct cli_state *cli, int t_idx, uint16 fnum,
DEBUG(4,("SAMR Open Policy server:%s undoc value:%x\n",
srv_name, unknown_0));
- if (srv_name == NULL || connect_pol == NULL || fnum == 0xffff) return False;
+ if (srv_name == NULL || connect_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_connect(&q_o, srv_name, unknown_0);
@@ -272,7 +272,7 @@ BOOL do_samr_connect(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_connect("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_CONNECT, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_CONNECT, &data, &rdata))
{
SAMR_R_CONNECT r_o;
BOOL p;
@@ -303,7 +303,7 @@ BOOL do_samr_connect(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Open User
****************************************************************************/
-BOOL do_samr_open_user(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_open_user(struct cli_state *cli,
POLICY_HND *pol, uint32 unk_0, uint32 rid,
POLICY_HND *user_pol)
{
@@ -321,7 +321,7 @@ BOOL do_samr_open_user(struct cli_state *cli, int t_idx, uint16 fnum,
DEBUG(4,("SAMR Open User. unk_0: %08x RID:%x\n",
unk_0, rid));
- if (pol == NULL || user_pol == NULL || fnum == 0xffff) return False;
+ if (pol == NULL || user_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_open_user(&q_o, pol, unk_0, rid);
@@ -330,7 +330,7 @@ BOOL do_samr_open_user(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_open_user("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_OPEN_USER, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_OPEN_USER, &data, &rdata))
{
SAMR_R_OPEN_USER r_o;
BOOL p;
@@ -361,10 +361,11 @@ BOOL do_samr_open_user(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Open Domain
****************************************************************************/
-BOOL do_samr_open_domain(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_open_domain(struct cli_state *cli,
POLICY_HND *connect_pol, uint32 rid, DOM_SID *sid,
POLICY_HND *domain_pol)
{
+ pstring sid_str;
prs_struct data;
prs_struct rdata;
@@ -376,9 +377,10 @@ BOOL do_samr_open_domain(struct cli_state *cli, int t_idx, uint16 fnum,
prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
- DEBUG(4,("SAMR Open Domain. SID:%s RID:%x\n", sid, rid));
+ sid_to_string(sid_str, sid);
+ DEBUG(4,("SAMR Open Domain. SID:%s RID:%x\n", sid_str, rid));
- if (connect_pol == NULL || sid == NULL || domain_pol == NULL || fnum == 0xffff) return False;
+ if (connect_pol == NULL || sid == NULL || domain_pol == NULL || cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_open_domain(&q_o, connect_pol, rid, sid);
@@ -387,7 +389,7 @@ BOOL do_samr_open_domain(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_open_domain("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_OPEN_DOMAIN, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_OPEN_DOMAIN, &data, &rdata))
{
SAMR_R_OPEN_DOMAIN r_o;
BOOL p;
@@ -418,7 +420,7 @@ BOOL do_samr_open_domain(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Query Unknown 12
****************************************************************************/
-BOOL do_samr_query_unknown_12(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_query_unknown_12(struct cli_state *cli,
POLICY_HND *pol, uint32 rid, uint32 num_gids, uint32 *gids,
uint32 *num_aliases,
fstring als_names [MAX_LOOKUP_SIDS],
@@ -439,7 +441,7 @@ BOOL do_samr_query_unknown_12(struct cli_state *cli, int t_idx, uint16 fnum,
if (pol == NULL || rid == 0 || num_gids == 0 || gids == NULL ||
num_aliases == NULL || als_names == NULL || num_als_users == NULL ||
- fnum == 0xffff) return False;
+ cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_unknown_12(&q_o, pol, rid, num_gids, gids);
@@ -448,7 +450,7 @@ BOOL do_samr_query_unknown_12(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_unknown_12("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_UNKNOWN_12, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_UNKNOWN_12, &data, &rdata))
{
SAMR_R_UNKNOWN_12 r_o;
BOOL p;
@@ -503,7 +505,7 @@ BOOL do_samr_query_unknown_12(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Query User Groups
****************************************************************************/
-BOOL do_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_query_usergroups(struct cli_state *cli,
POLICY_HND *pol, uint32 *num_groups, DOM_GID *gid)
{
prs_struct data;
@@ -519,7 +521,7 @@ BOOL do_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
DEBUG(4,("SAMR Query User Groups.\n"));
- if (pol == NULL || gid == NULL || num_groups == 0|| fnum == 0xffff) return False;
+ if (pol == NULL || gid == NULL || num_groups == 0|| cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_query_usergroups(&q_o, pol);
@@ -528,7 +530,7 @@ BOOL do_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_query_usergroups("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_QUERY_USERGROUPS, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_QUERY_USERGROUPS, &data, &rdata))
{
SAMR_R_QUERY_USERGROUPS r_o;
BOOL p;
@@ -563,7 +565,7 @@ BOOL do_samr_query_usergroups(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Query User Info
****************************************************************************/
-BOOL do_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
+BOOL do_samr_query_userinfo(struct cli_state *cli,
POLICY_HND *pol, uint16 switch_value, void* usr)
{
prs_struct data;
@@ -579,7 +581,7 @@ BOOL do_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
DEBUG(4,("SAMR Query User Info. level: %d\n", switch_value));
- if (pol == NULL || usr == NULL || switch_value == 0|| fnum == 0xffff) return False;
+ if (pol == NULL || usr == NULL || switch_value == 0|| cli->nt_pipe_fnum == 0xffff) return False;
/* store the parameters */
make_samr_q_query_userinfo(&q_o, pol, switch_value);
@@ -588,7 +590,7 @@ BOOL do_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
samr_io_q_query_userinfo("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_QUERY_USERINFO, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_QUERY_USERINFO, &data, &rdata))
{
SAMR_R_QUERY_USERINFO r_o;
BOOL p;
@@ -627,7 +629,7 @@ BOOL do_samr_query_userinfo(struct cli_state *cli, int t_idx, uint16 fnum,
/****************************************************************************
do a SAMR Close
****************************************************************************/
-BOOL do_samr_close(struct cli_state *cli, int t_idx, uint16 fnum, POLICY_HND *hnd)
+BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
{
prs_struct data;
prs_struct rdata;
@@ -651,7 +653,7 @@ BOOL do_samr_close(struct cli_state *cli, int t_idx, uint16 fnum, POLICY_HND *hn
samr_io_q_close_hnd("", &q_c, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, t_idx, fnum, SAMR_CLOSE_HND, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_CLOSE_HND, &data, &rdata))
{
SAMR_R_CLOSE_HND r_c;
BOOL p;
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 3749827860..5144ef8c31 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -146,6 +146,60 @@ void smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
}
/*******************************************************************
+creates a DOM_SID structure.
+
+BIG NOTE: this function only does SIDS where the identauth is not >= 2^32
+identauth >= 2^32 can be detected because it will be specified in hex
+
+********************************************************************/
+void make_dom_sid(DOM_SID *sid, char *str_sid)
+{
+ pstring domsid;
+ int identauth;
+ char *p;
+
+ if (sid == NULL) return;
+
+ if (domsid == NULL)
+ {
+ DEBUG(4,("netlogon domain SID: none\n"));
+ sid->sid_rev_num = 0;
+ sid->num_auths = 0;
+ return;
+ }
+
+ pstrcpy(domsid, str_sid);
+
+ DEBUG(4,("make_dom_sid %d SID: %s\n", __LINE__, domsid));
+
+ /* assume, but should check, that domsid starts "S-" */
+ p = strtok(domsid+2,"-");
+ sid->sid_rev_num = atoi(p);
+
+ /* identauth in decimal should be < 2^32 */
+ /* identauth in hex should be >= 2^32 */
+ identauth = atoi(strtok(0,"-"));
+
+ DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num));
+ DEBUG(4,("netlogon %s ia %d\n", p, identauth));
+
+ sid->id_auth[0] = 0;
+ sid->id_auth[1] = 0;
+ sid->id_auth[2] = (identauth & 0xff000000) >> 24;
+ sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
+ sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
+ sid->id_auth[5] = (identauth & 0x000000ff);
+
+ sid->num_auths = 0;
+
+ while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS)
+ {
+ sid->sub_auths[sid->num_auths++] = atoi(p);
+ }
+
+ DEBUG(4,("make_dom_sid: %d SID: %s\n", __LINE__, domsid));
+}
+/*******************************************************************
creates a DOM_SID2 structure.
********************************************************************/
void make_dom_sid2(DOM_SID2 *sid2, DOM_SID *sid)
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 615a716eea..4454d74fe8 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -28,6 +28,18 @@ extern int DEBUGLEVEL;
/*******************************************************************
+makes a SAMR_Q_CLOSE_HND structure.
+********************************************************************/
+void make_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_close_hnd\n"));
+
+ memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
+}
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
void samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth)
@@ -65,6 +77,22 @@ void samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u,
+ POLICY_HND *connect_pol, uint32 rid,
+ DOM_SID *sid)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_open_domain\n"));
+
+ memcpy(&q_u->connect_pol, connect_pol, sizeof(q_u->connect_pol));
+ q_u->rid = rid;
+ make_dom_sid2(&(q_u->dom_sid), sid);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
void samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return;
@@ -102,6 +130,20 @@ void samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps,
prs_uint32("status", ps, depth, &(r_u->status));
}
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
+ POLICY_HND *user_pol, uint16 switch_value)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_unknown_3\n"));
+
+ memcpy(&q_u->user_pol, user_pol, sizeof(q_u->user_pol));
+ q_u->switch_value = switch_value;
+}
+
/*******************************************************************
reads or writes a structure.
@@ -123,6 +165,38 @@ void samr_io_q_unknown_3(char *desc, SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int
}
/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_samr_q_unknown_8(SAMR_Q_UNKNOWN_8 *q_u,
+ POLICY_HND *domain_pol, uint16 switch_value)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_unknown_8\n"));
+
+ memcpy(&q_u->domain_pol, domain_pol, sizeof(q_u->domain_pol));
+ q_u->switch_value = switch_value;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_8(char *desc, SAMR_Q_UNKNOWN_8 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_8");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("domain_pol", &(q_u->domain_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
+ prs_align(ps);
+}
+/*******************************************************************
makes a DOM_SID3 structure.
calculate length by adding up the size of the components.
@@ -533,6 +607,26 @@ static void sam_io_sam_entry(char *desc, SAM_ENTRY *sam, prs_struct *ps, int de
/*******************************************************************
+makes a SAMR_Q_ENUM_DOM_USERS structure.
+********************************************************************/
+void make_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
+ uint16 req_num_entries, uint16 unk_0,
+ uint16 acb_mask, uint16 unk_1, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_enum_dom_users\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->req_num_entries = req_num_entries; /* zero indicates lots */
+ q_e->unknown_0 = unk_0; /* this gets returned in the response */
+ q_e->acb_mask = acb_mask;
+ q_e->unknown_1 = unk_1;
+ q_e->max_size = size;
+}
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
void samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth)
@@ -661,6 +755,21 @@ void samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS *r_u, prs_struc
prs_uint32("status", ps, depth, &(r_u->status));
}
+/*******************************************************************
+makes a SAMR_Q_ENUM_DOM_ALIASES structure.
+********************************************************************/
+void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_enum_dom_aliases\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->unknown_0 = 0;
+ q_e->max_size = size;
+}
+
/*******************************************************************
reads or writes a structure.
@@ -779,6 +888,26 @@ void samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_s
/*******************************************************************
+makes a SAMR_Q_QUERY_DISPINFO structure.
+********************************************************************/
+void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_query_dispinfo\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->switch_level = switch_level;
+
+ q_e->unknown_0 = 0;
+ q_e->start_idx = start_idx;
+ q_e->unknown_1 = 0x000007d0;
+ q_e->max_size = size;
+}
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
void samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth)
@@ -1035,6 +1164,26 @@ void samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO *r_u, prs_struc
}
+/*******************************************************************
+makes a SAMR_Q_ENUM_DOM_GROUPS structure.
+********************************************************************/
+void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_enum_dom_groups\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->switch_level = switch_level;
+
+ q_e->unknown_0 = 0;
+ q_e->start_idx = start_idx;
+ q_e->unknown_1 = 0x000007d0;
+ q_e->max_size = size;
+}
+
/*******************************************************************
reads or writes a structure.
@@ -1167,6 +1316,22 @@ void samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_str
}
+/*******************************************************************
+makes a SAMR_Q_QUERY_ALIASINFO structure.
+********************************************************************/
+void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
+ POLICY_HND *pol,
+ uint16 switch_level)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_query_aliasinfo\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->switch_level = switch_level;
+}
+
/*******************************************************************
reads or writes a structure.
@@ -1628,6 +1793,23 @@ void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, i
/*******************************************************************
reads or writes a structure.
********************************************************************/
+void make_samr_q_open_user(SAMR_Q_OPEN_USER *q_u,
+ POLICY_HND *pol,
+ uint32 unk_0, uint32 rid)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_open_user\n"));
+
+ memcpy(&q_u->domain_pol, pol, sizeof(q_u->domain_pol));
+
+ q_u->unknown_0 = unk_0;
+ q_u->user_rid = rid;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
void samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return;
@@ -1664,6 +1846,19 @@ void samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER *r_u, prs_struct *ps, int
prs_uint32("status", ps, depth, &(r_u->status));
}
+/*******************************************************************
+makes a SAMR_Q_QUERY_USERGROUPS structure.
+********************************************************************/
+void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
+ POLICY_HND *hnd)
+{
+ if (q_u == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_query_usergroups\n"));
+
+ memcpy(&(q_u->pol), hnd, sizeof(q_u->pol));
+}
+
/*******************************************************************
reads or writes a structure.
@@ -1744,6 +1939,21 @@ void samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_s
}
/*******************************************************************
+makes a SAMR_Q_QUERY_USERINFO structure.
+********************************************************************/
+void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
+ POLICY_HND *hnd, uint16 switch_value)
+{
+ if (q_u == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_query_userinfo\n"));
+
+ memcpy(&(q_u->pol), hnd, sizeof(q_u->pol));
+ q_u->switch_value = switch_value;
+}
+
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
void samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth)
@@ -2134,6 +2344,26 @@ void samr_io_r_unknown_32(char *desc, SAMR_R_UNKNOWN_32 *r_u, prs_struct *ps, i
/*******************************************************************
+makes a SAMR_Q_CONNECT structure.
+********************************************************************/
+void make_samr_q_connect(SAMR_Q_CONNECT *q_u,
+ char *srv_name, uint32 unknown_0)
+{
+ int len_srv_name = strlen(srv_name);
+
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_q_connect\n"));
+
+ /* make PDC server name \\server */
+ make_unistr2(&(q_u->uni_srv_name), srv_name, len_srv_name);
+
+ /* example values: 0x0000 0002 */
+ q_u->unknown_0 = unknown_0;
+}
+
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
void samr_io_q_connect(char *desc, SAMR_Q_CONNECT *q_u, prs_struct *ps, int depth)
@@ -2172,6 +2402,22 @@ void samr_io_r_connect(char *desc, SAMR_R_CONNECT *r_u, prs_struct *ps, int dep
}
/*******************************************************************
+makes a SAMR_Q_OPEN_ALIAS structure.
+********************************************************************/
+void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
+ uint32 unknown_0, uint32 rid)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_q_open_alias\n"));
+
+ /* example values: 0x0000 0008 */
+ q_u->unknown_0 = unknown_0;
+
+ q_u->rid_alias = rid;
+}
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
void samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth)
@@ -2237,3 +2483,197 @@ typedef struct r_samr_chgpasswd_user_info
#endif /* 0 */
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_38 structure.
+********************************************************************/
+void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name)
+{
+ int len_srv_name = strlen(srv_name);
+
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_q_unknown_38\n"));
+
+ q_u->ptr = 1;
+ make_uni_hdr(&(q_u->hdr_srv_name), len_srv_name, len_srv_name, len_srv_name != 0);
+ make_unistr2(&(q_u->uni_srv_name), srv_name, len_srv_name);
+
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_38(char *desc, SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_38");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr", ps, depth, &(q_u->ptr));
+ if (q_u->ptr != 0)
+ {
+ smb_io_unihdr ("", &(q_u->hdr_srv_name), ps, depth);
+ smb_io_unistr2("", &(q_u->uni_srv_name), q_u->hdr_srv_name.buffer, ps, depth);
+ }
+}
+
+/*******************************************************************
+makes a SAMR_R_UNKNOWN_38 structure.
+********************************************************************/
+void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u,
+ uint16 level, uint32 status)
+{
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_r_unknown_38\n"));
+
+ r_u->level.value = level;
+ r_u->ptr_0 = 0;
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_unknown_38(char *desc, SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_38");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_lookup_level("level ", &(r_u->level), ps, depth);
+ prs_uint32("ptr_0 ", ps, depth, &(r_u->ptr_0 ));
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+reads or writes a SAMR_ENC_PASSWD structure.
+********************************************************************/
+void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth)
+{
+ if (pwd == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_enc_passwd");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr", ps, depth, &(pwd->ptr));
+ prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass));
+}
+
+/*******************************************************************
+reads or writes a SAMR_ENC_HASH structure.
+********************************************************************/
+void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth)
+{
+ if (hsh == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_enc_hash");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr ", ps, depth, &(hsh->ptr));
+ prs_uint8s(False, "hash", ps, depth, hsh->hash, sizeof(hsh->hash));
+}
+
+#if 0
+/* SAMR_Q_CHGPASSWD_USER */
+typedef struct q_samr_chgpasswd_user_info
+{
+ uint32 ptr_0;
+
+ UNIHDR hdr_server; /* server name unicode header */
+ UNISTR2 uni_server; /* server name unicode string */
+
+ UNIHDR hdr_user_name; /* username unicode string header */
+ UNISTR2 uni_user_name; /* username unicode string */
+
+ SAMR_ENC_PASSWD nt_newpass;
+ SAMR_ENC_HASH nt_oldhash;
+
+ uint32 unknown_1; /* seems to always contain 0001 */
+
+ SAMR_ENC_PASSWD lm_newpass;
+ SAMR_ENC_HASH lm_oldhash;
+
+} SAMR_Q_CHGPASSWD_USER;
+
+/* SAMR_R_CHGPASSWD_USER */
+typedef struct r_samr_chgpasswd_user_info
+{
+ uint32 result; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
+
+} SAMR_R_CHGPASSWD_USER;
+
+#endif /* 0 */
+
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_12 structure.
+********************************************************************/
+void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
+ POLICY_HND *pol, uint32 rid,
+ uint32 num_gids, uint32 *gid)
+{
+ int i;
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_unknwon_12\n"));
+
+ memcpy(&(q_u->pol), pol, sizeof(*pol));
+
+ q_u->num_gids1 = num_gids;
+ q_u->rid = rid;
+ q_u->ptr = 0;
+ q_u->num_gids2 = num_gids;
+
+ for (i = 0; i < num_gids; i++)
+ {
+ q_u->gid[i] = gid[i];
+ }
+}
+
+
+
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_21 structure.
+********************************************************************/
+void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
+ POLICY_HND *hnd, uint16 unk_1, uint16 unk_2)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_unknown_21\n"));
+
+ memcpy(&(q_c->group_pol), hnd, sizeof(q_c->group_pol));
+ q_c->unknown_1 = unk_1;
+ q_c->unknown_2 = unk_2;
+}
+
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_13 structure.
+********************************************************************/
+void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
+ POLICY_HND *hnd, uint16 unk_1, uint16 unk_2)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_unknown_13\n"));
+
+ memcpy(&(q_c->alias_pol), hnd, sizeof(q_c->alias_pol));
+ q_c->unknown_1 = unk_1;
+ q_c->unknown_2 = unk_2;
+}
+
+
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 447f2c41d0..f8710d548d 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -34,7 +34,6 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
extern struct cli_state *smb_cli;
-extern int smb_tidx;
extern FILE* out_hnd;
@@ -45,8 +44,8 @@ experimental SAM encryted rpc test connection
void cmd_sam_test(struct client_info *info)
{
fstring srv_name;
- fstring sid;
fstring domain;
+ fstring sid;
BOOL res = True;
fstrcpy(sid , info->dom.level5_sid);
@@ -58,20 +57,18 @@ void cmd_sam_test(struct client_info *info)
return;
}
- strcpy(srv_name, "\\\\");
- strcat(srv_name, info->myhostname);
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->myhostname);
strupper(srv_name);
fprintf(out_hnd, "SAM Encryption Test\n");
/* open SAMR session. */
- res = res ? do_ntlm_session_open(smb_cli, smb_tidx,
- PIPE_SAMR, &(info->dom.samr_fnum),
- info->myhostname, domain) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, True) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.samr_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -90,8 +87,9 @@ experimental SAM users enum.
void cmd_sam_enum_users(struct client_info *info)
{
fstring srv_name;
- fstring sid;
fstring domain;
+ fstring sid;
+ DOM_SID sid1;
int user_idx;
BOOL res = True;
BOOL request_user_info = False;
@@ -112,40 +110,42 @@ void cmd_sam_enum_users(struct client_info *info)
return;
}
- strcpy(srv_name, "\\\\");
- strcat(srv_name, info->dest_host);
+ make_dom_sid(&sid1, sid);
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
/* a bad way to do token parsing... */
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
request_user_info |= strequal(tmp, "-u");
request_group_info |= strequal(tmp, "-g");
}
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
request_user_info |= strequal(tmp, "-u");
request_group_info |= strequal(tmp, "-g");
}
#ifdef DEBUG_TESTING
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
num_entries = strtoul(tmp, (char**)NULL, 16);
}
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
unk_0 = strtoul(tmp, (char**)NULL, 16);
}
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
acb_mask = strtoul(tmp, (char**)NULL, 16);
}
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
unk_1 = strtoul(tmp, (char**)NULL, 16);
}
@@ -161,20 +161,20 @@ void cmd_sam_enum_users(struct client_info *info)
#endif
/* open SAMR session. negotiate credentials */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SAMR, &(info->dom.samr_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, False) : False;
/* establish a connection. */
- res = res ? do_samr_connect(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_connect(smb_cli,
srv_name, 0x00000020,
&info->dom.samr_pol_connect) : False;
/* connect to the domain */
- res = res ? do_samr_open_domain(smb_cli, smb_tidx, info->dom.samr_fnum,
- &info->dom.samr_pol_connect, admin_rid, sid,
+ res = res ? do_samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, admin_rid, &sid1,
&info->dom.samr_pol_open_domain) : False;
/* read some users */
- res = res ? do_samr_enum_dom_users(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_enum_dom_users(smb_cli,
&info->dom.samr_pol_open_domain,
num_entries, unk_0, acb_mask, unk_1, 0xffff,
info->dom.sam, &info->dom.num_sam_entries) : False;
@@ -201,13 +201,13 @@ void cmd_sam_enum_users(struct client_info *info)
if (request_user_info)
{
/* send user info query, level 0x15 */
- if (get_samr_query_userinfo(smb_cli, smb_tidx, info->dom.samr_fnum,
+ if (get_samr_query_userinfo(smb_cli,
&info->dom.samr_pol_open_domain,
0x15, user_rid, &usr))
{
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_HEADER , &usr);
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_ENUMERATE, &usr);
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_FOOTER , &usr);
+ display_sam_user_info_21(out_hnd, ACTION_HEADER , &usr);
+ display_sam_user_info_21(out_hnd, ACTION_ENUMERATE, &usr);
+ display_sam_user_info_21(out_hnd, ACTION_FOOTER , &usr);
}
}
@@ -217,13 +217,13 @@ void cmd_sam_enum_users(struct client_info *info)
DOM_GID gid[LSA_MAX_GROUPS];
/* send user group query */
- if (get_samr_query_usergroups(smb_cli, smb_tidx, info->dom.samr_fnum,
+ if (get_samr_query_usergroups(smb_cli,
&info->dom.samr_pol_open_domain,
user_rid, &num_groups, gid))
{
- display_group_rid_info(out_hnd, DISPLAY_TXT, ACTION_HEADER , num_groups, gid);
- display_group_rid_info(out_hnd, DISPLAY_TXT, ACTION_ENUMERATE, num_groups, gid);
- display_group_rid_info(out_hnd, DISPLAY_TXT, ACTION_FOOTER , num_groups, gid);
+ display_group_rid_info(out_hnd, ACTION_HEADER , num_groups, gid);
+ display_group_rid_info(out_hnd, ACTION_ENUMERATE, num_groups, gid);
+ display_group_rid_info(out_hnd, ACTION_FOOTER , num_groups, gid);
}
}
@@ -231,14 +231,14 @@ void cmd_sam_enum_users(struct client_info *info)
}
}
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_connect) : False;
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_open_domain) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.samr_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -257,8 +257,9 @@ experimental SAM user query.
void cmd_sam_query_user(struct client_info *info)
{
fstring srv_name;
- fstring sid;
fstring domain;
+ fstring sid;
+ DOM_SID sid1;
int user_idx;
BOOL res = True;
BOOL request_user_info = False;
@@ -284,11 +285,14 @@ void cmd_sam_query_user(struct client_info *info)
return;
}
- strcpy(srv_name, "\\\\");
- strcat(srv_name, info->dest_host);
+ make_dom_sid(&sid1, sid);
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (next_token(NULL, rid_str, NULL) && next_token(NULL, info_str, NULL))
+ if (next_token(NULL, rid_str , NULL, sizeof(rid_str )) &&
+ next_token(NULL, info_str, NULL, sizeof(info_str)))
{
user_rid = strtoul(rid_str , (char**)NULL, 16);
info_level = strtoul(info_str, (char**)NULL, 10);
@@ -300,16 +304,16 @@ void cmd_sam_query_user(struct client_info *info)
info->myhostname, srv_name, domain, sid);
/* open SAMR session. negotiate credentials */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SAMR, &(info->dom.samr_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, False) : False;
/* establish a connection. */
- res = res ? do_samr_connect(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_connect(smb_cli,
srv_name, 0x00000020,
&info->dom.samr_pol_connect) : False;
/* connect to the domain */
- res = res ? do_samr_open_domain(smb_cli, smb_tidx, info->dom.samr_fnum,
- &info->dom.samr_pol_connect, admin_rid, sid,
+ res = res ? do_samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, admin_rid, &sid1,
&info->dom.samr_pol_open_domain) : False;
fprintf(out_hnd, "User RID: %8x User Name: %s\n",
@@ -317,26 +321,26 @@ void cmd_sam_query_user(struct client_info *info)
info->dom.sam[user_idx].acct_name);
/* send user info query, level */
- if (get_samr_query_userinfo(smb_cli, smb_tidx, info->dom.samr_fnum,
+ if (get_samr_query_userinfo(smb_cli,
&info->dom.samr_pol_open_domain,
info_level, user_rid, &usr))
{
if (info_level == 0x15)
{
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_HEADER , &usr);
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_ENUMERATE, &usr);
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_FOOTER , &usr);
+ display_sam_user_info_21(out_hnd, ACTION_HEADER , &usr);
+ display_sam_user_info_21(out_hnd, ACTION_ENUMERATE, &usr);
+ display_sam_user_info_21(out_hnd, ACTION_FOOTER , &usr);
}
}
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_connect) : False;
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_open_domain) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.samr_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -355,8 +359,9 @@ experimental SAM groups query.
void cmd_sam_query_groups(struct client_info *info)
{
fstring srv_name;
- fstring sid;
fstring domain;
+ fstring sid;
+ DOM_SID sid1;
BOOL res = True;
fstring info_str;
uint32 switch_value = 2;
@@ -371,11 +376,13 @@ void cmd_sam_query_groups(struct client_info *info)
return;
}
- strcpy(srv_name, "\\\\");
- strcat(srv_name, info->dest_host);
+ make_dom_sid(&sid1, sid);
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (next_token(NULL, info_str, NULL))
+ if (next_token(NULL, info_str, NULL, sizeof(info_str)))
{
switch_value = strtoul(info_str, (char**)NULL, 10);
}
@@ -385,30 +392,30 @@ void cmd_sam_query_groups(struct client_info *info)
info->myhostname, srv_name, domain, sid);
/* open SAMR session. negotiate credentials */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SAMR, &(info->dom.samr_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, False) : False;
/* establish a connection. */
- res = res ? do_samr_connect(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_connect(smb_cli,
srv_name, 0x00000020,
&info->dom.samr_pol_connect) : False;
/* connect to the domain */
- res = res ? do_samr_open_domain(smb_cli, smb_tidx, info->dom.samr_fnum,
- &info->dom.samr_pol_connect, admin_rid, sid,
+ res = res ? do_samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, admin_rid, &sid1,
&info->dom.samr_pol_open_domain) : False;
/* send a samr 0x8 command */
- res = res ? do_samr_unknown_8(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_unknown_8(smb_cli,
&info->dom.samr_pol_open_domain, switch_value) : False;
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_connect) : False;
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_open_domain) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.samr_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
@@ -427,8 +434,9 @@ experimental SAM aliases query.
void cmd_sam_enum_aliases(struct client_info *info)
{
fstring srv_name;
- fstring sid;
fstring domain;
+ fstring sid;
+ DOM_SID sid1;
int user_idx;
BOOL res = True;
BOOL res2 = True;
@@ -455,18 +463,20 @@ void cmd_sam_enum_aliases(struct client_info *info)
return;
}
- strcpy(srv_name, "\\\\");
- strcat(srv_name, info->dest_host);
+ make_dom_sid(&sid1, sid);
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
strupper(srv_name);
/* a bad way to do token parsing... */
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
request_user_info |= strequal(tmp, "-u");
request_alias_info |= strequal(tmp, "-g");
}
- if (next_token(NULL, tmp, NULL))
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
{
request_user_info |= strequal(tmp, "-u");
request_alias_info |= strequal(tmp, "-g");
@@ -477,34 +487,34 @@ void cmd_sam_enum_aliases(struct client_info *info)
info->myhostname, srv_name, domain, sid);
/* open SAMR session. negotiate credentials */
- res = res ? do_session_open(smb_cli, smb_tidx, PIPE_SAMR, &(info->dom.samr_fnum)) : False;
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, False) : False;
/* establish a connection. */
- res = res ? do_samr_connect(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_connect(smb_cli,
srv_name, 0x00000020,
&info->dom.samr_pol_connect) : False;
/* connect to the domain */
- res = res ? do_samr_open_domain(smb_cli, smb_tidx, info->dom.samr_fnum,
- &info->dom.samr_pol_connect, admin_rid, sid,
+ res = res ? do_samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, admin_rid, &sid1,
&info->dom.samr_pol_open_domain) : False;
/* send a query on the aliase */
- res = res ? do_samr_query_unknown_12(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_query_unknown_12(smb_cli,
&info->dom.samr_pol_open_domain, admin_rid, num_aliases, alias_rid,
&num_aliases, alias_names, num_als_usrs) : False;
if (res)
{
- display_alias_name_info(out_hnd, DISPLAY_TXT, ACTION_HEADER , num_aliases, alias_names, num_als_usrs);
- display_alias_name_info(out_hnd, DISPLAY_TXT, ACTION_ENUMERATE, num_aliases, alias_names, num_als_usrs);
- display_alias_name_info(out_hnd, DISPLAY_TXT, ACTION_FOOTER , num_aliases, alias_names, num_als_usrs);
+ display_alias_name_info(out_hnd, ACTION_HEADER , num_aliases, alias_names, num_als_usrs);
+ display_alias_name_info(out_hnd, ACTION_ENUMERATE, num_aliases, alias_names, num_als_usrs);
+ display_alias_name_info(out_hnd, ACTION_FOOTER , num_aliases, alias_names, num_als_usrs);
}
#if 0
/* read some users */
- res = res ? do_samr_enum_dom_users(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_enum_dom_users(smb_cli,
&info->dom.samr_pol_open_domain,
num_entries, unk_0, acb_mask, unk_1, 0xffff,
info->dom.sam, &info->dom.num_sam_entries) : False;
@@ -531,13 +541,13 @@ void cmd_sam_enum_aliases(struct client_info *info)
if (request_user_info)
{
/* send user info query, level 0x15 */
- if (get_samr_query_userinfo(smb_cli, smb_tidx, info->dom.samr_fnum,
+ if (get_samr_query_userinfo(smb_cli,
&info->dom.samr_pol_open_domain,
0x15, user_rid, &usr))
{
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_HEADER , &usr);
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_ENUMERATE, &usr);
- display_sam_user_info_21(out_hnd, DISPLAY_TXT, ACTION_FOOTER , &usr);
+ display_sam_user_info_21(out_hnd, ACTION_HEADER , &usr);
+ display_sam_user_info_21(out_hnd, ACTION_ENUMERATE, &usr);
+ display_sam_user_info_21(out_hnd, ACTION_FOOTER , &usr);
}
}
@@ -547,13 +557,13 @@ void cmd_sam_enum_aliases(struct client_info *info)
DOM_GID gid[LSA_MAX_GROUPS];
/* send user aliase query */
- if (get_samr_query_useraliases(smb_cli, smb_tidx, info->dom.samr_fnum,
+ if (get_samr_query_useraliases(smb_cli,
&info->dom.samr_pol_open_domain,
user_rid, &num_aliases, gid))
{
- display_alias_info(out_hnd, DISPLAY_TXT, ACTION_HEADER , num_aliases, gid);
- display_alias_info(out_hnd, DISPLAY_TXT, ACTION_ENUMERATE, num_aliases, gid);
- display_alias_info(out_hnd, DISPLAY_TXT, ACTION_FOOTER , num_aliases, gid);
+ display_alias_info(out_hnd, ACTION_HEADER , num_aliases, gid);
+ display_alias_info(out_hnd, ACTION_ENUMERATE, num_aliases, gid);
+ display_alias_info(out_hnd, ACTION_FOOTER , num_aliases, gid);
}
}
@@ -562,14 +572,14 @@ void cmd_sam_enum_aliases(struct client_info *info)
}
#endif
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_connect) : False;
- res = res ? do_samr_close(smb_cli, smb_tidx, info->dom.samr_fnum,
+ res = res ? do_samr_close(smb_cli,
&info->dom.samr_pol_open_domain) : False;
/* close the session */
- do_session_close(smb_cli, smb_tidx, info->dom.samr_fnum);
+ cli_nt_session_close(smb_cli);
if (res)
{
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index b3a4e60029..f399b7fc03 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -32,20 +32,20 @@ char *get_file_mode_str(uint32 share_mode)
switch ((share_mode>>4)&0xF)
{
- case DENY_NONE : strcpy(mode, "DENY_NONE "); break;
- case DENY_ALL : strcpy(mode, "DENY_ALL "); break;
- case DENY_DOS : strcpy(mode, "DENY_DOS "); break;
- case DENY_READ : strcpy(mode, "DENY_READ "); break;
- case DENY_WRITE: strcpy(mode, "DENY_WRITE "); break;
- default : strcpy(mode, "DENY_???? "); break;
+ case DENY_NONE : fstrcpy(mode, "DENY_NONE "); break;
+ case DENY_ALL : fstrcpy(mode, "DENY_ALL "); break;
+ case DENY_DOS : fstrcpy(mode, "DENY_DOS "); break;
+ case DENY_READ : fstrcpy(mode, "DENY_READ "); break;
+ case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break;
+ default : fstrcpy(mode, "DENY_???? "); break;
}
switch (share_mode & 0xF)
{
- case 0 : strcat(mode, "RDONLY"); break;
- case 1 : strcat(mode, "WRONLY"); break;
- case 2 : strcat(mode, "RDWR "); break;
- default: strcat(mode, "R??W??"); break;
+ case 0 : fstrcat(mode, "RDONLY"); break;
+ case 1 : fstrcat(mode, "WRONLY"); break;
+ case 2 : fstrcat(mode, "RDWR "); break;
+ default: fstrcat(mode, "R??W??"); break;
}
return mode;
@@ -62,10 +62,10 @@ char *get_file_oplock_str(uint32 op_type)
oplock[0] = 0;
- if (excl ) strcat(oplock, "EXCLUSIVE");
- if (excl && batch) strcat(oplock, "+");
- if ( batch) strcat(oplock, "BATCH");
- if (!excl && !batch) strcat(oplock, "NONE");
+ if (excl ) fstrcat(oplock, "EXCLUSIVE");
+ if (excl && batch) fstrcat(oplock, "+");
+ if ( batch) fstrcat(oplock, "BATCH");
+ if (!excl && !batch) fstrcat(oplock, "NONE");
return oplock;
}
@@ -79,11 +79,11 @@ char *get_share_type_str(uint32 type)
switch (type)
{
- case STYPE_DISKTREE: strcpy(typestr, "Disk" ); break;
- case STYPE_PRINTQ : strcpy(typestr, "Printer"); break;
- case STYPE_DEVICE : strcpy(typestr, "Device" ); break;
- case STYPE_IPC : strcpy(typestr, "IPC" ); break;
- default : strcpy(typestr, "????" ); break;
+ case STYPE_DISKTREE: fstrcpy(typestr, "Disk" ); break;
+ case STYPE_PRINTQ : fstrcpy(typestr, "Printer"); break;
+ case STYPE_DEVICE : fstrcpy(typestr, "Device" ); break;
+ case STYPE_IPC : fstrcpy(typestr, "IPC" ); break;
+ default : fstrcpy(typestr, "????" ); break;
}
return typestr;
}
@@ -97,7 +97,7 @@ char *get_server_type_str(uint32 type)
if (type == SV_TYPE_ALL)
{
- strcpy(typestr, "All");
+ fstrcpy(typestr, "All");
}
else
{
@@ -109,32 +109,32 @@ char *get_server_type_str(uint32 type)
{
switch (1 << i)
{
- case SV_TYPE_WORKSTATION : strcat(typestr, "Wk " ); break;
- case SV_TYPE_SERVER : strcat(typestr, "Sv " ); break;
- case SV_TYPE_SQLSERVER : strcat(typestr, "Sql "); break;
- case SV_TYPE_DOMAIN_CTRL : strcat(typestr, "PDC "); break;
- case SV_TYPE_DOMAIN_BAKCTRL : strcat(typestr, "BDC "); break;
- case SV_TYPE_TIME_SOURCE : strcat(typestr, "Tim "); break;
- case SV_TYPE_AFP : strcat(typestr, "AFP "); break;
- case SV_TYPE_NOVELL : strcat(typestr, "Nov "); break;
- case SV_TYPE_DOMAIN_MEMBER : strcat(typestr, "Dom "); break;
- case SV_TYPE_PRINTQ_SERVER : strcat(typestr, "PrQ "); break;
- case SV_TYPE_DIALIN_SERVER : strcat(typestr, "Din "); break;
- case SV_TYPE_SERVER_UNIX : strcat(typestr, "Unx "); break;
- case SV_TYPE_NT : strcat(typestr, "NT " ); break;
- case SV_TYPE_WFW : strcat(typestr, "Wfw "); break;
- case SV_TYPE_SERVER_MFPN : strcat(typestr, "Mfp "); break;
- case SV_TYPE_SERVER_NT : strcat(typestr, "SNT "); break;
- case SV_TYPE_POTENTIAL_BROWSER: strcat(typestr, "PtB "); break;
- case SV_TYPE_BACKUP_BROWSER : strcat(typestr, "BMB "); break;
- case SV_TYPE_MASTER_BROWSER : strcat(typestr, "LMB "); break;
- case SV_TYPE_DOMAIN_MASTER : strcat(typestr, "DMB "); break;
- case SV_TYPE_SERVER_OSF : strcat(typestr, "OSF "); break;
- case SV_TYPE_SERVER_VMS : strcat(typestr, "VMS "); break;
- case SV_TYPE_WIN95_PLUS : strcat(typestr, "W95 "); break;
- case SV_TYPE_ALTERNATE_XPORT : strcat(typestr, "Xpt "); break;
- case SV_TYPE_LOCAL_LIST_ONLY : strcat(typestr, "Dom "); break;
- case SV_TYPE_DOMAIN_ENUM : strcat(typestr, "Loc "); break;
+ case SV_TYPE_WORKSTATION : fstrcat(typestr, "Wk " ); break;
+ case SV_TYPE_SERVER : fstrcat(typestr, "Sv " ); break;
+ case SV_TYPE_SQLSERVER : fstrcat(typestr, "Sql "); break;
+ case SV_TYPE_DOMAIN_CTRL : fstrcat(typestr, "PDC "); break;
+ case SV_TYPE_DOMAIN_BAKCTRL : fstrcat(typestr, "BDC "); break;
+ case SV_TYPE_TIME_SOURCE : fstrcat(typestr, "Tim "); break;
+ case SV_TYPE_AFP : fstrcat(typestr, "AFP "); break;
+ case SV_TYPE_NOVELL : fstrcat(typestr, "Nov "); break;
+ case SV_TYPE_DOMAIN_MEMBER : fstrcat(typestr, "Dom "); break;
+ case SV_TYPE_PRINTQ_SERVER : fstrcat(typestr, "PrQ "); break;
+ case SV_TYPE_DIALIN_SERVER : fstrcat(typestr, "Din "); break;
+ case SV_TYPE_SERVER_UNIX : fstrcat(typestr, "Unx "); break;
+ case SV_TYPE_NT : fstrcat(typestr, "NT " ); break;
+ case SV_TYPE_WFW : fstrcat(typestr, "Wfw "); break;
+ case SV_TYPE_SERVER_MFPN : fstrcat(typestr, "Mfp "); break;
+ case SV_TYPE_SERVER_NT : fstrcat(typestr, "SNT "); break;
+ case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break;
+ case SV_TYPE_BACKUP_BROWSER : fstrcat(typestr, "BMB "); break;
+ case SV_TYPE_MASTER_BROWSER : fstrcat(typestr, "LMB "); break;
+ case SV_TYPE_DOMAIN_MASTER : fstrcat(typestr, "DMB "); break;
+ case SV_TYPE_SERVER_OSF : fstrcat(typestr, "OSF "); break;
+ case SV_TYPE_SERVER_VMS : fstrcat(typestr, "VMS "); break;
+ case SV_TYPE_WIN95_PLUS : fstrcat(typestr, "W95 "); break;
+ case SV_TYPE_ALTERNATE_XPORT : fstrcat(typestr, "Xpt "); break;
+ case SV_TYPE_LOCAL_LIST_ONLY : fstrcat(typestr, "Dom "); break;
+ case SV_TYPE_DOMAIN_ENUM : fstrcat(typestr, "Loc "); break;
}
}
}
@@ -977,12 +977,12 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I
fprintf(out_hnd, "\t\tUnknown Str : %s\n", unistrn2(usr->uni_unknown_str .buffer, usr->uni_unknown_str .uni_str_len)); /* unknown string unicode string */
fprintf(out_hnd, "\t\tRemote Dial : %s\n", unistrn2(usr->uni_munged_dial .buffer, usr->uni_munged_dial .uni_str_len)); /* munged remote access unicode string */
- fprintf(out_hnd, "\t\tLogon Time : %s\n", time_to_string(interpret_nt_time(&(usr->logon_time ))));
- fprintf(out_hnd, "\t\tLogoff Time : %s\n", time_to_string(interpret_nt_time(&(usr->logoff_time ))));
- fprintf(out_hnd, "\t\tKickoff Time : %s\n", time_to_string(interpret_nt_time(&(usr->kickoff_time ))));
- fprintf(out_hnd, "\t\tPassword last set Time : %s\n", time_to_string(interpret_nt_time(&(usr->pass_last_set_time ))));
- fprintf(out_hnd, "\t\tPassword can change Time : %s\n", time_to_string(interpret_nt_time(&(usr->pass_can_change_time ))));
- fprintf(out_hnd, "\t\tPassword must change Time: %s\n", time_to_string(interpret_nt_time(&(usr->pass_must_change_time))));
+ fprintf(out_hnd, "\t\tLogon Time : %s\n", http_timestring(interpret_nt_time(&(usr->logon_time ))));
+ fprintf(out_hnd, "\t\tLogoff Time : %s\n", http_timestring(interpret_nt_time(&(usr->logoff_time ))));
+ fprintf(out_hnd, "\t\tKickoff Time : %s\n", http_timestring(interpret_nt_time(&(usr->kickoff_time ))));
+ fprintf(out_hnd, "\t\tPassword last set Time : %s\n", http_timestring(interpret_nt_time(&(usr->pass_last_set_time ))));
+ fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(interpret_nt_time(&(usr->pass_can_change_time ))));
+ fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(interpret_nt_time(&(usr->pass_must_change_time))));
fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 9c4f160f9f..3166046c19 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -115,18 +115,14 @@ struct
{"srvfiles", cmd_srv_enum_files, "DCE/RPC - List files on a server"},
#endif
{"lsaquery", cmd_lsa_query_info, "Query Info Policy (domain member or server)"},
-#if 0
{"enumusers", cmd_sam_enum_users, "SAM User Database Query (experimental!)"},
{"samuser", cmd_sam_query_user, "<username> SAM User Query (experimental!)"},
{"samtest", cmd_sam_test , "SAM User Encrypted RPC test (experimental!)"},
{"enumaliases",cmd_sam_enum_aliases, "SAM Aliases Database Query (experimental!)"},
-#endif
#if 0
{"enumgroups", cmd_sam_enum_groups, "SAM Group Database Query (experimental!)"},
#endif
-#if 0
{"samgroups", cmd_sam_query_groups, "SAM Group Database Query (experimental!)"},
-#endif
{"quit", cmd_quit, "logoff the server"},
{"q", cmd_quit, "logoff the server"},
{"exit", cmd_quit, "logoff the server"},