patch for rpcclient

Todd Sabin tastas at home.com
Mon Mar 8 17:46:37 GMT 1999


Luke wrote:
> todd,
> 
> please re-send without attachments if you are using:
> 
> - outlook depressed
> - eudora 3.0
> - netscape
> 

Actually, I'm using exmh.  As someone recently pointed out on ntdom, the
mailing list software doesn't like multi-line headers.

Here's the patch again, hopefully readable...not sure if the whitespace
will survive correctly.


Todd



Index: rpcclient/cmd_samr.c
===================================================================
RCS file: /cvsroot/samba/source/rpcclient/cmd_samr.c,v
retrieving revision 1.38
diff -c -r1.38 cmd_samr.c
*** cmd_samr.c	1999/02/24 01:51:45	1.38
--- cmd_samr.c	1999/03/08 04:56:28
***************
*** 1093,1099 ****
  	uint16 unk_0 = 0x0;
  	uint16 acb_mask = 0;
  	uint16 unk_1 = 0x0;
! 	uint32 flags = 0x304; /* absolutely no idea. */
  	fstring tmp;
  	int i;
  
--- 1093,1099 ----
  	uint16 unk_0 = 0x0;
  	uint16 acb_mask = 0;
  	uint16 unk_1 = 0x0;
! 	uint32 flags = 0x02000000; /* maximum allowed. */
  	fstring tmp;
  	int i;
  
***************
*** 1191,1302 ****
  		fprintf(out_hnd, "No users\n");
  	}
  
  		/* 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].rid;
  			SAM_USER_INFO_21 usr;
! 
  			fprintf(out_hnd, "User RID: %8x  User Name: %s\n",
! 					  user_rid,
! 					  info->dom.sam[user_idx].acct_name);
! 
  			if (request_user_info)
  			{
  				/* send user info query, level 0x15 */
  				if (get_samr_query_userinfo(smb_cli, fnum,
! 							&info->dom.samr_pol_open_domain,
! 							0x15, user_rid, &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);
  				}
  			}
! 
  			if (request_group_info)
  			{
  				uint32 num_groups;
  				DOM_GID gid[LSA_MAX_GROUPS];
! 
  				/* send user group query */
  				if (get_samr_query_usergroups(smb_cli, fnum,
! 							&info->dom.samr_pol_open_domain,
! 							user_rid, &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, fnum, 
! 						&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);
! 				}
  				}
  			}
! 
  			if (request_alias_info)
  			{
  				uint32 num_aliases;
  				uint32 rid[LSA_MAX_GROUPS];
  				DOM_SID als_sid;
! 
  				sid_copy(&als_sid, &sid1);
  				sid_append_rid(&als_sid, user_rid);
! 
  				/* send user alias query */
  				if (samr_query_useraliases(smb_cli, fnum,
! 				                        &info->dom.samr_pol_open_domain,
! 				                        &als_sid, &num_aliases, rid))
! 				{
! 				uint32 num_names;
! 				fstring name   [MAX_LOOKUP_SIDS];
! 				uint32  type   [MAX_LOOKUP_SIDS];
! 
! 				if (samr_query_lookup_rids(smb_cli, fnum, 
! 						&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 */
! 			if (res1 && samr_query_useraliases(smb_cli, fnum,
! 						&info->dom.samr_pol_open_builtindom,
! 						&als_sid, &num_aliases, rid))
! 			{
! 				uint32 num_names;
! 				fstring name   [MAX_LOOKUP_SIDS];
! 				uint32  type   [MAX_LOOKUP_SIDS];
! 
! 				if (samr_query_lookup_rids(smb_cli, fnum, 
! 						&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);
  				}
  			}
  		}
  	}
! 
  	res1 = res1 ? samr_close(smb_cli, fnum,
  	            &info->dom.samr_pol_open_builtindom) : False;
  
--- 1191,1305 ----
  		fprintf(out_hnd, "No users\n");
  	}
  
+ 	if (res)
+ 	{
  		/* 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].rid;
  			SAM_USER_INFO_21 usr;
! 	
  			fprintf(out_hnd, "User RID: %8x  User Name: %s\n",
! 					user_rid,
! 					info->dom.sam[user_idx].acct_name);
! 	
  			if (request_user_info)
  			{
  				/* send user info query, level 0x15 */
  				if (get_samr_query_userinfo(smb_cli, fnum,
! 								&info->dom.samr_pol_open_domain,
! 								0x15, user_rid, &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);
  				}
  			}
! 	
  			if (request_group_info)
  			{
  				uint32 num_groups;
  				DOM_GID gid[LSA_MAX_GROUPS];
! 	
  				/* send user group query */
  				if (get_samr_query_usergroups(smb_cli, fnum,
! 								&info->dom.samr_pol_open_domain,
! 								user_rid, &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, fnum, 
! 								&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);
! 					}
  				}
  			}
