summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-06-25 12:44:27 -0700
committerKarolin Seeger <kseeger@samba.org>2008-06-26 08:56:38 +0200
commit8c4e75cbfc069608d7d6f899243096d198589aba (patch)
tree80aedb8c939631d18d6810bcf5d08f131ff39664
parent90ad03b06e9df879b2139b9208912bc476ecd99d (diff)
downloadsamba-8c4e75cbfc069608d7d6f899243096d198589aba.tar.gz
Final (hopefully :-) part of fix for bug #5551. Allow passdb backend to enumerate domain groups.
Jeremy (cherry picked from commit 269521ee08b962040afe63ea74130ba27f29e092)
-rw-r--r--source/winbindd/winbindd_passdb.c68
1 files changed, 45 insertions, 23 deletions
diff --git a/source/winbindd/winbindd_passdb.c b/source/winbindd/winbindd_passdb.c
index 8b2016c0310..ffcf0719be7 100644
--- a/source/winbindd/winbindd_passdb.c
+++ b/source/winbindd/winbindd_passdb.c
@@ -28,35 +28,31 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
-/* list all domain groups */
-static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
+static NTSTATUS enum_groups_internal(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
uint32 *num_entries,
- struct acct_info **info)
-{
- /* We don't have domain groups */
- *num_entries = 0;
- *info = NULL;
- return NT_STATUS_OK;
-}
-
-/* List all domain groups */
-
-static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- uint32 *num_entries,
- struct acct_info **info)
+ struct acct_info **info,
+ enum lsa_SidType sidtype)
{
struct pdb_search *search;
- struct samr_displayentry *aliases;
+ struct samr_displayentry *entries;
int i;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- search = pdb_search_aliases(&domain->sid);
+ if (sidtype == SID_NAME_ALIAS) {
+ search = pdb_search_aliases(&domain->sid);
+ } else {
+ search = pdb_search_groups();
+ }
+
if (search == NULL) goto done;
- *num_entries = pdb_search_entries(search, 0, 0xffffffff, &aliases);
- if (*num_entries == 0) goto done;
+ *num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries);
+ if (*num_entries == 0) {
+ /* Zero entries isn't an error */
+ result = NT_STATUS_OK;
+ goto done;
+ }
*info = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_entries);
if (*info == NULL) {
@@ -65,9 +61,9 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
}
for (i=0; i<*num_entries; i++) {
- fstrcpy((*info)[i].acct_name, aliases[i].account_name);
- fstrcpy((*info)[i].acct_desc, aliases[i].description);
- (*info)[i].rid = aliases[i].rid;
+ fstrcpy((*info)[i].acct_name, entries[i].account_name);
+ fstrcpy((*info)[i].acct_desc, entries[i].description);
+ (*info)[i].rid = entries[i].rid;
}
result = NT_STATUS_OK;
@@ -76,6 +72,32 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
return result;
}
+/* list all domain groups */
+static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32 *num_entries,
+ struct acct_info **info)
+{
+ return enum_groups_internal(domain,
+ mem_ctx,
+ num_entries,
+ info,
+ SID_NAME_DOM_GRP);
+}
+
+/* List all local groups (aliases) */
+static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
+ TALLOC_CTX *mem_ctx,
+ uint32 *num_entries,
+ struct acct_info **info)
+{
+ return enum_groups_internal(domain,
+ mem_ctx,
+ num_entries,
+ info,
+ SID_NAME_ALIAS);
+}
+
/* convert a single name to a sid in a domain */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,