summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-06-07 12:30:26 +0200
committerVolker Lendecke <vl@samba.org>2009-06-07 12:32:29 +0200
commit14a2974092bec50d37feaa33e0cdd6fd336f492c (patch)
treeff6f8ea2c947921ea3fa3c6afa0ac339427cdf79 /source3
parentf3b227c0d2abb0d4f02fa2313ff59750a35a4cd2 (diff)
downloadsamba-14a2974092bec50d37feaa33e0cdd6fd336f492c.tar.gz
samba-14a2974092bec50d37feaa33e0cdd6fd336f492c.tar.bz2
samba-14a2974092bec50d37feaa33e0cdd6fd336f492c.zip
Make "net sam list" work for groups, aliases and builtins
Diffstat (limited to 'source3')
-rw-r--r--source3/passdb/pdb_ads.c65
1 files changed, 58 insertions, 7 deletions
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c
index 5ea8158284..3c5cd442ff 100644
--- a/source3/passdb/pdb_ads.c
+++ b/source3/passdb/pdb_ads.c
@@ -849,9 +849,10 @@ static void pdb_ads_search_end(struct pdb_search *search)
TALLOC_FREE(state);
}
-static bool pdb_ads_search_users(struct pdb_methods *m,
- struct pdb_search *search,
- uint32 acct_flags)
+static bool pdb_ads_search_filter(struct pdb_methods *m,
+ struct pdb_search *search,
+ const char *filter,
+ struct pdb_ads_search_state **pstate)
{
struct pdb_ads_state *state = talloc_get_type_abort(
m->private_data, struct pdb_ads_state);
@@ -865,12 +866,11 @@ static bool pdb_ads_search_users(struct pdb_methods *m,
if (sstate == NULL) {
return false;
}
- sstate->acct_flags = acct_flags;
rc = tldap_search_fmt(
state->ld, state->domaindn, TLDAP_SCOPE_SUB,
attrs, ARRAY_SIZE(attrs), 0, talloc_tos(), &users,
- "(objectclass=user)");
+ "%s", filter);
if (rc != TLDAP_SUCCESS) {
DEBUG(10, ("ldap_search_ext_s failed: %s\n",
tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -926,20 +926,71 @@ static bool pdb_ads_search_users(struct pdb_methods *m,
search->private_data = sstate;
search->next_entry = pdb_ads_next_entry;
search->search_end = pdb_ads_search_end;
+ *pstate = sstate;
+ return true;
+}
+
+static bool pdb_ads_search_users(struct pdb_methods *m,
+ struct pdb_search *search,
+ uint32 acct_flags)
+{
+ struct pdb_ads_search_state *sstate;
+ bool ret;
+
+ ret = pdb_ads_search_filter(m, search, "(objectclass=user)", &sstate);
+ if (!ret) {
+ return false;
+ }
+ sstate->acct_flags = acct_flags;
return true;
}
static bool pdb_ads_search_groups(struct pdb_methods *m,
struct pdb_search *search)
{
- return false;
+ struct pdb_ads_search_state *sstate;
+ char *filter;
+ bool ret;
+
+ filter = talloc_asprintf(talloc_tos(),
+ "(&(grouptype=%d)(objectclass=group))",
+ GTYPE_SECURITY_GLOBAL_GROUP);
+ if (filter == NULL) {
+ return false;
+ }
+ ret = pdb_ads_search_filter(m, search, filter, &sstate);
+ TALLOC_FREE(filter);
+ if (!ret) {
+ return false;
+ }
+ sstate->acct_flags = 0;
+ return true;
}
static bool pdb_ads_search_aliases(struct pdb_methods *m,
struct pdb_search *search,
const DOM_SID *sid)
{
- return false;
+ struct pdb_ads_search_state *sstate;
+ char *filter;
+ bool ret;
+
+ filter = talloc_asprintf(
+ talloc_tos(), "(&(grouptype=%d)(objectclass=group))",
+ sid_check_is_builtin(sid)
+ ? GTYPE_SECURITY_BUILTIN_LOCAL_GROUP
+ : GTYPE_SECURITY_DOMAIN_LOCAL_GROUP);
+
+ if (filter == NULL) {
+ return false;
+ }
+ ret = pdb_ads_search_filter(m, search, filter, &sstate);
+ TALLOC_FREE(filter);
+ if (!ret) {
+ return false;
+ }
+ sstate->acct_flags = 0;
+ return true;
}
static bool pdb_ads_uid_to_rid(struct pdb_methods *m, uid_t uid,