diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-09-01 23:26:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:36:23 -0500 |
commit | 9b905c9f27f6d7d682085036b27b55d26c1f38ee (patch) | |
tree | 9be17c239260c02b9ae1ab8a7b08e4921fb2a825 /source4/dsdb | |
parent | 95fcf031b0480ada75ed5ed02826f4acf196be77 (diff) | |
download | samba-9b905c9f27f6d7d682085036b27b55d26c1f38ee.tar.gz samba-9b905c9f27f6d7d682085036b27b55d26c1f38ee.tar.bz2 samba-9b905c9f27f6d7d682085036b27b55d26c1f38ee.zip |
r9930: Use a single samdb_base_dn() function rather than lots of silly
searches all over the place.
This can be extended to cover an NT4 (no ADS) mode in future as well.
Andrew Bartlett
(This used to be commit 0761b22f99a128bd9634a191adc88b0e30982a3a)
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/samdb/samdb.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c index aed47d1ed2..717b72ded2 100644 --- a/source4/dsdb/samdb/samdb.c +++ b/source4/dsdb/samdb/samdb.c @@ -969,3 +969,37 @@ struct security_descriptor *samdb_default_security_descriptor(TALLOC_CTX *mem_ct return sd; } + +struct ldb_dn *samdb_base_dn(TALLOC_CTX *mem_ctx) +{ + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + int server_role = lp_server_role(); + const char **split_realm; + struct ldb_dn *dn; + + if (!tmp_ctx) { + return NULL; + } + + if ((server_role == ROLE_DOMAIN_PDC) + || (server_role == ROLE_DOMAIN_BDC)) { + int i; + split_realm = str_list_make(tmp_ctx, lp_realm(), "."); + if (!split_realm) { + talloc_free(tmp_ctx); + return NULL; + } + dn = NULL; + i = str_list_length(split_realm); + i--; + for (; i >= 0; i--) { + dn = ldb_dn_build_child(tmp_ctx, "dc", split_realm[i], dn); + if (!dn) { + talloc_free(tmp_ctx); + return NULL; + } + } + return dn; + } + return ldb_dn_string_compose(mem_ctx, NULL, "cn=%s", lp_netbios_name()); +} |