]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: add dom_sid_lookup_is_predefined_domain()
authorRalph Boehme <slow@samba.org>
Wed, 28 Nov 2018 16:19:39 +0000 (17:19 +0100)
committerKarolin Seeger <kseeger@samba.org>
Fri, 7 Dec 2018 09:28:30 +0000 (10:28 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12164

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Mulder <dmulder@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 2de5f06d399109009c343b0acfef822db38502a1)

libcli/security/dom_sid.h
libcli/security/util_sid.c

index 6c3225e267d0abbb47d98e8d07b70b88ddae2268..e22ebc9abcad1d13d95d4672c5747067c630153e 100644 (file)
@@ -74,6 +74,7 @@ NTSTATUS dom_sid_lookup_predefined_sid(const struct dom_sid *sid,
                                       enum lsa_SidType *type,
                                       const struct dom_sid **authority_sid,
                                       const char **authority_name);
+bool dom_sid_lookup_is_predefined_domain(const char *domain);
 
 int dom_sid_compare_auth(const struct dom_sid *sid1,
                         const struct dom_sid *sid2);
index 4e4a8fa0d3e6c87fbc43f41b29e12b7a90f14cae..c616d2459e0335d546d20e069271c17a0755472e 100644 (file)
@@ -879,6 +879,39 @@ NTSTATUS dom_sid_lookup_predefined_name(const char *name,
        return NT_STATUS_NONE_MAPPED;
 }
 
+bool dom_sid_lookup_is_predefined_domain(const char *domain)
+{
+       size_t di;
+       bool match;
+
+       if (domain == NULL) {
+               domain = "";
+       }
+
+       match = strequal(domain, "");
+       if (match) {
+               /*
+                * Strange, but that's what W2012R2 does.
+                */
+               domain = "BUILTIN";
+       }
+
+       for (di = 0; di < ARRAY_SIZE(predefined_domains); di++) {
+               const struct predefined_domain_mapping *d =
+                       &predefined_domains[di];
+               int cmp;
+
+               cmp = strcasecmp(d->domain, domain);
+               if (cmp != 0) {
+                       continue;
+               }
+
+               return true;
+       }
+
+       return false;
+}
+
 NTSTATUS dom_sid_lookup_predefined_sid(const struct dom_sid *sid,
                                       const char **name,
                                       enum lsa_SidType *type,