diff options
author | Dave Craft <wimberosa@gmail.com> | 2011-07-05 21:19:54 -0500 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-07-14 07:05:09 +1000 |
commit | 0d1c54ecafc0f324b84ddd5cdf64db9f6108f517 (patch) | |
tree | b2bf3f472e9b70b6da32e0e1759c0b43b37ff227 /source4 | |
parent | b52246bf2f75e2a4869bce3e474e6c1c81a492b7 (diff) | |
download | samba-0d1c54ecafc0f324b84ddd5cdf64db9f6108f517.tar.gz samba-0d1c54ecafc0f324b84ddd5cdf64db9f6108f517.tar.bz2 samba-0d1c54ecafc0f324b84ddd5cdf64db9f6108f517.zip |
Standalone samdb_ntds_site_settings_options() helper
A helper function for retrieving the ntds site settings
via standalone function call. Used within KCC
Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/common/util.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 3fa8f67447..7283405bb3 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -2909,6 +2909,54 @@ failed: /* + * return NTDSSiteSettings options. See MS-ADTS 7.1.1.2.2.1.1 + * flags are DS_NTDSSETTINGS_OPT_* + */ +int samdb_ntds_site_settings_options(struct ldb_context *ldb_ctx, + uint32_t *options) +{ + int rc; + TALLOC_CTX *tmp_ctx; + struct ldb_result *res; + struct ldb_dn *site_dn; + const char *attrs[] = { "options", NULL }; + + tmp_ctx = talloc_new(ldb_ctx); + if (tmp_ctx == NULL) + goto failed; + + /* Retrieve the site dn for the ldb that we + * have open. This is our local site. + */ + site_dn = samdb_server_site_dn(ldb_ctx, tmp_ctx); + if (site_dn == NULL) + goto failed; + + /* Perform a one level (child) search from the local + * site distinguided name. We're looking for the + * "options" attribute within the nTDSSiteSettings + * object + */ + rc = ldb_search(ldb_ctx, tmp_ctx, &res, site_dn, + LDB_SCOPE_ONELEVEL, attrs, + "objectClass=nTDSSiteSettings"); + + if (rc != LDB_SUCCESS || res->count != 1) + goto failed; + + *options = ldb_msg_find_attr_as_uint(res->msgs[0], "options", 0); + + talloc_free(tmp_ctx); + + return LDB_SUCCESS; + +failed: + DEBUG(1,("Failed to find our NTDS Site Settings options in ldb!\n")); + talloc_free(tmp_ctx); + return LDB_ERR_NO_SUCH_OBJECT; +} + +/* return NTDS options flags. See MS-ADTS 7.1.1.2.2.1.2.1.1 flags are DS_NTDS_OPTION_* |