diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/winbindd/winbindd_passdb.c | 68 |
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, |