summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/ntdomain.h3
-rw-r--r--source3/include/proto.h76
-rw-r--r--source3/include/rpc_samr.h32
-rw-r--r--source3/lib/sids.c8
-rw-r--r--source3/lib/util.c8
-rw-r--r--source3/rpc_client/cli_lsarpc.c10
-rw-r--r--source3/rpc_client/cli_samr.c651
-rw-r--r--source3/rpc_parse/parse_samr.c56
-rw-r--r--source3/rpc_server/srv_samr.c40
-rw-r--r--source3/rpcclient/cmd_lsarpc.c20
-rw-r--r--source3/rpcclient/cmd_samr.c564
-rw-r--r--source3/rpcclient/display.c244
-rw-r--r--source3/rpcclient/rpcclient.c4
13 files changed, 1425 insertions, 291 deletions
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index ed74943187..d03b1e0a3e 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -145,7 +145,8 @@ typedef struct
struct acct_info
{
fstring acct_name; /* account name */
- uint32 user_rid; /* domain-relative RID */
+ fstring acct_desc; /* account description */
+ uint32 rid; /* domain-relative RID */
};
#endif /* _NT_DOMAIN_H */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6a0d99f59d..e2b33b3226 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -347,7 +347,7 @@ BOOL user_in_list(char *user,char *list);
char *tmpdir(void);
BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups);
-int get_number(const char *tmp);
+uint32 get_number(const char *tmp);
char *Atoic(char *p, int *n, char *c);
uint32 *add_num_to_list(uint32 **num, int *count, int val);
char *get_numlist(char *p, uint32 **num, int *count);
@@ -1495,25 +1495,25 @@ BOOL cli_nt_logoff(struct cli_state *cli, NET_ID_INFO_CTR *ctr);
/*The following definitions come from rpc_client/cli_lsarpc.c */
-BOOL do_lsa_open_policy(struct cli_state *cli,
+BOOL lsa_open_policy(struct cli_state *cli,
char *server_name, POLICY_HND *hnd,
BOOL sec_qos);
-BOOL do_lsa_lookup_names(struct cli_state *cli,
+BOOL lsa_lookup_names(struct cli_state *cli,
POLICY_HND *hnd,
int num_names,
char **names,
DOM_SID **sids,
int *num_sids);
-BOOL do_lsa_lookup_sids(struct cli_state *cli,
+BOOL lsa_lookup_sids(struct cli_state *cli,
POLICY_HND *hnd,
int num_sids,
DOM_SID **sids,
char ***names,
int *num_names);
-BOOL do_lsa_query_info_pol(struct cli_state *cli,
+BOOL lsa_query_info_pol(struct cli_state *cli,
POLICY_HND *hnd, uint16 info_class,
fstring domain_name, DOM_SID *domain_sid);
-BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd);
+BOOL lsa_close(struct cli_state *cli, POLICY_HND *hnd);
/*The following definitions come from rpc_client/cli_netlogon.c */
@@ -1591,10 +1591,21 @@ BOOL create_samr_domain_group(struct cli_state *cli,
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_groupmem(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 group_rid, uint32 *num_mem,
+ uint32 *rid, uint32 *attr);
+BOOL get_samr_query_aliasmem(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 alias_rid, uint32 *num_mem, DOM_SID2 *sid);
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 get_samr_query_groupinfo(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 info_level,
+ uint32 group_rid, GROUP_INFO_CTR *ctr);
BOOL samr_chgpasswd_user(struct cli_state *cli,
char *srv_name, char *user_name,
char nt_newpass[516], uchar nt_oldhash[16],
@@ -1602,6 +1613,14 @@ BOOL samr_chgpasswd_user(struct cli_state *cli,
BOOL samr_unknown_38(struct cli_state *cli, char *srv_name);
BOOL samr_query_dom_info(struct cli_state *cli,
POLICY_HND *domain_pol, uint16 switch_value);
+BOOL samr_enum_dom_groups(struct cli_state *cli,
+ POLICY_HND *pol, uint32 size,
+ struct acct_info **sam,
+ int *num_sam_groups);
+BOOL samr_enum_dom_aliases(struct cli_state *cli,
+ POLICY_HND *pol, uint32 size,
+ struct acct_info **sam,
+ int *num_sam_aliases);
BOOL 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,
@@ -1616,6 +1635,8 @@ BOOL samr_open_user(struct cli_state *cli,
BOOL samr_open_alias(struct cli_state *cli,
POLICY_HND *domain_pol, uint32 rid,
POLICY_HND *alias_pol);
+BOOL samr_add_aliasmem(struct cli_state *cli,
+ POLICY_HND *alias_pol, DOM_SID *sid);
BOOL samr_create_dom_alias(struct cli_state *cli,
POLICY_HND *domain_pol, const char *acct_name,
POLICY_HND *alias_pol, uint32 *rid);
@@ -1624,24 +1645,36 @@ BOOL samr_set_aliasinfo(struct cli_state *cli,
BOOL samr_open_group(struct cli_state *cli,
POLICY_HND *domain_pol, uint32 rid,
POLICY_HND *group_pol);
+BOOL samr_add_groupmem(struct cli_state *cli,
+ POLICY_HND *group_pol, uint32 rid);
BOOL samr_create_dom_group(struct cli_state *cli,
POLICY_HND *domain_pol, const char *acct_name,
POLICY_HND *group_pol, uint32 *rid);
BOOL samr_set_groupinfo(struct cli_state *cli,
POLICY_HND *group_pol, GROUP_INFO_CTR *ctr);
BOOL samr_open_domain(struct cli_state *cli,
- POLICY_HND *connect_pol, uint32 rid, DOM_SID *sid,
+ POLICY_HND *connect_pol, uint32 flags, DOM_SID *sid,
POLICY_HND *domain_pol);
-BOOL samr_query_unknown_12(struct cli_state *cli,
- POLICY_HND *pol, uint32 rid, uint32 num_gids, uint32 *gids,
+BOOL samr_query_lookup_rids(struct cli_state *cli,
+ POLICY_HND *pol, uint32 flags,
+ uint32 num_rids, uint32 *rids,
uint32 *num_names,
fstring names[MAX_LOOKUP_SIDS],
uint32 type [MAX_LOOKUP_SIDS]);
+BOOL samr_query_aliasmem(struct cli_state *cli,
+ POLICY_HND *alias_pol,
+ uint32 *num_mem, DOM_SID2 *sid);
BOOL samr_query_useraliases(struct cli_state *cli,
POLICY_HND *pol, DOM_SID *sid,
uint32 *num_aliases, uint32 *rid);
+BOOL samr_query_groupmem(struct cli_state *cli,
+ POLICY_HND *group_pol,
+ uint32 *num_mem, uint32 *rid, uint32 *attr);
BOOL samr_query_usergroups(struct cli_state *cli,
POLICY_HND *pol, uint32 *num_groups, DOM_GID *gid);
+BOOL samr_query_groupinfo(struct cli_state *cli,
+ POLICY_HND *pol,
+ uint16 switch_value, GROUP_INFO_CTR* ctr);
BOOL samr_query_userinfo(struct cli_state *cli,
POLICY_HND *pol, uint16 switch_value, void* usr);
BOOL samr_close(struct cli_state *cli, POLICY_HND *hnd);
@@ -2021,7 +2054,7 @@ 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,
+ POLICY_HND *connect_pol, uint32 flags,
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);
@@ -2155,14 +2188,14 @@ void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u, POLICY_HND *pol,
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_12(SAMR_Q_UNKNOWN_12 *q_u,
- POLICY_HND *pol, uint32 rid,
- uint32 num_gids, uint32 *gid);
-void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth);
-void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
+void make_samr_q_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u,
+ POLICY_HND *pol, uint32 flags,
+ uint32 num_rids, uint32 *rid);
+void samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *ps, int depth);
+void make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
uint32 num_names, fstring *name, uint8 *type,
uint32 status);
-void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth);
+void samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth);
void make_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, POLICY_HND *hnd);
void samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS *q_u, prs_struct *ps, int depth);
void samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS *r_u, prs_struct *ps, int depth);
@@ -2475,12 +2508,15 @@ void cmd_reg_get_key_sec(struct client_info *info);
void cmd_sam_ntchange_pwd(struct client_info *info);
void cmd_sam_test(struct client_info *info);
+void cmd_sam_add_aliasmem(struct client_info *info);
void cmd_sam_create_dom_alias(struct client_info *info);
+void cmd_sam_add_groupmem(struct client_info *info);
void cmd_sam_create_dom_group(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_query_dominfo(struct client_info *info);
void cmd_sam_enum_aliases(struct client_info *info);
+void cmd_sam_enum_groups(struct client_info *info);
/*The following definitions come from rpcclient/cmd_srvsvc.c */
@@ -2496,6 +2532,7 @@ void cmd_wks_query_info(struct client_info *info);
/*The following definitions come from rpcclient/display.c */
+char *get_sid_name_use_str(uint8 sid_name_use);
char *get_file_mode_str(uint32 share_mode);
char *get_file_oplock_str(uint32 op_type);
char *get_share_type_str(uint32 type);
@@ -2540,9 +2577,14 @@ void display_share2(FILE *out_hnd, enum action_type action,
char *path, char *passwd);
void display_name(FILE *out_hnd, enum action_type action,
char *sname);
+void display_alias_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, char **sid_mem);
void display_alias_rid_info(FILE *out_hnd, enum action_type action,
DOM_SID *sid,
uint32 num_rids, uint32 *rid);
+void display_group_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, fstring *name, uint32 *type);
+void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *info1);
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,
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h
index 21fed222c4..9c4cd4bd8c 100644
--- a/source3/include/rpc_samr.h
+++ b/source3/include/rpc_samr.h
@@ -92,7 +92,7 @@ SamrTestPrivateFunctionsUser
#define SAMR_QUERY_USERALIASES 0x10
#define SAMR_LOOKUP_NAMES 0x11
-#define SAMR_UNKNOWN_12 0x12
+#define SAMR_LOOKUP_RIDS 0x12
#define SAMR_OPEN_GROUP 0x13
#define SAMR_QUERY_GROUPINFO 0x14
@@ -438,7 +438,7 @@ SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
typedef struct q_samr_open_domain_info
{
POLICY_HND connect_pol; /* policy handle */
- uint32 rid; /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - a RID? */
+ uint32 flags; /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
DOM_SID2 dom_sid; /* domain SID */
} SAMR_Q_OPEN_DOMAIN;
@@ -1012,34 +1012,32 @@ typedef struct r_samr_lookup_names_info
/****************************************************************************
-SAMR_Q_UNKNOWN_12 - do a conversion from RID groups to something.
+SAMR_Q_LOOKUP_RIDS - do a conversion from RID groups to something.
called to resolve domain RID groups.
*****************************************************************************/
-/* SAMR_Q_UNKNOWN_12 */
-typedef struct q_samr_unknown_12_info
+/* SAMR_Q_LOOKUP_RIDS */
+typedef struct q_samr_lookup_rids_info
{
POLICY_HND pol; /* policy handle */
- uint32 num_gids1; /* number of rids being looked up */
- uint32 rid; /* 0x0000 03e8 - RID of the server doing the query? */
+ uint32 num_rids1; /* number of rids being looked up */
+ uint32 flags; /* 0x0000 03e8 - RID of the server doing the query? */
uint32 ptr; /* 0x0000 0000 - 32 bit unknown */
- uint32 num_gids2; /* number of rids being looked up */
+ uint32 num_rids2; /* number of rids being looked up */
- uint32 gid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+ uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
-} SAMR_Q_UNKNOWN_12;
+} SAMR_Q_LOOKUP_RIDS;
/****************************************************************************
-SAMR_R_UNKNOWN_12 - do a conversion from group RID to names
+SAMR_R_LOOKUP_RIDS - do a conversion from group RID to names
*****************************************************************************/
-/* SAMR_R_UNKNOWN_12 */
-typedef struct r_samr_unknown_12_info
+/* SAMR_R_LOOKUP_RIDS */
+typedef struct r_samr_lookup_rids_info
{
- POLICY_HND pol; /* policy handle */
-
uint32 num_names1; /* number of aliases being looked up */
uint32 ptr_names; /* pointer to aliases */
uint32 num_names2; /* number of aliases being looked up */
@@ -1055,7 +1053,7 @@ typedef struct r_samr_unknown_12_info
uint32 status;
-} SAMR_R_UNKNOWN_12;
+} SAMR_R_LOOKUP_RIDS;
/* SAMR_Q_OPEN_USER - probably an open */
@@ -1216,7 +1214,7 @@ typedef struct q_samr_add_alias_mem_info
{
POLICY_HND alias_pol; /* policy handle */
- DOM_SID sid; /* member sid to be added to alias */
+ DOM_SID2 sid; /* member sid to be added to alias */
} SAMR_Q_ADD_ALIASMEM;
diff --git a/source3/lib/sids.c b/source3/lib/sids.c
index de0eb40d9f..b308664bcf 100644
--- a/source3/lib/sids.c
+++ b/source3/lib/sids.c
@@ -223,22 +223,22 @@ BOOL get_domain_sids(DOM_SID *sid3, DOM_SID *sid5, char *servers)
res = res ? cli_nt_session_open(&cli, PIPE_LSARPC) : False;
/* lookup domain controller; receive a policy handle */
- res = res ? do_lsa_open_policy(&cli, srv_name, &pol, False) : False;
+ res = res ? lsa_open_policy(&cli, srv_name, &pol, False) : False;
if (sid3 != NULL)
{
/* send client info query, level 3. receive domain name and sid */
- res = res ? do_lsa_query_info_pol(&cli, &pol, 3, dom3, sid3) : False;
+ res = res ? lsa_query_info_pol(&cli, &pol, 3, dom3, sid3) : False;
}
if (sid5 != NULL)
{
/* send client info query, level 5. receive domain name and sid */
- res = res ? do_lsa_query_info_pol(&cli, &pol, 5, dom5, sid5) : False;
+ res = res ? lsa_query_info_pol(&cli, &pol, 5, dom5, sid5) : False;
}
/* close policy handle */
- res = res ? do_lsa_close(&cli, &pol) : False;
+ res = res ? lsa_close(&cli, &pol) : False;
/* close the session */
cli_nt_session_close(&cli);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index dc11c7789c..904b007749 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -121,15 +121,15 @@ BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups)
/****************************************************************************
gets either a hex number (0xNNN) or decimal integer (NNN).
****************************************************************************/
-int get_number(const char *tmp)
+uint32 get_number(const char *tmp)
{
if (strnequal(tmp, "0x", 2))
{
- return strtol(tmp, (char**)NULL, 16);
+ return strtoul(tmp, (char**)NULL, 16);
}
else
{
- return strtol(tmp, (char**)NULL, 10);
+ return strtoul(tmp, (char**)NULL, 10);
}
}
@@ -144,7 +144,7 @@ char *Atoic(char *p, int *n, char *c)
return NULL;
}
- (*n) = get_number(p);
+ (*n) = (int)get_number(p);
if (strnequal(p, "0x", 2))
{
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 81202fedb5..f80d6613f6 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -35,7 +35,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
do a LSA Open Policy
****************************************************************************/
-BOOL do_lsa_open_policy(struct cli_state *cli,
+BOOL lsa_open_policy(struct cli_state *cli,
char *server_name, POLICY_HND *hnd,
BOOL sec_qos)
{
@@ -101,7 +101,7 @@ BOOL do_lsa_open_policy(struct cli_state *cli,
/****************************************************************************
do a LSA Lookup Names
****************************************************************************/
-BOOL do_lsa_lookup_names(struct cli_state *cli,
+BOOL lsa_lookup_names(struct cli_state *cli,
POLICY_HND *hnd,
int num_names,
char **names,
@@ -214,7 +214,7 @@ BOOL do_lsa_lookup_names(struct cli_state *cli,
/****************************************************************************
do a LSA Lookup SIDs
****************************************************************************/
-BOOL do_lsa_lookup_sids(struct cli_state *cli,
+BOOL lsa_lookup_sids(struct cli_state *cli,
POLICY_HND *hnd,
int num_sids,
DOM_SID **sids,
@@ -333,7 +333,7 @@ BOOL do_lsa_lookup_sids(struct cli_state *cli,
/****************************************************************************
do a LSA Query Info Policy
****************************************************************************/
-BOOL do_lsa_query_info_pol(struct cli_state *cli,
+BOOL lsa_query_info_pol(struct cli_state *cli,
POLICY_HND *hnd, uint16 info_class,
fstring domain_name, DOM_SID *domain_sid)
{
@@ -446,7 +446,7 @@ BOOL do_lsa_query_info_pol(struct cli_state *cli,
/****************************************************************************
do a LSA Close
****************************************************************************/
-BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
+BOOL lsa_close(struct cli_state *cli, POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index 6c72972199..2ea7d54821 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -43,6 +43,8 @@ BOOL create_samr_domain_alias(struct cli_state *cli,
{
POLICY_HND pol_open_alias;
ALIAS_INFO_CTR ctr;
+ BOOL ret = True;
+
if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False;
/* send create alias */
@@ -66,9 +68,10 @@ BOOL create_samr_domain_alias(struct cli_state *cli,
&ctr))
{
DEBUG(5,("create_samr_domain_alias: error in samr_set_aliasinfo\n"));
+ ret = False;
}
- return samr_close(cli, &pol_open_alias);
+ return samr_close(cli, &pol_open_alias) && ret;
}
/****************************************************************************
@@ -81,6 +84,8 @@ BOOL create_samr_domain_group(struct cli_state *cli,
{
POLICY_HND pol_open_group;
GROUP_INFO_CTR ctr;
+ BOOL ret = True;
+
if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False;
/* send create group*/
@@ -105,9 +110,10 @@ BOOL create_samr_domain_group(struct cli_state *cli,
&ctr))
{
DEBUG(5,("create_samr_domain_group: error in samr_set_groupinfo\n"));
+ ret = False;
}
- return samr_close(cli, &pol_open_group);
+ return samr_close(cli, &pol_open_group) && ret;
}
/****************************************************************************
@@ -118,6 +124,8 @@ BOOL get_samr_query_usergroups(struct cli_state *cli,
uint32 *num_groups, DOM_GID *gid)
{
POLICY_HND pol_open_user;
+ BOOL ret = True;
+
if (pol_open_domain == NULL || num_groups == NULL || gid == NULL) return False;
/* send open domain (on user sid) */
@@ -135,9 +143,73 @@ BOOL get_samr_query_usergroups(struct cli_state *cli,
num_groups, gid))
{
DEBUG(5,("samr_query_usergroups: error in query user groups\n"));
+ ret = False;
+ }
+
+ return samr_close(cli, &pol_open_user) && ret;
+}
+
+/****************************************************************************
+do a SAMR query group members
+****************************************************************************/
+BOOL get_samr_query_groupmem(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 group_rid, uint32 *num_mem,
+ uint32 *rid, uint32 *attr)
+{
+ POLICY_HND pol_open_group;
+ BOOL ret = True;
+
+ if (pol_open_domain == NULL || num_mem == NULL || rid == NULL || attr == NULL) return False;
+
+ /* send open domain (on group sid) */
+ if (!samr_open_group(cli, pol_open_domain,
+ group_rid,
+ &pol_open_group))
+ {
+ return False;
}
- return samr_close(cli, &pol_open_user);
+ /* send group info query */
+ if (!samr_query_groupmem(cli, &pol_open_group, num_mem, rid, attr))
+
+ {
+ DEBUG(5,("samr_query_group: error in query group members\n"));
+ ret = False;
+ }
+
+ return samr_close(cli, &pol_open_group) && ret;
+}
+
+/****************************************************************************
+do a SAMR query alias members
+****************************************************************************/
+BOOL get_samr_query_aliasmem(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 alias_rid, uint32 *num_mem, DOM_SID2 *sid)
+{
+ POLICY_HND pol_open_alias;
+ BOOL ret = True;
+
+ if (pol_open_domain == NULL || num_mem == NULL || sid == NULL) return False;
+
+ /* send open domain (on alias sid) */
+ if (!samr_open_alias(cli, pol_open_domain,
+ alias_rid,
+ &pol_open_alias))
+ {
+ return False;
+ }
+
+ /* send alias info query */
+ if (!samr_query_aliasmem(cli, &pol_open_alias, num_mem, sid))
+
+ {
+ DEBUG(5,("samr_query_alias: error in query alias members\n"));
+ ret = False;
+ }
+
+ return samr_close(cli, &pol_open_alias) && ret;
}
/****************************************************************************
@@ -149,6 +221,8 @@ BOOL get_samr_query_userinfo(struct cli_state *cli,
uint32 user_rid, SAM_USER_INFO_21 *usr)
{
POLICY_HND pol_open_user;
+ BOOL ret = True;
+
if (pol_open_domain == NULL || usr == NULL) return False;
bzero(usr, sizeof(*usr));
@@ -169,9 +243,46 @@ BOOL get_samr_query_userinfo(struct cli_state *cli,
{
DEBUG(5,("samr_query_userinfo: error in query user info, level 0x%x\n",
info_level));
+ ret = False;
+ }
+
+ return samr_close(cli, &pol_open_user) && ret;
+}
+
+/****************************************************************************
+do a SAMR query group info
+****************************************************************************/
+BOOL get_samr_query_groupinfo(struct cli_state *cli,
+ POLICY_HND *pol_open_domain,
+ uint32 info_level,
+ uint32 group_rid, GROUP_INFO_CTR *ctr)
+{
+ POLICY_HND pol_open_group;
+ BOOL ret = True;
+
+ if (pol_open_domain == NULL || ctr == NULL) return False;
+
+ bzero(ctr, sizeof(*ctr));
+
+ /* send open domain (on group sid) */
+ if (!samr_open_group(cli,
+ pol_open_domain,
+ group_rid, &pol_open_group))
+ {
+ return False;
+ }
+
+ /* send group info query */
+ if (!samr_query_groupinfo(cli,
+ &pol_open_group,
+ info_level, ctr))
+ {
+ DEBUG(5,("samr_query_groupinfo: error in query group info, level 0x%x\n",
+ info_level));
+ ret = False;
}
- return samr_close(cli, &pol_open_user);
+ return samr_close(cli, &pol_open_group) && ret;
}
/****************************************************************************
@@ -313,7 +424,6 @@ BOOL samr_query_dom_info(struct cli_state *cli,
/* send the data on \PIPE\ */
if (rpc_api_pipe_req(cli, SAMR_QUERY_DOMAIN_INFO, &data, &rdata))
{
-#if 0
SAMR_R_QUERY_DOMAIN_INFO r_e;
BOOL p;
@@ -331,7 +441,6 @@ BOOL samr_query_dom_info(struct cli_state *cli,
{
valid_un8 = True;
}
-#endif
}
prs_mem_free(&data );
@@ -341,6 +450,188 @@ BOOL samr_query_dom_info(struct cli_state *cli,
}
/****************************************************************************
+do a SAMR enumerate groups
+****************************************************************************/
+BOOL samr_enum_dom_groups(struct cli_state *cli,
+ POLICY_HND *pol, uint32 size,
+ struct acct_info **sam,
+ int *num_sam_groups)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_ENUM_DOM_GROUPS q_e;
+ BOOL valid_pol = False;
+
+ DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
+
+ if (pol == NULL || num_sam_groups == NULL) return False;
+
+ /* create and send a MSRPC command with api SAMR_ENUM_DOM_GROUPS */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ /* store the parameters */
+ make_samr_q_enum_dom_groups(&q_e, pol, 3, 0, size);
+
+ /* turn parameters into data stream */
+ samr_io_q_enum_dom_groups("", &q_e, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_ENUM_DOM_GROUPS, &data, &rdata))
+ {
+ SAMR_R_ENUM_DOM_GROUPS r_e;
+ BOOL p;
+
+ samr_io_r_enum_dom_groups("", &r_e, &rdata, 0);
+
+ p = rdata.offset != 0;
+ if (p && r_e.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_ENUM_DOM_GROUPS: %s\n", get_nt_error_msg(r_e.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ int i;
+ int name_idx = 0;
+ int desc_idx = 0;
+
+ *num_sam_groups = r_e.num_entries2;
+ if (*num_sam_groups > MAX_SAM_ENTRIES)
+ {
+ *num_sam_groups = MAX_SAM_ENTRIES;
+ DEBUG(2,("samr_enum_dom_groups: sam user entries limited to %d\n",
+ *num_sam_groups));
+ }
+
+ *sam = (struct acct_info*) malloc(sizeof(struct acct_info) * (*num_sam_groups));
+
+ if ((*sam) == NULL)
+ {
+ *num_sam_groups = 0;
+ }
+
+ for (i = 0; i < *num_sam_groups; i++)
+ {
+ (*sam)[i].rid = r_e.sam[i].rid_grp;
+ (*sam)[i].acct_name[0] = 0;
+ (*sam)[i].acct_desc[0] = 0;
+ if (r_e.sam[i].hdr_grp_name.buffer)
+ {
+ fstrcpy((*sam)[i].acct_name, unistr2_to_str(&r_e.str[name_idx].uni_grp_name));
+ name_idx++;
+ }
+ if (r_e.sam[i].hdr_grp_desc.buffer)
+ {
+ fstrcpy((*sam)[i].acct_desc, unistr2_to_str(&r_e.str[desc_idx].uni_grp_desc));
+ desc_idx++;
+ }
+ DEBUG(5,("samr_enum_dom_groups: idx: %4d rid: %8x acct: %s desc: %s\n",
+ i, (*sam)[i].rid, (*sam)[i].acct_name, (*sam)[i].acct_desc));
+ }
+ valid_pol = True;
+ }
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_pol;
+}
+
+/****************************************************************************
+do a SAMR enumerate aliases
+****************************************************************************/
+BOOL samr_enum_dom_aliases(struct cli_state *cli,
+ POLICY_HND *pol, uint32 size,
+ struct acct_info **sam,
+ int *num_sam_aliases)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_ENUM_DOM_ALIASES q_e;
+ BOOL valid_pol = False;
+
+ DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
+
+ if (pol == NULL || num_sam_aliases == NULL) return False;
+
+ /* create and send a MSRPC command with api SAMR_ENUM_DOM_ALIASES */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ /* store the parameters */
+ make_samr_q_enum_dom_aliases(&q_e, pol, size);
+
+ /* turn parameters into data stream */
+ samr_io_q_enum_dom_aliases("", &q_e, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_ENUM_DOM_ALIASES, &data, &rdata))
+ {
+ SAMR_R_ENUM_DOM_ALIASES r_e;
+ BOOL p;
+
+ samr_io_r_enum_dom_aliases("", &r_e, &rdata, 0);
+
+ p = rdata.offset != 0;
+ if (p && r_e.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_ENUM_DOM_ALIASES: %s\n", get_nt_error_msg(r_e.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ int i;
+ int name_idx = 0;
+
+ *num_sam_aliases = r_e.num_entries2;
+ if (*num_sam_aliases > MAX_SAM_ENTRIES)
+ {
+ *num_sam_aliases = MAX_SAM_ENTRIES;
+ DEBUG(2,("samr_enum_dom_aliases: sam user entries limited to %d\n",
+ *num_sam_aliases));
+ }
+
+ *sam = (struct acct_info*) malloc(sizeof(struct acct_info) * (*num_sam_aliases));
+
+ if ((*sam) == NULL)
+ {
+ *num_sam_aliases = 0;
+ }
+
+ for (i = 0; i < *num_sam_aliases; i++)
+ {
+ (*sam)[i].rid = r_e.sam[i].rid;
+ (*sam)[i].acct_name[0] = 0;
+ (*sam)[i].acct_desc[0] = 0;
+ if (r_e.sam[i].hdr_name.buffer)
+ {
+ fstrcpy((*sam)[i].acct_name, unistr2_to_str(&r_e.uni_grp_name[name_idx]));
+ name_idx++;
+ }
+ DEBUG(5,("samr_enum_dom_aliases: idx: %4d rid: %8x acct: %s\n",
+ i, (*sam)[i].rid, (*sam)[i].acct_name));
+ }
+ valid_pol = True;
+ }
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_pol;
+}
+
+/****************************************************************************
do a SAMR enumerate users
****************************************************************************/
BOOL samr_enum_dom_users(struct cli_state *cli,
@@ -410,21 +701,16 @@ BOOL samr_enum_dom_users(struct cli_state *cli,
for (i = 0; i < *num_sam_users; i++)
{
-
- (*sam)[i].user_rid = r_e.sam[i].rid;
+ (*sam)[i].rid = r_e.sam[i].rid;
+ (*sam)[i].acct_name[0] = 0;
+ (*sam)[i].acct_desc[0] = 0;
if (r_e.sam[i].hdr_name.buffer)
{
- char *acct_name = unistrn2(r_e.uni_acct_name[name_idx].buffer,
- r_e.uni_acct_name[name_idx].uni_str_len);
- fstrcpy((*sam)[i].acct_name, acct_name);
+ fstrcpy((*sam)[i].acct_name, unistr2_to_str(&r_e.uni_acct_name[name_idx]));
name_idx++;
}
- else
- {
- bzero((*sam)[i].acct_name, sizeof((*sam)[i].acct_name));
- }
DEBUG(5,("samr_enum_dom_users: idx: %4d rid: %8x acct: %s\n",
- i, (*sam)[i].user_rid, (*sam)[i].acct_name));
+ i, (*sam)[i].rid, (*sam)[i].acct_name));
}
valid_pol = True;
}
@@ -610,6 +896,61 @@ BOOL samr_open_alias(struct cli_state *cli,
}
/****************************************************************************
+do a SAMR Add Alias Member
+****************************************************************************/
+BOOL samr_add_aliasmem(struct cli_state *cli,
+ POLICY_HND *alias_pol, DOM_SID *sid)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_ADD_ALIASMEM q_o;
+ BOOL valid_pol = False;
+
+ if (alias_pol == NULL || sid == NULL) return False;
+
+ /* create and send a MSRPC command with api SAMR_ADD_ALIASMEM */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ DEBUG(4,("SAMR Add Alias Member.\n"));
+
+ /* store the parameters */
+ make_samr_q_add_aliasmem(&q_o, alias_pol, sid);
+
+ /* turn parameters into data stream */
+ samr_io_q_add_aliasmem("", &q_o, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_ADD_ALIASMEM, &data, &rdata))
+ {
+ SAMR_R_ADD_ALIASMEM r_o;
+ BOOL p;
+
+ samr_io_r_add_aliasmem("", &r_o, &rdata, 0);
+ p = rdata.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_ADD_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ valid_pol = True;
+ }
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_pol;
+}
+
+/****************************************************************************
do a SAMR Create Domain Alias
****************************************************************************/
BOOL samr_create_dom_alias(struct cli_state *cli,
@@ -780,6 +1121,61 @@ BOOL samr_open_group(struct cli_state *cli,
}
/****************************************************************************
+do a SAMR Add Group Member
+****************************************************************************/
+BOOL samr_add_groupmem(struct cli_state *cli,
+ POLICY_HND *group_pol, uint32 rid)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_ADD_GROUPMEM q_o;
+ BOOL valid_pol = False;
+
+ if (group_pol == NULL) return False;
+
+ /* create and send a MSRPC command with api SAMR_ADD_GROUPMEM */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ DEBUG(4,("SAMR Add Group Member.\n"));
+
+ /* store the parameters */
+ make_samr_q_add_groupmem(&q_o, group_pol, rid);
+
+ /* turn parameters into data stream */
+ samr_io_q_add_groupmem("", &q_o, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_ADD_GROUPMEM, &data, &rdata))
+ {
+ SAMR_R_ADD_GROUPMEM r_o;
+ BOOL p;
+
+ samr_io_r_add_groupmem("", &r_o, &rdata, 0);
+ p = rdata.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_ADD_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ valid_pol = True;
+ }
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_pol;
+}
+
+/****************************************************************************
do a SAMR Create Domain Group
****************************************************************************/
BOOL samr_create_dom_group(struct cli_state *cli,
@@ -896,7 +1292,7 @@ BOOL samr_set_groupinfo(struct cli_state *cli,
do a SAMR Open Domain
****************************************************************************/
BOOL samr_open_domain(struct cli_state *cli,
- POLICY_HND *connect_pol, uint32 rid, DOM_SID *sid,
+ POLICY_HND *connect_pol, uint32 flags, DOM_SID *sid,
POLICY_HND *domain_pol)
{
pstring sid_str;
@@ -907,7 +1303,7 @@ BOOL samr_open_domain(struct cli_state *cli,
BOOL valid_pol = False;
sid_to_string(sid_str, sid);
- DEBUG(4,("SAMR Open Domain. SID:%s RID:%x\n", sid_str, rid));
+ DEBUG(4,("SAMR Open Domain. SID:%s Flags:%x\n", sid_str, flags));
if (connect_pol == NULL || sid == NULL || domain_pol == NULL) return False;
@@ -917,7 +1313,7 @@ BOOL samr_open_domain(struct cli_state *cli,
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
/* store the parameters */
- make_samr_q_open_domain(&q_o, connect_pol, rid, sid);
+ make_samr_q_open_domain(&q_o, connect_pol, flags, sid);
/* turn parameters into data stream */
samr_io_q_open_domain("", &q_o, &data, 0);
@@ -952,10 +1348,11 @@ BOOL samr_open_domain(struct cli_state *cli,
}
/****************************************************************************
-do a SAMR Query Unknown 12
+do a SAMR Query Lookup RIDS
****************************************************************************/
-BOOL samr_query_unknown_12(struct cli_state *cli,
- POLICY_HND *pol, uint32 rid, uint32 num_gids, uint32 *gids,
+BOOL samr_query_lookup_rids(struct cli_state *cli,
+ POLICY_HND *pol, uint32 flags,
+ uint32 num_rids, uint32 *rids,
uint32 *num_names,
fstring names[MAX_LOOKUP_SIDS],
uint32 type [MAX_LOOKUP_SIDS])
@@ -963,38 +1360,38 @@ BOOL samr_query_unknown_12(struct cli_state *cli,
prs_struct data;
prs_struct rdata;
- SAMR_Q_UNKNOWN_12 q_o;
+ SAMR_Q_LOOKUP_RIDS q_o;
BOOL valid_query = False;
- if (pol == NULL || rid == 0 || num_gids == 0 || gids == NULL ||
+ if (pol == NULL || flags == 0 || num_rids == 0 || rids == NULL ||
num_names == NULL || names == NULL || type == NULL ) return False;
- /* create and send a MSRPC command with api SAMR_UNKNOWN_12 */
+ /* create and send a MSRPC command with api SAMR_LOOKUP_RIDS */
prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
- DEBUG(4,("SAMR Query Unknown 12.\n"));
+ DEBUG(4,("SAMR Query Lookup RIDs.\n"));
/* store the parameters */
- make_samr_q_unknown_12(&q_o, pol, rid, num_gids, gids);
+ make_samr_q_lookup_rids(&q_o, pol, flags, num_rids, rids);
/* turn parameters into data stream */
- samr_io_q_unknown_12("", &q_o, &data, 0);
+ samr_io_q_lookup_rids("", &q_o, &data, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, SAMR_UNKNOWN_12, &data, &rdata))
+ if (rpc_api_pipe_req(cli, SAMR_LOOKUP_RIDS, &data, &rdata))
{
- SAMR_R_UNKNOWN_12 r_o;
+ SAMR_R_LOOKUP_RIDS r_o;
BOOL p;
- samr_io_r_unknown_12("", &r_o, &rdata, 0);
+ samr_io_r_lookup_rids("", &r_o, &rdata, 0);
p = rdata.offset != 0;
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_UNKNOWN_12: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(0,("SAMR_R_LOOKUP_RIDS: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
@@ -1036,6 +1433,67 @@ BOOL samr_query_unknown_12(struct cli_state *cli,
}
/****************************************************************************
+do a SAMR Query Alias Members
+****************************************************************************/
+BOOL samr_query_aliasmem(struct cli_state *cli,
+ POLICY_HND *alias_pol,
+ uint32 *num_mem, DOM_SID2 *sid)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_QUERY_ALIASMEM q_o;
+ BOOL valid_query = False;
+
+ DEBUG(4,("SAMR Query Alias Members.\n"));
+
+ if (alias_pol == NULL || sid == NULL || num_mem == NULL) return False;
+
+ /* create and send a MSRPC command with api SAMR_QUERY_ALIASMEM */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ /* store the parameters */
+ make_samr_q_query_aliasmem(&q_o, alias_pol);
+
+ /* turn parameters into data stream */
+ samr_io_q_query_aliasmem("", &q_o, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_QUERY_ALIASMEM, &data, &rdata))
+ {
+ SAMR_R_QUERY_ALIASMEM r_o;
+ BOOL p;
+
+ /* get user info */
+ r_o.sid = sid;
+
+ samr_io_r_query_aliasmem("", &r_o, &rdata, 0);
+ p = rdata.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_QUERY_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p && r_o.ptr != 0)
+ {
+ valid_query = True;
+ *num_mem = r_o.num_sids;
+ }
+
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_query;
+}
+
+/****************************************************************************
do a SAMR Query User Aliases
****************************************************************************/
BOOL samr_query_useraliases(struct cli_state *cli,
@@ -1097,6 +1555,70 @@ BOOL samr_query_useraliases(struct cli_state *cli,
}
/****************************************************************************
+do a SAMR Query Group Members
+****************************************************************************/
+BOOL samr_query_groupmem(struct cli_state *cli,
+ POLICY_HND *group_pol,
+ uint32 *num_mem, uint32 *rid, uint32 *attr)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_QUERY_GROUPMEM q_o;
+ BOOL valid_query = False;
+
+ DEBUG(4,("SAMR Query Group Members.\n"));
+
+ if (group_pol == NULL || rid == NULL || attr == NULL || num_mem == NULL) return False;
+
+ /* create and send a MSRPC command with api SAMR_QUERY_GROUPMEM */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ /* store the parameters */
+ make_samr_q_query_groupmem(&q_o, group_pol);
+
+ /* turn parameters into data stream */
+ samr_io_q_query_groupmem("", &q_o, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_QUERY_GROUPMEM, &data, &rdata))
+ {
+ SAMR_R_QUERY_GROUPMEM r_o;
+ BOOL p;
+
+ /* get user info */
+ r_o.rid = rid;
+ r_o.attr = attr;
+
+ samr_io_r_query_groupmem("", &r_o, &rdata, 0);
+ p = rdata.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_QUERY_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p && r_o.ptr != 0 &&
+ r_o.ptr_rids != 0 && r_o.ptr_attrs != 0 &&
+ r_o.num_rids == r_o.num_attrs)
+ {
+ valid_query = True;
+ *num_mem = r_o.num_rids;
+ }
+
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_query;
+}
+
+/****************************************************************************
do a SAMR Query User Groups
****************************************************************************/
BOOL samr_query_usergroups(struct cli_state *cli,
@@ -1157,6 +1679,71 @@ BOOL samr_query_usergroups(struct cli_state *cli,
}
/****************************************************************************
+do a SAMR Query Group Info
+****************************************************************************/
+BOOL samr_query_groupinfo(struct cli_state *cli,
+ POLICY_HND *pol,
+ uint16 switch_value, GROUP_INFO_CTR* ctr)
+{
+ prs_struct data;
+ prs_struct rdata;
+
+ SAMR_Q_QUERY_GROUPINFO q_o;
+ BOOL valid_query = False;
+
+ DEBUG(4,("SAMR Query Group Info. level: %d\n", switch_value));
+
+ if (pol == NULL || ctr == NULL || switch_value == 0) return False;
+
+ /* create and send a MSRPC command with api SAMR_QUERY_GROUPINFO */
+
+ prs_init(&data , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
+
+ /* store the parameters */
+ make_samr_q_query_groupinfo(&q_o, pol, switch_value);
+
+ /* turn parameters into data stream */
+ samr_io_q_query_groupinfo("", &q_o, &data, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, SAMR_QUERY_GROUPINFO, &data, &rdata))
+ {
+ SAMR_R_QUERY_GROUPINFO r_o;
+ BOOL p;
+
+ /* get user info */
+ r_o.ctr = ctr;
+
+ samr_io_r_query_groupinfo("", &r_o, &rdata, 0);
+ p = rdata.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SAMR_R_QUERY_GROUPINFO: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p && r_o.ctr->switch_value1 != switch_value)
+ {
+ DEBUG(0,("SAMR_R_QUERY_GROUPINFO: received incorrect level %d\n",
+ r_o.ctr->switch_value1));
+ }
+
+ if (p && r_o.ptr != 0)
+ {
+ valid_query = True;
+ }
+ }
+
+ prs_mem_free(&data );
+ prs_mem_free(&rdata );
+
+ return valid_query;
+}
+
+/****************************************************************************
do a SAMR Query User Info
****************************************************************************/
BOOL samr_query_userinfo(struct cli_state *cli,
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 99f0673c27..a344d0d4ee 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -78,7 +78,7 @@ 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,
+ POLICY_HND *connect_pol, uint32 flags,
DOM_SID *sid)
{
if (q_u == NULL) return;
@@ -86,7 +86,7 @@ void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u,
DEBUG(5,("samr_make_samr_q_open_domain\n"));
memcpy(&q_u->connect_pol, connect_pol, sizeof(q_u->connect_pol));
- q_u->rid = rid;
+ q_u->flags = flags;
make_dom_sid2(&(q_u->dom_sid), sid);
}
@@ -105,7 +105,7 @@ void samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps,
smb_io_pol_hnd("connect_pol", &(q_u->connect_pol), ps, depth);
prs_align(ps);
- prs_uint32("rid", ps, depth, &(q_u->rid));
+ prs_uint32("flags", ps, depth, &(q_u->flags));
smb_io_dom_sid2("sid", &(q_u->dom_sid), ps, depth);
prs_align(ps);
@@ -2544,11 +2544,11 @@ void samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, i
}
/*******************************************************************
-makes a SAMR_Q_UNKNOWN_12 structure.
+makes a SAMR_Q_LOOKUP_RIDS structure.
********************************************************************/
-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_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u,
+ POLICY_HND *pol, uint32 flags,
+ uint32 num_rids, uint32 *rid)
{
int i;
if (q_u == NULL) return;
@@ -2557,28 +2557,28 @@ void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
memcpy(&(q_u->pol), pol, sizeof(*pol));
- q_u->num_gids1 = num_gids;
- q_u->rid = rid;
+ q_u->num_rids1 = num_rids;
+ q_u->flags = flags;
q_u->ptr = 0;
- q_u->num_gids2 = num_gids;
+ q_u->num_rids2 = num_rids;
- for (i = 0; i < num_gids; i++)
+ for (i = 0; i < num_rids; i++)
{
- q_u->gid[i] = gid[i];
+ q_u->rid[i] = rid[i];
}
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth)
+void samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *ps, int depth)
{
int i;
fstring tmp;
if (q_u == NULL) return;
- prs_debug(ps, depth, desc, "samr_io_q_unknown_12");
+ prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
depth++;
prs_align(ps);
@@ -2586,18 +2586,18 @@ void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, i
smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
prs_align(ps);
- prs_uint32("num_gids1", ps, depth, &(q_u->num_gids1));
- prs_uint32("rid ", ps, depth, &(q_u->rid ));
+ prs_uint32("num_rids1", ps, depth, &(q_u->num_rids1));
+ prs_uint32("flags ", ps, depth, &(q_u->flags ));
prs_uint32("ptr ", ps, depth, &(q_u->ptr ));
- prs_uint32("num_gids2", ps, depth, &(q_u->num_gids2));
+ prs_uint32("num_rids2", ps, depth, &(q_u->num_rids2));
- SMB_ASSERT_ARRAY(q_u->gid, q_u->num_gids2);
+ SMB_ASSERT_ARRAY(q_u->rid, q_u->num_rids2);
- for (i = 0; i < q_u->num_gids2; i++)
+ for (i = 0; i < q_u->num_rids2; i++)
{
prs_grow(ps);
- slprintf(tmp, sizeof(tmp) - 1, "gid[%02d] ", i);
- prs_uint32(tmp, ps, depth, &(q_u->gid[i]));
+ slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
+ prs_uint32(tmp, ps, depth, &(q_u->rid[i]));
}
prs_align(ps);
@@ -2605,16 +2605,16 @@ void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, i
/*******************************************************************
-makes a SAMR_R_UNKNOWN_12 structure.
+makes a SAMR_R_LOOKUP_RIDS structure.
********************************************************************/
-void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
+void make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
uint32 num_names, fstring *name, uint8 *type,
uint32 status)
{
int i;
if (r_u == NULL || name == NULL || type == NULL) return;
- DEBUG(5,("make_samr_r_unknown_12\n"));
+ DEBUG(5,("make_samr_r_lookup_rids\n"));
if (status == 0x0)
{
@@ -2653,13 +2653,13 @@ void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
/*******************************************************************
reads or writes a structure.
********************************************************************/
-void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth)
+void samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth)
{
int i;
fstring tmp;
if (r_u == NULL) return;
- prs_debug(ps, depth, desc, "samr_io_r_unknown_12");
+ prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
depth++;
prs_align(ps);
@@ -2870,7 +2870,7 @@ void make_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, POLICY_HND *hnd,
DEBUG(5,("make_samr_q_add_aliasmem\n"));
memcpy(&(q_u->alias_pol), hnd, sizeof(q_u->alias_pol));
- sid_copy(&q_u->sid, sid);
+ make_dom_sid2(&q_u->sid, sid);
}
@@ -2887,7 +2887,7 @@ void samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM *q_u, prs_struct *p
prs_align(ps);
smb_io_pol_hnd("alias_pol", &(q_u->alias_pol), ps, depth);
- smb_io_dom_sid("sid ", &(q_u->sid ), ps, depth);
+ smb_io_dom_sid2("sid ", &(q_u->sid ), ps, depth);
}
/*******************************************************************
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index f010c76614..9ed2409ab2 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -1257,20 +1257,20 @@ static void api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdat
/*******************************************************************
- samr_reply_unknown_12
+ samr_reply_lookup_rids
********************************************************************/
-static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
+static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u,
prs_struct *rdata)
{
fstring group_names[MAX_SAM_ENTRIES];
uint8 group_attrs[MAX_SAM_ENTRIES];
uint32 status = 0;
- int num_gids = q_u->num_gids1;
+ int num_rids = q_u->num_rids1;
DOM_SID pol_sid;
- SAMR_R_UNKNOWN_12 r_u;
+ SAMR_R_LOOKUP_RIDS r_u;
- DEBUG(5,("samr_unknown_12: %d\n", __LINE__));
+ DEBUG(5,("samr_lookup_rids: %d\n", __LINE__));
/* find the policy handle. open a policy on it. */
if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1))
@@ -1286,42 +1286,42 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
if (status == 0x0)
{
int i;
- if (num_gids > MAX_SAM_ENTRIES)
+ if (num_rids > MAX_SAM_ENTRIES)
{
- num_gids = MAX_SAM_ENTRIES;
- DEBUG(5,("samr_unknown_12: truncating entries to %d\n", num_gids));
+ num_rids = MAX_SAM_ENTRIES;
+ DEBUG(5,("samr_lookup_rids: truncating entries to %d\n", num_rids));
}
- for (i = 0; i < num_gids && status == 0; i++)
+ for (i = 0; i < num_rids && status == 0; i++)
{
DOM_SID sid;
sid_copy(&sid, &pol_sid);
- sid_append_rid(&sid, q_u->gid[i]);
+ sid_append_rid(&sid, q_u->rid[i]);
lookup_sid(&sid, group_names[i], &group_attrs[i]);
}
}
- make_samr_r_unknown_12(&r_u, num_gids, group_names, group_attrs, status);
+ make_samr_r_lookup_rids(&r_u, num_rids, group_names, group_attrs, status);
/* store the response in the SMB stream */
- samr_io_r_unknown_12("", &r_u, rdata, 0);
+ samr_io_r_lookup_rids("", &r_u, rdata, 0);
- DEBUG(5,("samr_unknown_12: %d\n", __LINE__));
+ DEBUG(5,("samr_lookup_rids: %d\n", __LINE__));
}
/*******************************************************************
- api_samr_unknown_12
+ api_samr_lookup_rids
********************************************************************/
-static void api_samr_unknown_12( uint16 vuid, prs_struct *data, prs_struct *rdata)
+static void api_samr_lookup_rids( uint16 vuid, prs_struct *data, prs_struct *rdata)
{
- SAMR_Q_UNKNOWN_12 q_u;
+ SAMR_Q_LOOKUP_RIDS q_u;
/* grab the samr lookup names */
- samr_io_q_unknown_12("", &q_u, data, 0);
+ samr_io_q_lookup_rids("", &q_u, data, 0);
/* construct reply. always indicate success */
- samr_reply_unknown_12(&q_u, rdata);
+ samr_reply_lookup_rids(&q_u, rdata);
}
@@ -2085,8 +2085,8 @@ static struct api_struct api_samr_cmds [] =
{ "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , 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_0x32" , 0x32 , api_samr_unknown_32 },
- { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 },
+ { "SAMR_0x32" , SAMR_UNKNOWN_32 , api_samr_unknown_32 },
+ { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids },
{ "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 },
{ "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user },
{ "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias },
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 83d2e40af4..c222d0a0e0 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -65,23 +65,23 @@ void cmd_lsa_query_info(struct client_info *info)
res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC) : False;
/* lookup domain controller; receive a policy handle */
- res = res ? do_lsa_open_policy(smb_cli,
+ res = res ? lsa_open_policy(smb_cli,
srv_name,
&info->dom.lsa_info_pol, False) : False;
/* send client info query, level 3. receive domain name and sid */
- res = res ? do_lsa_query_info_pol(smb_cli,
+ res = res ? lsa_query_info_pol(smb_cli,
&info->dom.lsa_info_pol, 0x03,
info->dom.level3_dom,
&info->dom.level3_sid) : False;
/* send client info query, level 5. receive domain name and sid */
- res = res ? do_lsa_query_info_pol(smb_cli,
+ res = res ? lsa_query_info_pol(smb_cli,
&info->dom.lsa_info_pol, 0x05,
info->dom.level5_dom,
&info->dom.level5_sid) : False;
- res = res ? do_lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
+ res = res ? lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
/* close the session */
cli_nt_session_close(smb_cli);
@@ -160,17 +160,17 @@ void cmd_lsa_lookup_names(struct client_info *info)
res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC) : False;
/* lookup domain controller; receive a policy handle */
- res = res ? do_lsa_open_policy(smb_cli,
+ res = res ? lsa_open_policy(smb_cli,
srv_name,
&info->dom.lsa_info_pol, True) : False;
/* send lsa lookup sids call */
- res = res ? do_lsa_lookup_names(smb_cli,
+ res = res ? lsa_lookup_names(smb_cli,
&info->dom.lsa_info_pol,
num_names, names,
&sids, &num_sids) : False;
- res = res ? do_lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
+ res = res ? lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
/* close the session */
cli_nt_session_close(smb_cli);
@@ -267,17 +267,17 @@ void cmd_lsa_lookup_sids(struct client_info *info)
res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC) : False;
/* lookup domain controller; receive a policy handle */
- res = res ? do_lsa_open_policy(smb_cli,
+ res = res ? lsa_open_policy(smb_cli,
srv_name,
&info->dom.lsa_info_pol, True) : False;
/* send lsa lookup sids call */
- res = res ? do_lsa_lookup_sids(smb_cli,
+ res = res ? lsa_lookup_sids(smb_cli,
&info->dom.lsa_info_pol,
num_sids, sids,
&names, &num_names) : False;
- res = res ? do_lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
+ res = res ? lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
/* close the session */
cli_nt_session_close(smb_cli);
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index a1ff0519f7..13e0829613 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -172,6 +172,97 @@ void cmd_sam_test(struct client_info *info)
}
/****************************************************************************
+SAM add alias member.
+****************************************************************************/
+void cmd_sam_add_aliasmem(struct client_info *info)
+{
+ fstring srv_name;
+ fstring domain;
+ fstring tmp;
+ fstring sid;
+ DOM_SID sid1;
+ POLICY_HND alias_pol;
+ BOOL res = True;
+ BOOL res1 = True;
+ BOOL res2 = True;
+ uint32 flags = 0x200003f3; /* absolutely no idea. */
+ DOM_SID member_sid;
+ uint32 alias_rid;
+
+ sid_copy(&sid1, &info->dom.level5_sid);
+ sid_to_string(sid, &sid1);
+ fstrcpy(domain, info->dom.level5_dom);
+
+ if (sid1.num_auths == 0)
+ {
+ fprintf(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+ return;
+ }
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
+
+ if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
+ {
+ fprintf(out_hnd, "addaliasmem: <alias rid> [member sid1] [member sid2] ...\n");
+ return;
+ }
+ alias_rid = strtoul(tmp, (char**)NULL, 10);
+
+ fprintf(out_hnd, "SAM Create Domain Alias\n");
+
+ /* open SAMR session. negotiate credentials */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR) : False;
+
+ /* establish a connection. */
+ res = res ? samr_connect(smb_cli,
+ srv_name, 0x00000020,
+ &info->dom.samr_pol_connect) : False;
+
+ /* connect to the domain */
+ res = res ? samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, flags, &sid1,
+ &info->dom.samr_pol_open_domain) : False;
+
+ /* connect to the domain */
+ res1 = res ? samr_open_alias(smb_cli,
+ &info->dom.samr_pol_open_domain,
+ alias_rid, &alias_pol) : False;
+
+ while (next_token(NULL, tmp, NULL, sizeof(tmp)) && res2 && res1)
+ {
+ /* get a sid, add a member to the alias */
+ res2 = res2 ? string_to_sid(&member_sid, tmp) : False;
+ res2 = res2 ? samr_add_aliasmem(smb_cli, &alias_pol, &member_sid) : False;
+
+ if (res2)
+ {
+ fprintf(out_hnd, "SID added to Alias 0x%x: %s\n", alias_rid, tmp);
+ }
+ }
+
+ res1 = res1 ? samr_close(smb_cli, &alias_pol) : False;
+ res = res ? samr_close(smb_cli, &info->dom.samr_pol_open_domain) : False;
+ res = res ? samr_close(smb_cli, &info->dom.samr_pol_connect) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli);
+
+ if (res && res1 && res2)
+ {
+ DEBUG(5,("cmd_sam_add_aliasmem: succeeded\n"));
+ fprintf(out_hnd, "Add Domain Alias Member: OK\n");
+ }
+ else
+ {
+ DEBUG(5,("cmd_sam_add_aliasmem: failed\n"));
+ fprintf(out_hnd, "Add Domain Alias Member: FAILED\n");
+ }
+}
+
+
+/****************************************************************************
SAM create domain alias.
****************************************************************************/
void cmd_sam_create_dom_alias(struct client_info *info)
@@ -184,7 +275,7 @@ void cmd_sam_create_dom_alias(struct client_info *info)
DOM_SID sid1;
BOOL res = True;
BOOL res1 = True;
- uint32 admin_rid = 0x200003f3; /* absolutely no idea. */
+ uint32 flags = 0x200003f3; /* absolutely no idea. */
uint32 alias_rid;
sid_copy(&sid1, &info->dom.level5_sid);
@@ -227,10 +318,10 @@ void cmd_sam_create_dom_alias(struct client_info *info)
/* connect to the domain */
res = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid1,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
- /* read some users */
+ /* create a domain alias */
res1 = res ? create_samr_domain_alias(smb_cli,
&info->dom.samr_pol_open_domain,
acct_name, acct_desc, &alias_rid) : False;
@@ -258,6 +349,97 @@ void cmd_sam_create_dom_alias(struct client_info *info)
/****************************************************************************
+SAM add group member.
+****************************************************************************/
+void cmd_sam_add_groupmem(struct client_info *info)
+{
+ fstring srv_name;
+ fstring domain;
+ fstring tmp;
+ fstring sid;
+ DOM_SID sid1;
+ POLICY_HND group_pol;
+ BOOL res = True;
+ BOOL res1 = True;
+ BOOL res2 = True;
+ uint32 flags = 0x200003f3; /* absolutely no idea. */
+ uint32 member_rid;
+ uint32 group_rid;
+
+ sid_copy(&sid1, &info->dom.level5_sid);
+ sid_to_string(sid, &sid1);
+ fstrcpy(domain, info->dom.level5_dom);
+
+ if (sid1.num_auths == 0)
+ {
+ fprintf(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+ return;
+ }
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
+
+ if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
+ {
+ fprintf(out_hnd, "addgroupmem: <group rid> [member rid1] [member rid2] ...\n");
+ return;
+ }
+ group_rid = strtoul(tmp, (char**)NULL, 10);
+
+ fprintf(out_hnd, "SAM Create Domain Group\n");
+
+ /* open SAMR session. negotiate credentials */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR) : False;
+
+ /* establish a connection. */
+ res = res ? samr_connect(smb_cli,
+ srv_name, 0x00000020,
+ &info->dom.samr_pol_connect) : False;
+
+ /* connect to the domain */
+ res = res ? samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, flags, &sid1,
+ &info->dom.samr_pol_open_domain) : False;
+
+ /* connect to the domain */
+ res1 = res ? samr_open_group(smb_cli,
+ &info->dom.samr_pol_open_domain,
+ group_rid, &group_pol) : False;
+
+ while (next_token(NULL, tmp, NULL, sizeof(tmp)) && res2 && res1)
+ {
+ /* get a rid, add a member to the group */
+ member_rid = get_number(tmp);
+ res2 = res2 ? samr_add_groupmem(smb_cli, &group_pol, member_rid) : False;
+
+ if (res2)
+ {
+ fprintf(out_hnd, "RID added to Group 0x%x: 0x%x\n", group_rid, member_rid);
+ }
+ }
+
+ res1 = res1 ? samr_close(smb_cli, &group_pol) : False;
+ res = res ? samr_close(smb_cli, &info->dom.samr_pol_open_domain) : False;
+ res = res ? samr_close(smb_cli, &info->dom.samr_pol_connect) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli);
+
+ if (res && res1 && res2)
+ {
+ DEBUG(5,("cmd_sam_add_groupmem: succeeded\n"));
+ fprintf(out_hnd, "Add Domain Group Member: OK\n");
+ }
+ else
+ {
+ DEBUG(5,("cmd_sam_add_groupmem: failed\n"));
+ fprintf(out_hnd, "Add Domain Group Member: FAILED\n");
+ }
+}
+
+
+/****************************************************************************
SAM create domain group.
****************************************************************************/
void cmd_sam_create_dom_group(struct client_info *info)
@@ -270,7 +452,7 @@ void cmd_sam_create_dom_group(struct client_info *info)
DOM_SID sid1;
BOOL res = True;
BOOL res1 = True;
- uint32 admin_rid = 0x220; /* absolutely no idea. */
+ uint32 flags = 0x220; /* absolutely no idea. */
uint32 group_rid;
sid_copy(&sid1, &info->dom.level5_sid);
@@ -313,7 +495,7 @@ void cmd_sam_create_dom_group(struct client_info *info)
/* connect to the domain */
res = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid1,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
/* read some users */
@@ -363,7 +545,7 @@ void cmd_sam_enum_users(struct client_info *info)
uint16 unk_0 = 0x0;
uint16 acb_mask = 0;
uint16 unk_1 = 0x0;
- uint32 admin_rid = 0x304; /* absolutely no idea. */
+ uint32 flags = 0x304; /* absolutely no idea. */
fstring tmp;
int i;
@@ -440,14 +622,16 @@ void cmd_sam_enum_users(struct client_info *info)
/* connect to the domain */
res = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid1,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
/* connect to the S-1-5-20 domain */
res1 = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid_1_5_20,
+ &info->dom.samr_pol_connect, flags, &sid_1_5_20,
&info->dom.samr_pol_open_builtindom) : False;
+ info->dom.sam = NULL;
+
/* read some users */
res = res ? samr_enum_dom_users(smb_cli,
&info->dom.samr_pol_open_domain,
@@ -462,7 +646,7 @@ void cmd_sam_enum_users(struct client_info *info)
/* query all the users */
for (user_idx = 0; res && user_idx < info->dom.num_sam_entries; user_idx++)
{
- uint32 user_rid = info->dom.sam[user_idx].user_rid;
+ uint32 user_rid = info->dom.sam[user_idx].rid;
SAM_USER_INFO_21 usr;
fprintf(out_hnd, "User RID: %8x User Name: %s\n",
@@ -492,9 +676,25 @@ void cmd_sam_enum_users(struct client_info *info)
&info->dom.samr_pol_open_domain,
user_rid, &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);
+ uint32 num_names;
+ uint32 rid_mem[MAX_LOOKUP_SIDS];
+ fstring name [MAX_LOOKUP_SIDS];
+ uint32 type [MAX_LOOKUP_SIDS];
+
+ for (i = 0; i < num_groups; i++)
+ {
+ rid_mem[i] = gid[i].g_rid;
+ }
+
+ if (samr_query_lookup_rids(smb_cli,
+ &info->dom.samr_pol_open_domain, 0x3e8,
+ num_groups, rid_mem,
+ &num_names, name, type))
+ {
+ display_group_members(out_hnd, ACTION_HEADER , num_names, name, type);
+ display_group_members(out_hnd, ACTION_ENUMERATE, num_names, name, type);
+ display_group_members(out_hnd, ACTION_FOOTER , num_names, name, type);
+ }
}
}
@@ -512,9 +712,19 @@ void cmd_sam_enum_users(struct client_info *info)
&info->dom.samr_pol_open_domain,
&als_sid, &num_aliases, rid))
{
- display_alias_rid_info(out_hnd, ACTION_HEADER , &sid1, num_aliases, rid);
- display_alias_rid_info(out_hnd, ACTION_ENUMERATE, &sid1, num_aliases, rid);
- display_alias_rid_info(out_hnd, ACTION_FOOTER , &sid1, num_aliases, rid);
+ uint32 num_names;
+ fstring name [MAX_LOOKUP_SIDS];
+ uint32 type [MAX_LOOKUP_SIDS];
+
+ if (samr_query_lookup_rids(smb_cli,
+ &info->dom.samr_pol_open_domain, 0x3e8,
+ num_aliases, rid,
+ &num_names, name, type))
+ {
+ display_group_members(out_hnd, ACTION_HEADER , num_names, name, type);
+ display_group_members(out_hnd, ACTION_ENUMERATE, num_names, name, type);
+ display_group_members(out_hnd, ACTION_FOOTER , num_names, name, type);
+ }
}
/* send user alias query */
@@ -522,9 +732,19 @@ void cmd_sam_enum_users(struct client_info *info)
&info->dom.samr_pol_open_builtindom,
&als_sid, &num_aliases, rid))
{
- display_alias_rid_info(out_hnd, ACTION_HEADER , &sid_1_5_20, num_aliases, rid);
- display_alias_rid_info(out_hnd, ACTION_ENUMERATE, &sid_1_5_20, num_aliases, rid);
- display_alias_rid_info(out_hnd, ACTION_FOOTER , &sid_1_5_20, num_aliases, rid);
+ uint32 num_names;
+ fstring name [MAX_LOOKUP_SIDS];
+ uint32 type [MAX_LOOKUP_SIDS];
+
+ if (samr_query_lookup_rids(smb_cli,
+ &info->dom.samr_pol_open_builtindom, 0x3e8,
+ num_aliases, rid,
+ &num_names, name, type))
+ {
+ display_group_members(out_hnd, ACTION_HEADER , num_names, name, type);
+ display_group_members(out_hnd, ACTION_ENUMERATE, num_names, name, type);
+ display_group_members(out_hnd, ACTION_FOOTER , num_names, name, type);
+ }
}
}
}
@@ -568,7 +788,7 @@ void cmd_sam_query_user(struct client_info *info)
DOM_SID sid1;
int user_idx = 0; /* FIXME maybe ... */
BOOL res = True;
- uint32 admin_rid = 0x304; /* absolutely no idea. */
+ uint32 flags = 0x304; /* absolutely no idea. */
fstring rid_str ;
fstring info_str;
uint32 user_rid = 0;
@@ -594,8 +814,8 @@ void cmd_sam_query_user(struct client_info *info)
if (next_token(NULL, rid_str , NULL, sizeof(rid_str )) &&
next_token(NULL, info_str, NULL, sizeof(info_str)))
{
- user_rid = (uint32)strtol(rid_str , (char**)NULL, 16);
- info_level = (uint32)strtol(info_str, (char**)NULL, 10);
+ user_rid = strtoul(rid_str , (char**)NULL, 16);
+ info_level = strtoul(info_str, (char**)NULL, 10);
}
fprintf(out_hnd, "SAM Query User: rid %x info level %d\n",
@@ -613,7 +833,7 @@ void cmd_sam_query_user(struct client_info *info)
/* connect to the domain */
res = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid1,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
fprintf(out_hnd, "User RID: %8x User Name: %s\n",
@@ -654,9 +874,9 @@ void cmd_sam_query_user(struct client_info *info)
/****************************************************************************
-experimental SAM groups query.
+experimental SAM domain info query.
****************************************************************************/
-void cmd_sam_query_groups(struct client_info *info)
+void cmd_sam_query_dominfo(struct client_info *info)
{
fstring srv_name;
fstring domain;
@@ -665,7 +885,7 @@ void cmd_sam_query_groups(struct client_info *info)
BOOL res = True;
fstring info_str;
uint32 switch_value = 2;
- uint32 admin_rid = 0x304; /* absolutely no idea. */
+ uint32 flags = 0x304; /* absolutely no idea. */
sid_to_string(sid, &info->dom.level5_sid);
fstrcpy(domain, info->dom.level5_dom);
@@ -684,10 +904,10 @@ void cmd_sam_query_groups(struct client_info *info)
if (next_token(NULL, info_str, NULL, sizeof(info_str)))
{
- switch_value = (uint32)strtol(info_str, (char**)NULL, 10);
+ switch_value = strtoul(info_str, (char**)NULL, 10);
}
- fprintf(out_hnd, "SAM Query Groups: info level %d\n", switch_value);
+ fprintf(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
fprintf(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
info->myhostname, srv_name, domain, sid);
@@ -701,7 +921,7 @@ void cmd_sam_query_groups(struct client_info *info)
/* connect to the domain */
res = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid1,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
/* send a samr 0x8 command */
@@ -719,11 +939,11 @@ void cmd_sam_query_groups(struct client_info *info)
if (res)
{
- DEBUG(5,("cmd_sam_query_groups: succeeded\n"));
+ DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
}
else
{
- DEBUG(5,("cmd_sam_query_groups: failed\n"));
+ DEBUG(5,("cmd_sam_query_dominfo: failed\n"));
}
}
@@ -738,15 +958,10 @@ void cmd_sam_enum_aliases(struct client_info *info)
fstring sid;
DOM_SID sid1;
BOOL res = True;
- BOOL request_user_info = False;
- BOOL request_alias_info = False;
- uint32 admin_rid = 0x304; /* absolutely no idea. */
+ BOOL request_member_info = False;
+ uint32 flags = 0x304; /* absolutely no idea. */
fstring tmp;
-
- uint32 num_aliases = 3;
- uint32 alias_rid[3] = { DOMAIN_GROUP_RID_ADMINS, DOMAIN_GROUP_RID_USERS, DOMAIN_GROUP_RID_GUESTS };
- fstring alias_names [3];
- uint32 num_als_usrs[3];
+ uint32 alias_idx;
sid_to_string(sid, &info->dom.level3_sid);
fstrcpy(domain, info->dom.level3_dom);
@@ -768,14 +983,7 @@ void cmd_sam_enum_aliases(struct client_info *info)
/* a bad way to do token parsing... */
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, sizeof(tmp)))
- {
- request_user_info |= strequal(tmp, "-u");
- request_alias_info |= strequal(tmp, "-g");
+ request_member_info |= strequal(tmp, "-m");
}
fprintf(out_hnd, "SAM Enumerate Aliases\n");
@@ -792,98 +1000,260 @@ void cmd_sam_enum_aliases(struct client_info *info)
/* connect to the domain */
res = res ? samr_open_domain(smb_cli,
- &info->dom.samr_pol_connect, admin_rid, &sid1,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
- /* send a query on the aliases */
- res = res ? 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;
+ info->dom.sam = NULL;
- if (res)
+ /* read some aliases */
+ res = res ? samr_enum_dom_aliases(smb_cli,
+ &info->dom.samr_pol_open_domain,
+ 0xffff,
+ &info->dom.sam, &info->dom.num_sam_entries) : False;
+
+ if (res && info->dom.num_sam_entries == 0)
{
- 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);
+ fprintf(out_hnd, "No aliases\n");
}
-#if 0
- /* read some users */
- res = res ? 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;
+ for (alias_idx = 0; alias_idx < info->dom.num_sam_entries; alias_idx++)
+ {
+ uint32 alias_rid = info->dom.sam[alias_idx].rid;
- if (res && info->dom.num_sam_entries == 0)
+ fprintf(out_hnd, "Alias RID: %8x Group Name: %s\n",
+ alias_rid,
+ info->dom.sam[alias_idx].acct_name);
+
+ if (request_member_info)
+ {
+ uint32 num_aliases;
+ DOM_SID2 sid_mem[MAX_LOOKUP_SIDS];
+
+ /* send user aliases query */
+ if (get_samr_query_aliasmem(smb_cli,
+ &info->dom.samr_pol_open_domain,
+ alias_rid, &num_aliases, sid_mem))
+ {
+ BOOL res3 = True;
+ BOOL res4 = True;
+ char **names = NULL;
+ int num_names = 0;
+ DOM_SID **sids = NULL;
+ int i;
+
+ /* jeremy, you removed all the independent fnums
+ * i put into the nt client code. this is the reason
+ * why they are all needed.
+ */
+ uint16 old_fnum = smb_cli->nt_pipe_fnum;
+
+ if (num_aliases != 0)
{
- fprintf(out_hnd, "No users\n");
+ sids = malloc(num_aliases * sizeof(DOM_SID*));
}
- if (request_user_info || request_alias_info)
+ res3 = sids != NULL;
+ if (res3)
{
- /* query all the users */
- user_idx = 0;
-
- while (res && user_idx < info->dom.num_sam_entries)
+ for (i = 0; i < num_aliases; i++)
{
- uint32 user_rid = info->dom.sam[user_idx].user_rid;
- SAM_USER_INFO_21 usr;
+ sids[i] = &sid_mem[i].sid;
+ }
+ }
- fprintf(out_hnd, "User RID: %8x User Name: %s\n",
- user_rid,
- info->dom.sam[user_idx].acct_name);
+ /* open LSARPC session. */
+ res3 = res3 ? cli_nt_session_open(smb_cli, PIPE_LSARPC) : False;
- if (request_user_info)
+ /* lookup domain controller; receive a policy handle */
+ res3 = res3 ? lsa_open_policy(smb_cli,
+ srv_name,
+ &info->dom.lsa_info_pol, True) : False;
+
+ /* send lsa lookup sids call */
+ res4 = res3 ? lsa_lookup_sids(smb_cli,
+ &info->dom.lsa_info_pol,
+ num_aliases, sids,
+ &names, &num_names) : False;
+
+ res3 = res3 ? lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
+
+ cli_nt_session_close(smb_cli);
+
+ smb_cli->nt_pipe_fnum = old_fnum;
+
+ if (res4 && names != NULL)
{
- /* send user info query, level 0x15 */
- if (get_samr_query_userinfo(smb_cli,
- &info->dom.samr_pol_open_domain,
- 0x15, user_rid, &usr))
+ display_alias_members(out_hnd, ACTION_HEADER , num_names, names);
+ display_alias_members(out_hnd, ACTION_ENUMERATE, num_names, names);
+ display_alias_members(out_hnd, ACTION_FOOTER , num_names, names);
+ }
+ if (names != NULL)
{
- 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);
+ for (i = 0; i < num_names; i++)
+ {
+ if (names[i] != NULL)
+ {
+ free(names[i]);
+ }
+ }
+ free(names);
+ }
+ if (sids != NULL)
+ {
+ free(sids);
+ }
+ }
}
}
- if (request_alias_info)
+ res = res ? samr_close(smb_cli,
+ &info->dom.samr_pol_connect) : False;
+
+ res = res ? samr_close(smb_cli,
+ &info->dom.samr_pol_open_domain) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli);
+
+ if (info->dom.sam != NULL)
{
- uint32 num_aliases;
- DOM_GID gid[LSA_MAX_GROUPS];
+ free(info->dom.sam);
+ }
- /* send user aliase query */
- if (get_samr_query_useraliases(smb_cli,
- &info->dom.samr_pol_open_domain,
- user_rid, &num_aliases, gid))
+ if (res)
+ {
+ DEBUG(5,("cmd_sam_enum_aliases: succeeded\n"));
+ }
+ else
{
- 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);
+ DEBUG(5,("cmd_sam_enum_aliases: failed\n"));
}
}
- user_idx++;
+
+/****************************************************************************
+experimental SAM groups query.
+****************************************************************************/
+void cmd_sam_enum_groups(struct client_info *info)
+{
+ fstring srv_name;
+ fstring domain;
+ fstring sid;
+ DOM_SID sid1;
+ BOOL res = True;
+ BOOL request_member_info = False;
+ uint32 flags = 0x304; /* absolutely no idea. */
+ fstring tmp;
+ uint32 group_idx;
+
+ sid_to_string(sid, &info->dom.level3_sid);
+ fstrcpy(domain, info->dom.level3_dom);
+#if 0
+ fstrcpy(sid , "S-1-5-20");
+#endif
+ if (strlen(sid) == 0)
+ {
+ fprintf(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+ return;
}
+
+ string_to_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, sizeof(tmp)))
+ {
+ request_member_info |= strequal(tmp, "-m");
}
-#endif
- res = res ? samr_close(smb_cli,
+ fprintf(out_hnd, "SAM Enumerate Groups\n");
+ fprintf(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
+ info->myhostname, srv_name, domain, sid);
+
+ /* open SAMR session. negotiate credentials */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR) : False;
+
+ /* establish a connection. */
+ res = res ? samr_connect(smb_cli,
+ srv_name, 0x00000020,
&info->dom.samr_pol_connect) : False;
- res = res ? samr_close(smb_cli,
+ /* connect to the domain */
+ res = res ? samr_open_domain(smb_cli,
+ &info->dom.samr_pol_connect, flags, &sid1,
&info->dom.samr_pol_open_domain) : False;
+ info->dom.sam = NULL;
+
+ /* read some groups */
+ res = res ? samr_enum_dom_groups(smb_cli,
+ &info->dom.samr_pol_open_domain,
+ 0xffff,
+ &info->dom.sam, &info->dom.num_sam_entries) : False;
+
+ if (res && info->dom.num_sam_entries == 0)
+ {
+ fprintf(out_hnd, "No groups\n");
+ }
+
+
+ for (group_idx = 0; group_idx < info->dom.num_sam_entries; group_idx++)
+ {
+ uint32 group_rid = info->dom.sam[group_idx].rid;
+
+ fprintf(out_hnd, "Group RID: %8x Group Name: %s Description: %s\n",
+ group_rid,
+ info->dom.sam[group_idx].acct_name,
+ info->dom.sam[group_idx].acct_desc);
+
+ if (request_member_info)
+ {
+ uint32 num_groups;
+ uint32 num_names;
+ uint32 attr_mem[MAX_LOOKUP_SIDS];
+ uint32 rid_mem [MAX_LOOKUP_SIDS];
+ fstring name[MAX_LOOKUP_SIDS];
+ uint32 type[MAX_LOOKUP_SIDS];
+
+ /* send user groups query */
+ if (get_samr_query_groupmem(smb_cli,
+ &info->dom.samr_pol_open_domain,
+ group_rid, &num_groups,
+ rid_mem, attr_mem) &&
+ samr_query_lookup_rids(smb_cli,
+ &info->dom.samr_pol_open_domain, 0x3e8,
+ num_groups, rid_mem,
+ &num_names, name, type))
+ {
+ display_group_members(out_hnd, ACTION_HEADER , num_names, name, type);
+ display_group_members(out_hnd, ACTION_ENUMERATE, num_names, name, type);
+ display_group_members(out_hnd, ACTION_FOOTER , num_names, name, type);
+ }
+ }
+ }
+
+ res = res ? samr_close(smb_cli, &info->dom.samr_pol_connect) : False;
+ res = res ? samr_close(smb_cli, &info->dom.samr_pol_open_domain) : False;
+
/* close the session */
cli_nt_session_close(smb_cli);
+ if (info->dom.sam != NULL)
+ {
+ free(info->dom.sam);
+ }
+
if (res)
{
- DEBUG(5,("cmd_sam_enum_users: succeeded\n"));
+ DEBUG(5,("cmd_sam_enum_groups: succeeded\n"));
}
else
{
- DEBUG(5,("cmd_sam_enum_users: failed\n"));
+ DEBUG(5,("cmd_sam_enum_groups: failed\n"));
}
}
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index 5f63b02c76..8a5844f943 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -24,6 +24,29 @@
/****************************************************************************
+convert a SID_NAME_USE to a string
+****************************************************************************/
+char *get_sid_name_use_str(uint8 sid_name_use)
+{
+ static fstring type;
+
+ switch (sid_name_use)
+ {
+ case SID_NAME_USER : fstrcpy(type, "User" ); break;
+ case SID_NAME_DOM_GRP : fstrcpy(type, "Domain Group" ); break;
+ case SID_NAME_DOMAIN : fstrcpy(type, "Domain" ); break;
+ case SID_NAME_ALIAS : fstrcpy(type, "Local Group" ); break;
+ case SID_NAME_WKN_GRP : fstrcpy(type, "Well-known Group"); break;
+ case SID_NAME_DELETED : fstrcpy(type, "Deleted" ); break;
+ case SID_NAME_INVALID : fstrcpy(type, "Invalid" ); break;
+ case SID_NAME_UNKNOWN :
+ default : fstrcpy(type, "UNKNOWN" ); break;
+ }
+
+ return type;
+}
+
+/****************************************************************************
convert a share mode to a string
****************************************************************************/
char *get_file_mode_str(uint32 share_mode)
@@ -174,8 +197,8 @@ void display_srv_info_101(FILE *out_hnd, enum action_type action,
display_server(out_hnd, action, name, sv101->srv_type, comment);
- fprintf(out_hnd, "\tplatform_id : %d\n" , sv101->platform_id);
- fprintf(out_hnd, "\tos version : %d.%d\n" , sv101->ver_major, sv101->ver_minor);
+ fprintf(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id);
+ fprintf(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor);
break;
}
@@ -217,14 +240,14 @@ void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *s
display_server(out_hnd, action, name, sv102->srv_type, comment);
- fprintf(out_hnd, "\tplatform_id : %d\n" , sv102->platform_id);
- fprintf(out_hnd, "\tos version : %d.%d\n" , sv102->ver_major, sv102->ver_minor);
+ fprintf(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id);
+ fprintf(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor);
- fprintf(out_hnd, "\tusers : %x\n" , sv102->users );
- fprintf(out_hnd, "\tdisc, hidden : %x,%x\n" , sv102->disc , sv102->hidden );
- fprintf(out_hnd, "\tannounce, delta : %d, %d\n", sv102->announce , sv102->ann_delta);
- fprintf(out_hnd, "\tlicenses : %d\n" , sv102->licenses );
- fprintf(out_hnd, "\tuser path : %s\n" , usr_path);
+ fprintf(out_hnd, "\tusers :\t%x\n" , sv102->users );
+ fprintf(out_hnd, "\tdisc, hidden :\t%x,%x\n" , sv102->disc , sv102->hidden );
+ fprintf(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta);
+ fprintf(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses );
+ fprintf(out_hnd, "\tuser path :\t%s\n" , usr_path);
break;
}
@@ -287,7 +310,7 @@ void display_conn_info_0(FILE *out_hnd, enum action_type action,
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\tid: %d\n", info0->id);
+ fprintf(out_hnd, "\tid:\t%d\n", info0->id);
break;
}
@@ -327,14 +350,14 @@ void display_conn_info_1(FILE *out_hnd, enum action_type action,
fstrcpy(usr_name, unistrn2(str1->uni_usr_name.buffer, str1->uni_usr_name.uni_str_len));
fstrcpy(net_name, unistrn2(str1->uni_net_name.buffer, str1->uni_net_name.uni_str_len));
- fprintf(out_hnd, "\tid : %d\n", info1->id);
- fprintf(out_hnd, "\ttype : %s\n", get_share_type_str(info1->type));
- fprintf(out_hnd, "\tnum_opens: %d\n", info1->num_opens);
- fprintf(out_hnd, "\tnum_users: %d\n", info1->num_users);
- fprintf(out_hnd, "\topen_time: %d\n", info1->open_time);
+ fprintf(out_hnd, "\tid :\t%d\n", info1->id);
+ fprintf(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type));
+ fprintf(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens);
+ fprintf(out_hnd, "\tnum_users:\t%d\n", info1->num_users);
+ fprintf(out_hnd, "\topen_time:\t%d\n", info1->open_time);
- fprintf(out_hnd, "\tuser name: %s\n", usr_name);
- fprintf(out_hnd, "\tnet name: %s\n", net_name);
+ fprintf(out_hnd, "\tuser name:\t%s\n", usr_name);
+ fprintf(out_hnd, "\tnet name:\t%s\n", net_name);
break;
}
@@ -678,12 +701,12 @@ void display_file_info_3(FILE *out_hnd, enum action_type action,
fstrcpy(path_name, unistrn2(str3->uni_path_name.buffer, str3->uni_path_name.uni_str_len));
fstrcpy(user_name, unistrn2(str3->uni_user_name.buffer, str3->uni_user_name.uni_str_len));
- fprintf(out_hnd, "\tid : %d\n", info3->id);
- fprintf(out_hnd, "\tperms : %s\n", get_file_mode_str(info3->perms));
- fprintf(out_hnd, "\tnum_locks: %d\n", info3->num_locks);
+ fprintf(out_hnd, "\tid :\t%d\n", info3->id);
+ fprintf(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms));
+ fprintf(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks);
- fprintf(out_hnd, "\tpath name: %s\n", path_name);
- fprintf(out_hnd, "\tuser name: %s\n", user_name);
+ fprintf(out_hnd, "\tpath name:\t%s\n", path_name);
+ fprintf(out_hnd, "\tuser name:\t%s\n", user_name);
break;
}
@@ -867,6 +890,50 @@ void display_name(FILE *out_hnd, enum action_type action,
/****************************************************************************
+ display alias members
+ ****************************************************************************/
+void display_alias_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, char **sid_mem)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_mem == 0)
+ {
+ fprintf(out_hnd, "\tNo Alias Members\n");
+ }
+ else
+ {
+ fprintf(out_hnd, "\tAlias Members:\n");
+ fprintf(out_hnd, "\t-------------\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_mem; i++)
+ {
+ if (sid_mem[i] != NULL)
+ {
+ fprintf(out_hnd, "\tMember Name:\t%s\n", sid_mem[i]);
+ }
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
display alias rid info
****************************************************************************/
void display_alias_rid_info(FILE *out_hnd, enum action_type action,
@@ -881,11 +948,11 @@ void display_alias_rid_info(FILE *out_hnd, enum action_type action,
sid_to_string(sid_str, sid);
if (num_rids == 0)
{
- fprintf(out_hnd, "\tNo Aliases: Sid %s\n", sid_str);
+ fprintf(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
}
else
{
- fprintf(out_hnd, "\tAlias Info: Sid %s\n", sid_str);
+ fprintf(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
fprintf(out_hnd, "\t----------\n");
}
break;
@@ -896,7 +963,48 @@ void display_alias_rid_info(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_rids; i++)
{
- fprintf(out_hnd, "\tAlias RID: %8x\n", rid[i]);
+ fprintf(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display group members
+ ****************************************************************************/
+void display_group_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, fstring *name, uint32 *type)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_mem == 0)
+ {
+ fprintf(out_hnd, "\tNo Members\n");
+ }
+ else
+ {
+ fprintf(out_hnd, "\tMembers:\n");
+ fprintf(out_hnd, "\t-------\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_mem; i++)
+ {
+ fprintf(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
+ name[i], get_sid_name_use_str(type[i]));
}
break;
@@ -910,6 +1018,36 @@ void display_alias_rid_info(FILE *out_hnd, enum action_type action,
}
+#if 0
+
+/****************************************************************************
+ display group info
+ ****************************************************************************/
+void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *info1)
+
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ fprintf(out_hnd, "\tGroup Name:\t%s\tDescription:\t%s\tunk1:\t%sunk2:%s\n",
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+}
+#endif
+
/****************************************************************************
display group rid info
****************************************************************************/
@@ -937,7 +1075,7 @@ void display_group_rid_info(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_gids; i++)
{
- fprintf(out_hnd, "\tGroup RID: %8x attr: %x\n",
+ fprintf(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
gid[i].g_rid, gid[i].attr);
}
@@ -979,7 +1117,7 @@ void display_alias_name_info(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_aliases; i++)
{
- fprintf(out_hnd, "\tAlias Name: %s Attributes: %3d\n",
+ fprintf(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
alias_name[i], num_als_usrs[i]);
}
@@ -1010,33 +1148,33 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t\tUser Name : %s\n", unistrn2(usr->uni_user_name .buffer, usr->uni_user_name .uni_str_len)); /* username unicode string */
- fprintf(out_hnd, "\t\tFull Name : %s\n", unistrn2(usr->uni_full_name .buffer, usr->uni_full_name .uni_str_len)); /* user's full name unicode string */
- fprintf(out_hnd, "\t\tHome Drive : %s\n", unistrn2(usr->uni_home_dir .buffer, usr->uni_home_dir .uni_str_len)); /* home directory unicode string */
- fprintf(out_hnd, "\t\tDir Drive : %s\n", unistrn2(usr->uni_dir_drive .buffer, usr->uni_dir_drive .uni_str_len)); /* home directory drive unicode string */
- fprintf(out_hnd, "\t\tProfile Path: %s\n", unistrn2(usr->uni_profile_path.buffer, usr->uni_profile_path.uni_str_len)); /* profile path unicode string */
- fprintf(out_hnd, "\t\tLogon Script: %s\n", unistrn2(usr->uni_logon_script.buffer, usr->uni_logon_script.uni_str_len)); /* logon script unicode string */
- fprintf(out_hnd, "\t\tDescription : %s\n", unistrn2(usr->uni_acct_desc .buffer, usr->uni_acct_desc .uni_str_len)); /* user description unicode string */
- fprintf(out_hnd, "\t\tWorkstations: %s\n", unistrn2(usr->uni_workstations.buffer, usr->uni_workstations.uni_str_len)); /* workstaions unicode string */
- 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", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
- fprintf(out_hnd, "\t\tLogoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
- fprintf(out_hnd, "\t\tKickoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
- fprintf(out_hnd, "\t\tPassword last set Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
- fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
- fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
+ fprintf(out_hnd, "\t\tUser Name :\t%s\n", unistrn2(usr->uni_user_name .buffer, usr->uni_user_name .uni_str_len)); /* username unicode string */
+ fprintf(out_hnd, "\t\tFull Name :\t%s\n", unistrn2(usr->uni_full_name .buffer, usr->uni_full_name .uni_str_len)); /* user's full name unicode string */
+ fprintf(out_hnd, "\t\tHome Drive :\t%s\n", unistrn2(usr->uni_home_dir .buffer, usr->uni_home_dir .uni_str_len)); /* home directory unicode string */
+ fprintf(out_hnd, "\t\tDir Drive :\t%s\n", unistrn2(usr->uni_dir_drive .buffer, usr->uni_dir_drive .uni_str_len)); /* home directory drive unicode string */
+ fprintf(out_hnd, "\t\tProfile Path:\t%s\n", unistrn2(usr->uni_profile_path.buffer, usr->uni_profile_path.uni_str_len)); /* profile path unicode string */
+ fprintf(out_hnd, "\t\tLogon Script:\t%s\n", unistrn2(usr->uni_logon_script.buffer, usr->uni_logon_script.uni_str_len)); /* logon script unicode string */
+ fprintf(out_hnd, "\t\tDescription :\t%s\n", unistrn2(usr->uni_acct_desc .buffer, usr->uni_acct_desc .uni_str_len)); /* user description unicode string */
+ fprintf(out_hnd, "\t\tWorkstations:\t%s\n", unistrn2(usr->uni_workstations.buffer, usr->uni_workstations.uni_str_len)); /* workstaions unicode string */
+ fprintf(out_hnd, "\t\tUnknown Str :\t%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 :\t%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 :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
+ fprintf(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
+ fprintf(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
+ fprintf(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
+ fprintf(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
+ fprintf(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
- fprintf(out_hnd, "\t\tuser_rid : %x\n" , usr->user_rid ); /* User ID */
- fprintf(out_hnd, "\t\tgroup_rid: %x\n" , usr->group_rid); /* Group ID */
- fprintf(out_hnd, "\t\tacb_info : %04x\n", usr->acb_info ); /* Account Control Info */
+ fprintf(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
+ fprintf(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
+ fprintf(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
- fprintf(out_hnd, "\t\tunknown_3: %08x\n", usr->unknown_3); /* 0x00ff ffff */
- fprintf(out_hnd, "\t\tlogon_divs: %d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
- fprintf(out_hnd, "\t\tunknown_5: %08x\n", usr->unknown_5); /* 0x0002 0000 */
+ fprintf(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
+ fprintf(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
+ fprintf(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
fprintf(out_hnd, "\t\tpadding1[0..7]...\n");
@@ -1133,7 +1271,7 @@ void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *info
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t\tPermissions: %s\n",
+ fprintf(out_hnd, "\t\tPermissions:\t%s\n",
get_sec_mask_str(info->mask));
}
case ACTION_FOOTER:
@@ -1164,7 +1302,7 @@ void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *ace)
display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
sid_to_string(sid_str, &ace->sid);
- fprintf(out_hnd, "\t\tSID: %s\n", sid_str);
+ fprintf(out_hnd, "\t\tSID:\t%s\n", sid_str);
}
case ACTION_FOOTER:
{
@@ -1336,7 +1474,7 @@ static void print_reg_value(FILE *out_hnd, char *val_name, uint32 val_type, BUFF
case 0x04: /* uint32 */
{
- fprintf(out_hnd,"\t%s:\t%s: 0x%08x\n", val_name, type, buffer2_to_uint32(value));
+ fprintf(out_hnd,"\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value));
break;
}
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index ea5abb23bf..68b7356e53 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -130,10 +130,8 @@ struct
{"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!)"},
-#if 0
{"enumgroups", cmd_sam_enum_groups, "SAM Group Database Query (experimental!)"},
-#endif
- {"samgroups", cmd_sam_query_groups, "SAM Group Database Query (experimental!)"},
+ {"samgroups", cmd_sam_query_dominfo, "SAM Query Domain Info(experimental!)"},
{"quit", cmd_quit, "logoff the server"},
{"q", cmd_quit, "logoff the server"},
{"exit", cmd_quit, "logoff the server"},