1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00

Back out some of the less well thought out ideas from last weeks work on

winbind default domains, particulary now I understand whats going on a lot
better.  This ensures that the RPC client code does as little 'magic' as
possible - this is up to the application/user.  (Where - for to name->sid code
- it was all along).  This leaves the change that allows the sid->name code to
return domains and usernames in seperate paramaters.

Andrew Bartlett
(This used to be commit 5dfba2cf536f761b0aee314ed9e30dc53900b691)
This commit is contained in:
Andrew Bartlett 2002-01-26 11:48:42 +00:00
parent 670f46fd4c
commit ba8c1c6e45
5 changed files with 24 additions and 33 deletions

View File

@ -336,7 +336,7 @@ NTSTATUS cli_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx,
/** Lookup a list of names */
NTSTATUS cli_lsa_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *pol, int num_names, const char **dom_names, const char **names,
POLICY_HND *pol, int num_names, const char **names,
DOM_SID **sids, uint32 **types, int *num_sids)
{
prs_struct qbuf, rbuf;
@ -356,7 +356,7 @@ NTSTATUS cli_lsa_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx,
/* Marshall data and send request */
init_q_lookup_names(mem_ctx, &q, pol, num_names, dom_names, names);
init_q_lookup_names(mem_ctx, &q, pol, num_names, names);
if (!lsa_io_q_lookup_names("", &q, &qbuf, 0) ||
!rpc_api_pipe_req(cli, LSA_LOOKUPNAMES, &qbuf, &rbuf)) {

View File

@ -177,17 +177,28 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
DOM_SID *sids = NULL;
uint32 *types = NULL;
int num_sids;
const char *domain_name = domain->name;
const char *full_name;
if (!(mem_ctx = talloc_init_named("name_to_sid[rpc]")))
if (!(mem_ctx = talloc_init_named("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
DEBUG(0, ("talloc_init failed!\n"));
return NT_STATUS_NO_MEMORY;
}
if (!(hnd = cm_get_lsa_handle(domain->name)))
if (!(hnd = cm_get_lsa_handle(domain->name))) {
talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
full_name = talloc_asprintf(mem_ctx, "%s\\%s", domain->name, name);
if (!full_name) {
DEBUG(0, ("talloc_asprintf failed!\n"));
talloc_destroy(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
status = cli_lsa_lookup_names(hnd->cli, mem_ctx, &hnd->pol, 1,
&domain_name, &name,
&sids, &types, &num_sids);
&full_name, &sids, &types, &num_sids);
/* Return rid and type if lookup successful */
if (NT_STATUS_IS_OK(status)) {

View File

@ -1045,7 +1045,7 @@ makes a structure.
********************************************************************/
void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
POLICY_HND *hnd, int num_names, const char **dom_names, const char **names)
POLICY_HND *hnd, int num_names, const char **names)
{
int i;
@ -1071,19 +1071,11 @@ void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
}
for (i = 0; i < num_names; i++) {
char *full_name;
int len;
full_name = talloc_asprintf(mem_ctx, "%s\\%s", dom_names[i], names[i]);
if (!full_name) {
DEBUG(0, ("init_q_lookup_names(): out of memory doing talloc_asprintf\n"));
return;
}
len = strlen(full_name);
len = strlen(names[i]);
init_uni_hdr(&q_l->hdr_name[i], len);
init_unistr2(&q_l->uni_name[i], full_name, len);
init_unistr2(&q_l->uni_name[i], names[i], len);
}
}

View File

@ -80,8 +80,6 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli,
DOM_SID *sids;
uint32 *types;
int num_names, i;
fstring name, domain;
const char *name2, *domain2;
if (argc == 1) {
printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
@ -95,15 +93,8 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
/* Lookup the names */
split_domain_name(argv[1], domain, name);
name2 = talloc_strdup(mem_ctx, name);
domain2 = talloc_strdup(mem_ctx, domain);
result = cli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
&domain2, &name2, &sids,
(const char**)(argv + 1), &sids,
&types, &num_names);
if (!NT_STATUS_IS_OK(result))

View File

@ -140,17 +140,14 @@ static BOOL StringToSid(DOM_SID *sid, const char *str)
DOM_SID *sids = NULL;
int num_sids;
BOOL result = True;
fstring name, domain;
if (strncmp(str, "S-", 2) == 0) {
return string_to_sid(sid, str);
}
split_domain_name(str, domain, name);
if (!cacls_open_policy_hnd() ||
!NT_STATUS_IS_OK(cli_lsa_lookup_names(&lsa_cli, lsa_cli.mem_ctx, &pol, 1,
(const char **)&domain, (const char **)&name,
&str,
&sids, &types, &num_sids))) {
result = False;
goto done;