! 	
  			if (request_alias_info)
  			{
  				uint32 num_aliases;
  				uint32 rid[LSA_MAX_GROUPS];
  				DOM_SID als_sid;
! 	
  				sid_copy(&als_sid, &sid1);
  				sid_append_rid(&als_sid, user_rid);
! 	
  				/* send user alias query */
  				if (samr_query_useraliases(smb_cli, fnum,
! 											&info->dom.samr_pol_open_domain,
! 											&als_sid, &num_aliases, rid))
  				{
! 					uint32 num_names;
! 					fstring name   [MAX_LOOKUP_SIDS];
! 					uint32  type   [MAX_LOOKUP_SIDS];
! 	
! 					if (samr_query_lookup_rids(smb_cli, fnum, 
! 							&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 */
! 				if (res1 && samr_query_useraliases(smb_cli, fnum,
! 							&info->dom.samr_pol_open_builtindom,
! 							&als_sid, &num_aliases, rid))
! 				{
! 					uint32 num_names;
! 					fstring name   [MAX_LOOKUP_SIDS];
! 					uint32  type   [MAX_LOOKUP_SIDS];
! 	
! 					if (samr_query_lookup_rids(smb_cli, fnum, 
! 							&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);
! 					}
  				}
  			}
  		}
  	}
! 	
  	res1 = res1 ? samr_close(smb_cli, fnum,
  	            &info->dom.samr_pol_open_builtindom) : False;
  
***************
*** 1510,1521 ****
  	DOM_SID sid1;
  	BOOL res = True;
  	BOOL request_member_info = False;
! 	uint32 flags = 0x200003f3; /* absolutely no idea. */
  	fstring tmp;
  	uint32 alias_idx;
  
! 	sid_to_string(sid, &info->dom.level3_sid);
! 	fstrcpy(domain, info->dom.level3_dom);
  #if 0
  	fstrcpy(sid   , "S-1-5-20");
  #endif
--- 1513,1524 ----
  	DOM_SID sid1;
  	BOOL res = True;
  	BOOL request_member_info = False;
! 	uint32 flags = 0x02000000; /* maximum allowed. */
  	fstring tmp;
  	uint32 alias_idx;
  
! 	sid_to_string(sid, &info->dom.level5_sid);
! 	fstrcpy(domain, info->dom.level5_dom);
  #if 0
  	fstrcpy(sid   , "S-1-5-20");
  #endif
***************
*** 1566,1651 ****
  	{
  		fprintf(out_hnd, "No aliases\n");
  	}
- 
  
! 	for (alias_idx = 0; alias_idx < info->dom.num_sam_entries; alias_idx++)
  	{
! 		uint32 alias_rid = info->dom.sam[alias_idx].rid;
! 
! 		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, fnum, 
! 				&info->dom.samr_pol_open_domain,
! 						alias_rid, &num_aliases, sid_mem))
  			{
! 				uint16 fnum_lsa;
! 				BOOL res3 = True;
! 				BOOL res4 = True;
! 				char **names = NULL;
! 				int num_names = 0;
! 				DOM_SID **sids = NULL;
! 				int i;
! 
! 				if (num_aliases != 0)
! 				{
! 					sids = malloc(num_aliases * sizeof(DOM_SID*));
! 				}
! 
! 				res3 = sids != NULL;
! 				if (res3)
  				{
! 					for (i = 0; i < num_aliases; i++)
  					{
! 						sids[i] = &sid_mem[i].sid;
  					}
! 				}
! 
! 				/* open LSARPC session. */
! 				res3 = res3 ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &fnum_lsa) : False;
! 
! 				/* lookup domain controller; receive a policy handle */
! 				res3 = res3 ? lsa_open_policy(smb_cli, fnum_lsa,
! 							srv_name,
! 							&info->dom.lsa_info_pol, True) : False;
! 
! 				/* send lsa lookup sids call */
! 				res4 = res3 ? lsa_lookup_sids(smb_cli, fnum_lsa, 
! 							       &info->dom.lsa_info_pol,
! 				                               num_aliases, sids, 
! 				                               &names, NULL, &num_names) : False;
! 
! 				res3 = res3 ? lsa_close(smb_cli, fnum_lsa, &info->dom.lsa_info_pol) : False;
! 
! 				cli_nt_session_close(smb_cli, fnum_lsa);
! 
! 				if (res4 && names != NULL)
! 				{
! 					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)
! 				{
! 					for (i = 0; i < num_names; i++)
  					{
! 						if (names[i] != NULL)
  						{
! 							free(names[i]);
  						}
  					}
! 					free(names);
! 				}
! 				if (sids != NULL)
! 				{
! 					free(sids);
  				}
  			}
  		}
--- 1569,1656 ----
  	{
  		fprintf(out_hnd, "No aliases\n");
  	}
  
! 	if (res)
  	{
! 		for (alias_idx = 0; alias_idx < info->dom.num_sam_entries; alias_idx++)
  		{
! 			uint32 alias_rid = info->dom.sam[alias_idx].rid;
! 	
! 			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, fnum, 
! 					&info->dom.samr_pol_open_domain,
! 							alias_rid, &num_aliases, sid_mem))
  				{
! 					uint16 fnum_lsa;
! 					BOOL res3 = True;
! 					BOOL res4 = True;
! 					char **names = NULL;
! 					int num_names = 0;
! 					DOM_SID **sids = NULL;
! 					int i;
! 	
! 					if (num_aliases != 0)
  					{
! 						sids = malloc(num_aliases * sizeof(DOM_SID*));
  					}
! 	
! 					res3 = sids != NULL;
! 					if (res3)
  					{
! 						for (i = 0; i < num_aliases; i++)
  						{
! 							sids[i] = &sid_mem[i].sid;
  						}
  					}
! 	
! 					/* open LSARPC session. */
! 					res3 = res3 ? cli_nt_session_open(smb_cli, PIPE_LSARPC, &fnum_lsa) : False;
! 	
! 					/* lookup domain controller; receive a policy handle */
! 					res3 = res3 ? lsa_open_policy(smb_cli, fnum_lsa,
! 								srv_name,
! 								&info->dom.lsa_info_pol, True) : False;
! 	
! 					/* send lsa lookup sids call */
! 					res4 = res3 ? lsa_lookup_sids(smb_cli, fnum_lsa, 
! 								       &info->dom.lsa_info_pol,
! 								       num_aliases, sids, 
! 								       &names, NULL, &num_names) : False;
! 	
! 					res3 = res3 ? lsa_close(smb_cli, fnum_lsa, &info->dom.lsa_info_pol) : False;
! 	
! 					cli_nt_session_close(smb_cli, fnum_lsa);
! 	
! 					if (res4 && names != NULL)
! 					{
! 						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)
! 					{
! 						for (i = 0; i < num_names; i++)
! 						{
! 							if (names[i] != NULL)
! 							{
! 								free(names[i]);
! 							}
! 						}
! 						free(names);
! 					}
! 					if (sids != NULL)
! 					{
! 						free(sids);
! 					}
  				}
  			}
  		}
***************
*** 1687,1697 ****
  	DOM_SID sid1;
  	BOOL res = True;
  	BOOL request_member_info = False;
! 	uint32 flags = 0x200003f3; /* absolutely no idea. */
  	fstring tmp;
  	uint32 group_idx;
  
