s3: Make "net sam list [users|workstations]" list only the right things
authorVolker Lendecke <vl@samba.org>
Sun, 13 Feb 2011 10:26:49 +0000 (11:26 +0100)
committerVolker Lendecke <vlendec@samba.org>
Sun, 13 Feb 2011 11:59:14 +0000 (12:59 +0100)
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Sun Feb 13 12:59:14 CET 2011 on sn-devel-104

source3/passdb/pdb_ads.c

index 89151588db01cf1c9cfed50ca51f17b0c3745213..b60615fafef46219c9a918fb61026626b9a635bc 100644 (file)
@@ -1902,9 +1902,28 @@ static bool pdb_ads_search_users(struct pdb_methods *m,
                                 uint32 acct_flags)
 {
        struct pdb_ads_search_state *sstate;
+       char *filter;
        bool ret;
 
-       ret = pdb_ads_search_filter(m, search, "(objectclass=user)", &sstate);
+       if (acct_flags & ACB_NORMAL) {
+               filter = talloc_asprintf(
+                       talloc_tos(),
+                       "(&(objectclass=user)(sAMAccountType=%d))",
+                       ATYPE_NORMAL_ACCOUNT);
+       } else if (acct_flags & ACB_WSTRUST) {
+               filter = talloc_asprintf(
+                       talloc_tos(),
+                       "(&(objectclass=user)(sAMAccountType=%d))",
+                       ATYPE_WORKSTATION_TRUST);
+       } else {
+               filter = talloc_strdup(talloc_tos(), "(objectclass=user)");
+       }
+       if (filter == NULL) {
+               return false;
+       }
+
+       ret = pdb_ads_search_filter(m, search, filter, &sstate);
+       TALLOC_FREE(filter);
        if (!ret) {
                return false;
        }