summaryrefslogtreecommitdiffstats
path: root/source/nsswitch/winbindd_util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-03 11:11:14 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-03 11:11:14 +0000
commit789833b44e342c0b5de463ed8f9b5f7474a99f27 (patch)
treebe3689a9e393f211eb3013e8fe5876a48d240d0b /source/nsswitch/winbindd_util.c
parent816e40a51af80a7f703c0451304de406deab3dd8 (diff)
downloadsamba-789833b44e342c0b5de463ed8f9b5f7474a99f27.tar.gz
samba-789833b44e342c0b5de463ed8f9b5f7474a99f27.tar.xz
samba-789833b44e342c0b5de463ed8f9b5f7474a99f27.zip
put sid_to_name behind the winbindd backend interface
I spent quite a while trying to work out how to make this call via ldap and failed. I then found that MS servers seem use rpc for sid_to_name, and it works even when in native mode, I ended up just implementing it via rpc
Diffstat (limited to 'source/nsswitch/winbindd_util.c')
-rw-r--r--source/nsswitch/winbindd_util.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/source/nsswitch/winbindd_util.c b/source/nsswitch/winbindd_util.c
index c18e0deda3e..900fc900bfe 100644
--- a/source/nsswitch/winbindd_util.c
+++ b/source/nsswitch/winbindd_util.c
@@ -64,7 +64,7 @@ struct winbindd_domain *find_domain_from_name(char *domain_name)
return NULL;
}
-/* Given a domain name, return the struct winbindd domain info for it */
+/* Given a domain sid, return the struct winbindd domain info for it */
struct winbindd_domain *find_domain_from_sid(DOM_SID *sid)
{
@@ -74,9 +74,8 @@ struct winbindd_domain *find_domain_from_sid(DOM_SID *sid)
get_domain_info();
/* Search through list */
-
for (tmp = domain_list; tmp != NULL; tmp = tmp->next) {
- if (sid_equal(sid, &tmp->sid))
+ if (sid_compare_domain(sid, &tmp->sid) == 0)
return tmp;
}
@@ -429,10 +428,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
fstring name,
enum SID_NAME_USE *type)
{
- int num_sids = 1, num_names = 0;
- uint32 *types = NULL;
- char **names;
- CLI_POLICY_HND *hnd;
+ char *names;
NTSTATUS result;
TALLOC_CTX *mem_ctx;
BOOL rv = False;
@@ -459,29 +455,15 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
if (!(mem_ctx = talloc_init()))
return False;
- if (!(hnd = cm_get_lsa_handle(lp_workgroup())))
- goto done;
-
- result = cli_lsa_lookup_sids(hnd->cli, mem_ctx, &hnd->pol,
- num_sids, sid, &names, &types,
- &num_names);
+ result = domain->methods->sid_to_name(domain, mem_ctx, sid, &names, type);
/* Return name and type if successful */
if ((rv = NT_STATUS_IS_OK(result))) {
-
- /* Return name */
-
- if ((names != NULL) && (name != NULL))
- fstrcpy(name, names[0]);
-
- /* Return name type */
-
- if ((type != NULL) && (types != NULL))
- *type = types[0];
+ fstrcpy(name, names);
- store_sid_by_name_in_cache(domain, names[0], sid, types[0]);
- store_name_by_sid_in_cache(domain, sid, names[0], types[0]);
+ store_sid_by_name_in_cache(domain, names, sid, *type);
+ store_name_by_sid_in_cache(domain, sid, names, *type);
} else {
/* OK, so we tried to look up a name in this sid, and
* didn't find it. Therefore add a negative cache
@@ -490,9 +472,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
*type = SID_NAME_UNKNOWN;
fstrcpy(name, name_deadbeef);
}
-
- done:
talloc_destroy(mem_ctx);
return rv;