Commit b3876c30 authored by Christof Schmitt's avatar Christof Schmitt Committed by Karolin Seeger

winbind: Return queried domain name from name_to_sid

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13831Signed-off-by: 's avatarChristof Schmitt <cs@samba.org>
Reviewed-by: 's avatarVolker Lendecke <vl@samba.org>
(cherry picked from commit 640e0ef4)
parent b5c442b7
......@@ -224,6 +224,7 @@ struct winbindd_methods {
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *sid,
enum lsa_SidType *type);
......
......@@ -558,11 +558,12 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *sid,
enum lsa_SidType *type)
{
return msrpc_methods.name_to_sid(domain, mem_ctx, domain_name, name,
flags, sid, type);
flags, pdom_name, sid, type);
}
/* convert a domain SID to a user or group name - use rpc methods */
......
......@@ -1818,7 +1818,7 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
winbindd_domain_init_backend(domain);
status = domain->backend->name_to_sid(domain, mem_ctx, domain_name,
name, flags, sid, type);
name, flags, NULL, sid, type);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
......
......@@ -218,6 +218,7 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *sid,
enum lsa_SidType *type)
{
......@@ -268,6 +269,17 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
/* Return rid and type if lookup successful */
if (pdom_name != NULL) {
const char *dom_name;
dom_name = talloc_strdup(mem_ctx, domains[0]);
if (dom_name == NULL) {
return NT_STATUS_NO_MEMORY;
}
*pdom_name = dom_name;
}
sid_copy(sid, &sids[0]);
*type = types[0];
......
......@@ -131,18 +131,19 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *sid,
enum lsa_SidType *type)
{
NTSTATUS result;
result = msrpc_methods.name_to_sid(domain, mem_ctx, domain_name, name,
flags, sid, type);
flags, pdom_name, sid, type);
if (reconnect_need_retry(result, domain))
result = msrpc_methods.name_to_sid(domain, mem_ctx,
domain_name, name, flags,
sid, type);
pdom_name, sid, type);
return result;
}
......
......@@ -137,18 +137,19 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *sid,
enum lsa_SidType *type)
{
NTSTATUS result;
result = ads_methods.name_to_sid(domain, mem_ctx, domain_name, name,
flags, sid, type);
flags, pdom_name, sid, type);
if (reconnect_need_retry(result, domain)) {
result = ads_methods.name_to_sid(domain, mem_ctx,
domain_name, name, flags,
sid, type);
pdom_name, sid, type);
}
return result;
......
......@@ -239,6 +239,7 @@ NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *sid,
enum lsa_SidType *type)
{
......@@ -293,6 +294,17 @@ NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx,
return status;
}
if (pdom_name != NULL) {
const char *dom_name;
dom_name = talloc_strdup(mem_ctx, domains[0]);
if (dom_name == NULL) {
return NT_STATUS_NO_MEMORY;
}
*pdom_name = dom_name;
}
sid_copy(sid, &sids[0]);
*type = types[0];
......
......@@ -53,6 +53,7 @@ NTSTATUS rpc_name_to_sid(TALLOC_CTX *mem_ctx,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *psid,
enum lsa_SidType *ptype);
......
......@@ -581,6 +581,7 @@ static NTSTATUS sam_name_to_sid(struct winbindd_domain *domain,
const char *domain_name,
const char *name,
uint32_t flags,
const char **pdom_name,
struct dom_sid *psid,
enum lsa_SidType *ptype)
{
......@@ -629,6 +630,14 @@ again:
goto done;
}
if (pdom_name != NULL) {
*pdom_name = talloc_strdup(mem_ctx, dom_name);
if (*pdom_name == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
}
if (psid) {
sid_copy(psid, &sid);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment