summaryrefslogtreecommitdiff
path: root/src/providers/ad
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-06-19 13:00:41 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-28 22:22:20 +0200
commit4e3ba17a3376b635cb0d9ae60a6d4e712ded01a0 (patch)
tree46bd78bf573bf010d164ee96d9874bc2ba1933f8 /src/providers/ad
parentf8a4a5f6240156809e1b5ef03816f673281e3fa0 (diff)
downloadsssd-4e3ba17a3376b635cb0d9ae60a6d4e712ded01a0.tar.gz
sssd-4e3ba17a3376b635cb0d9ae60a6d4e712ded01a0.tar.bz2
sssd-4e3ba17a3376b635cb0d9ae60a6d4e712ded01a0.zip
AD: Move storing sdap_domain for subdomain to generic LDAP code
Makes creating the sdap_domain structure for a subdomain reusable outside AD subdomain code where it was created initially. Subtask of: https://fedorahosted.org/sssd/ticket/1962
Diffstat (limited to 'src/providers/ad')
-rw-r--r--src/providers/ad/ad_subdomains.c66
1 files changed, 1 insertions, 65 deletions
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
index 724d0736..be4781cc 100644
--- a/src/providers/ad/ad_subdomains.c
+++ b/src/providers/ad/ad_subdomains.c
@@ -89,71 +89,7 @@ static errno_t
ads_store_sdap_subdom(struct ad_subdomains_ctx *ctx,
struct sss_domain_info *parent)
{
- struct sss_domain_info *dom;
- struct sdap_domain *sdom, *sditer;
- char *basedn;
- errno_t ret;
-
- for (dom = get_next_domain(parent, true);
- dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
- dom = get_next_domain(dom, false)) {
-
- DLIST_FOR_EACH(sditer, ctx->sdom) {
- if (sditer->dom == dom) {
- break;
- }
- }
-
- if (sditer == NULL) {
- /* New sdap domain */
- DEBUG(SSSDBG_TRACE_FUNC, ("subdomain %s is a new one, will "
- "create a new sdap domain object\n", dom->name));
-
- ret = sdap_domain_add(ctx->sdap_id_ctx->opts, dom, &sdom);
- if (ret != EOK) {
- DEBUG(SSSDBG_OP_FAILURE,
- ("Cannot add new sdap domain for domain %s [%d]: %s\n",
- parent->name, ret, strerror(ret)));
- return ret;
- }
- sditer = sdom;
- }
-
- /* Convert the domain name into search base */
- ret = domain_to_basedn(sditer, sditer->dom->name, &basedn);
- if (ret != EOK) {
- DEBUG(SSSDBG_OP_FAILURE,
- ("Cannot convert domain name [%s] to base DN [%d]: %s\n",
- dom->name, ret, strerror(ret)));
- talloc_free(basedn);
- return ret;
- }
-
- /* Update search bases */
- talloc_zfree(sdom->search_bases);
- sdom->search_bases = talloc_array(sdom, struct sdap_search_base *, 2);
- if (sdom->search_bases == NULL) {
- return ret;
- }
- sdom->search_bases[1] = NULL;
-
- ret = sdap_create_search_base(sdom, basedn, LDAP_SCOPE_SUBTREE, NULL,
- &sdom->search_bases[0]);
- talloc_free(basedn);
- if (ret) {
- DEBUG(SSSDBG_OP_FAILURE, ("Cannot create new sdap search base\n"));
- return ret;
- }
-
- sdom->user_search_bases = sdom->search_bases;
- sdom->group_search_bases = sdom->search_bases;
- sdom->netgroup_search_bases = sdom->search_bases;
- sdom->sudo_search_bases = sdom->search_bases;
- sdom->service_search_bases = sdom->search_bases;
- sdom->autofs_search_bases = sdom->search_bases;
- }
-
- return EOK;
+ return sdap_domain_subdom_add(ctx->sdap_id_ctx, ctx->sdom, parent);
}
static errno_t