summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2006-04-28 14:44:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:33 -0500
commit34e810076df8720a145f5a619ed648c384898563 (patch)
treeb8a248e9eb110109d009cf33088b0b5cdf5e60f6 /source3/nsswitch
parent2720db90c110908c3d077028b82c4a6a5f8c2c51 (diff)
downloadsamba-34e810076df8720a145f5a619ed648c384898563.tar.gz
samba-34e810076df8720a145f5a619ed648c384898563.tar.bz2
samba-34e810076df8720a145f5a619ed648c384898563.zip
r15305: Let winbind search by sid directly (or in windows terms: "bind to a
sid"); works in all AD versions I tested. Also add "net ads sid" search tool. Guenther (This used to be commit 5557ada6943b817d28a5471c613c7291febe2ad5)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd_ads.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source3/nsswitch/winbindd_ads.c b/source3/nsswitch/winbindd_ads.c
index 5e0d4cfe8e..336f27e6a1 100644
--- a/source3/nsswitch/winbindd_ads.c
+++ b/source3/nsswitch/winbindd_ads.c
@@ -634,13 +634,8 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
goto done;
}
- rc = ads_sid_to_dn(ads, mem_ctx, sid, &user_dn);
- if (!ADS_ERR_OK(rc)) {
- status = ads_ntstatus(rc);
- goto done;
- }
+ rc = ads_search_retry_sid(ads, (void**)(void *)&msg, sid, attrs);
- rc = ads_search_retry_dn(ads, (void**)(void *)&msg, user_dn, attrs);
if (!ADS_ERR_OK(rc)) {
status = ads_ntstatus(rc);
DEBUG(1,("lookup_usergroups(sid=%s) ads_search tokenGroups: %s\n",
@@ -648,6 +643,15 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
goto done;
}
+ count = ads_count_replies(ads, msg);
+ if (count != 1) {
+ status = NT_STATUS_UNSUCCESSFUL;
+ DEBUG(1,("lookup_usergroups(sid=%s) ads_search tokenGroups: "
+ "invalid number of results (count=%d)\n",
+ sid_to_string(sid_string, sid), count));
+ goto done;
+ }
+
if (!msg) {
DEBUG(1,("lookup_usergroups(sid=%s) ads_search tokenGroups: NULL msg\n",
sid_to_string(sid_string, sid)));
@@ -655,6 +659,12 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
goto done;
}
+ user_dn = ads_get_dn(ads, msg);
+ if (user_dn == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
if (!ads_pull_uint32(ads, msg, "primaryGroupID", &primary_group_rid)) {
DEBUG(1,("%s: No primary group for sid=%s !?\n",
domain->name, sid_to_string(sid_string, sid)));