summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-06-25 12:44:18 -0700
committerJeremy Allison <jra@samba.org>2008-06-25 12:44:18 -0700
commit7687a225104bbec47a672da60125af6ff580c817 (patch)
tree45dd7805f56f9d599a345510951e0821c3df4f32
parent335e3b11971ebbec415620d42512479b16c952fc (diff)
downloadsamba-7687a225104bbec47a672da60125af6ff580c817.tar.gz
samba-7687a225104bbec47a672da60125af6ff580c817.tar.bz2
samba-7687a225104bbec47a672da60125af6ff580c817.zip
Final (hopefully :-) part of fix for bug #5551. Allow passdb backend to enumerate domain groups.
Jeremy (This used to be commit 2181770e4589d475b95b4103a8f95a58787f1f86)
-rw-r--r--source3/winbindd/winbindd_passdb.c68
1 files changed, 45 insertions, 23 deletions
diff --git a/source3/winbindd/winbindd_passdb.c b/source3/winbindd/winbindd_passdb.c
index 8b2016c031..ffcf0719be 100644
--- a/source3/winbindd/winbindd_passdb.c
+++ b/source3/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,