! 	sid_copy(&sid1, &info->dom.level3_sid);
  
  	if (sid1.num_auths == 0)
  	{
--- 1692,1702 ----
  	DOM_SID sid1;
  	BOOL res = True;
  	BOOL request_member_info = False;
! 	uint32 flags = 0x02000000; /* maximum allowed. */
  	fstring tmp;
  	uint32 group_idx;
  
! 	sid_copy(&sid1, &info->dom.level5_sid);
  
  	if (sid1.num_auths == 0)
  	{
***************
*** 1743,1786 ****
  	}
  
  
! 	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\n",
! 				  group_rid,
! 				  info->dom.sam[group_idx].acct_name);
! 
! 		if (request_member_info)
  		{
! 			uint32 num_mem;
! 			uint32 rid_mem[MAX_LOOKUP_SIDS];
! 			uint32 attr_mem[MAX_LOOKUP_SIDS];
! 
! 			/* get group members */
! 			if (get_samr_query_groupmem(smb_cli, fnum, 
! 				&info->dom.samr_pol_open_domain,
! 				group_rid, &num_mem, rid_mem, attr_mem))
  			{
! 				BOOL res3 = True;
! 				int num_names = 0;
! 				fstring names[MAX_LOOKUP_SIDS];
! 				uint32 types[MAX_LOOKUP_SIDS];
! 
! 				res3 = samr_query_lookup_rids(smb_cli, fnum,
! 				       &info->dom.samr_pol_open_domain, 1000,
! 				       num_mem, rid_mem, &num_names, names, types);
! 
! 				if (res3)
  				{
! 					display_group_members(out_hnd, ACTION_HEADER   , num_names, names, types);
! 					display_group_members(out_hnd, ACTION_ENUMERATE, num_names, names, types);
! 					display_group_members(out_hnd, ACTION_FOOTER   , num_names, names, types);
  				}
  			}
  		}
  	}
! 
  	res = res ? samr_close(smb_cli, fnum,
  	            &info->dom.samr_pol_open_domain) : False;
  
--- 1748,1794 ----
  	}
  
  
! 	if (res)
  	{
! 		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\n",
! 					  group_rid,
! 					  info->dom.sam[group_idx].acct_name);
! 	
! 			if (request_member_info)
  			{
! 				uint32 num_mem;
! 				uint32 rid_mem[MAX_LOOKUP_SIDS];
! 				uint32 attr_mem[MAX_LOOKUP_SIDS];
! 	
! 				/* get group members */
! 				if (get_samr_query_groupmem(smb_cli, fnum, 
! 					&info->dom.samr_pol_open_domain,
! 					group_rid, &num_mem, rid_mem, attr_mem))
  				{
! 					BOOL res3 = True;
! 					int num_names = 0;
! 					fstring names[MAX_LOOKUP_SIDS];
! 					uint32 types[MAX_LOOKUP_SIDS];
! 	
! 					res3 = samr_query_lookup_rids(smb_cli, fnum,
! 						   &info->dom.samr_pol_open_domain, 1000,
! 						   num_mem, rid_mem, &num_names, names, types);
! 	
! 					if (res3)
! 					{
! 						display_group_members(out_hnd, ACTION_HEADER   , num_names, names, types);
! 						display_group_members(out_hnd, ACTION_ENUMERATE, num_names, names, types);
! 						display_group_members(out_hnd, ACTION_FOOTER   , num_names, names, types);
! 					}
  				}
  			}
  		}
  	}
! 	
  	res = res ? samr_close(smb_cli, fnum,
  	            &info->dom.samr_pol_open_domain) : False;
  
Index: rpc_parse/parse_samr.c
===================================================================
RCS file: /cvsroot/samba/source/rpc_parse/parse_samr.c,v
retrieving revision 1.50
diff -c -r1.50 parse_samr.c
*** parse_samr.c	1999/02/24 01:51:37	1.50
--- parse_samr.c	1999/03/08 04:56:38
***************
*** 1128,1136 ****
  
  		prs_align(ps);
  
- 		prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
  	}
  
  	prs_uint32("status", ps, depth, &(r_u->status));
  }
  
--- 1128,1136 ----
  
  		prs_align(ps);
  
  	}
  
+ 	prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
  	prs_uint32("status", ps, depth, &(r_u->status));
  }
  
***************
*** 2524,2533 ****
  		}
  
  		prs_align(ps);
- 
- 		prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
  	}
  
  	prs_uint32("status", ps, depth, &(r_u->status));
  }
  
--- 2524,2532 ----
  		}
  
  		prs_align(ps);
  	}
  
+ 	prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
  	prs_uint32("status", ps, depth, &(r_u->status));
  }
  
***************
*** 2658,2667 ****
  		}
  
  		prs_align(ps);
- 
- 		prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
  	}
  
  	prs_uint32("status", ps, depth, &(r_u->status));
  }
  
--- 2657,2665 ----
  		}
  
  		prs_align(ps);
  	}
  
+ 	prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
  	prs_uint32("status", ps, depth, &(r_u->status));
  }
  



More information about the samba-technical mailing list