82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina Simo Sorce <ssorce@redhat.com>
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina Copyright (C) 2008-2010 Red Hat
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina This program is free software; you can redistribute it and/or modify
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina it under the terms of the GNU General Public License as published by
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina the Free Software Foundation; either version 3 of the License, or
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina (at your option) any later version.
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina This program is distributed in the hope that it will be useful,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina GNU General Public License for more details.
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina You should have received a copy of the GNU General Public License
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březinasdap_domain_get_by_dn(struct sdap_options *opts,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina const char *dn)
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina if (sss_ldap_dn_in_search_bases_len(tmp_ctx, dn, sditer->search_bases,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina || sss_ldap_dn_in_search_bases_len(tmp_ctx, dn,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina || sss_ldap_dn_in_search_bases_len(tmp_ctx, dn,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina || sss_ldap_dn_in_search_bases_len(tmp_ctx, dn,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sditer->netgroup_search_bases, NULL, &match_len)
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina || sss_ldap_dn_in_search_bases_len(tmp_ctx, dn,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina || sss_ldap_dn_in_search_bases_len(tmp_ctx, dn,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sditer->service_search_bases, NULL, &match_len)
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina || sss_ldap_dn_in_search_bases_len(tmp_ctx, dn,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sditer->autofs_search_bases, NULL, &match_len)) {
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina /*this is a longer match*/
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina /* Convert the domain name into search base */
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina ret = domain_to_basedn(sdom, sdom->dom->name, &sdom->basedn);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina "Cannot convert domain name [%s] to base DN [%d]: %s\n",
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina talloc_set_destructor((TALLOC_CTX *)sdom, sdap_domain_destructor);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina DLIST_ADD_END(opts->sdom, sdom, struct sdap_domain *);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březinasdap_domain_subdom_add(struct sdap_id_ctx *sdap_id_ctx,
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek for (dom = get_next_domain(parent, SSS_GND_DESCEND);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina /* New sdap domain */
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "subdomain %s is a new one, will "
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina "create a new sdap domain object\n", dom->name);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina ret = sdap_domain_add(sdap_id_ctx->opts, dom, &sdom);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina "Cannot add new sdap domain for domain %s [%d]: %s\n",
c4ddb9ccab670f9c0d0377680237b62f9f91c496Michal Židek "subdomain %s has already initialized search bases\n",
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina /* Update search bases */
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sdom->search_bases = talloc_array(sdom, struct sdap_search_base *, 2);
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina ret = sdap_create_search_base(sdom, sdom->basedn, LDAP_SCOPE_SUBTREE,
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Cannot create new sdap search base\n");
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sdom->group_search_bases = sdom->search_bases;
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sdom->netgroup_search_bases = sdom->search_bases;
82a4f022ec1cbb9530ffa21d95474152b24acf50Pavel Březina sdom->service_search_bases = sdom->search_bases;