>From 933da86d1fea3005c36a0b4b272b5f7e90d730f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Tue, 10 Sep 2013 14:58:20 +0200 Subject: [PATCH 2/8] sdap: add sdap_domain_get_by_dn() This function will find sdap domain by comparing object dn with domain search bases. Resolves: https://fedorahosted.org/sssd/ticket/2064 --- src/providers/ldap/ldap_common.c | 29 +++++++++++++++++++++++++++++ src/providers/ldap/ldap_common.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index b3a048c1cb7336cec0a5bbfebd3509c56637bed3..3a7751f0321df6c10bcb3ff6effa0a519eaa29ce 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -63,6 +63,35 @@ sdap_domain_get(struct sdap_options *opts, return sditer; } +struct sdap_domain * +sdap_domain_get_by_dn(struct sdap_options *opts, + const char *dn) +{ + struct sdap_domain *sditer = NULL; + TALLOC_CTX *tmp_ctx = NULL; + + tmp_ctx = talloc_new(NULL); + if (tmp_ctx == NULL) { + return NULL; + } + + DLIST_FOR_EACH(sditer, opts->sdom) { + if (sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->search_bases, NULL) || + sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->user_search_bases, NULL) || + sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->group_search_bases, NULL) || + sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->netgroup_search_bases, NULL) || + sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->sudo_search_bases, NULL) || + sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->service_search_bases, NULL) || + sss_ldap_dn_in_search_bases(tmp_ctx, dn, sditer->autofs_search_bases, NULL)) { + break; + } + } + + talloc_free(tmp_ctx); + return sditer; +} + + errno_t sdap_domain_add(struct sdap_options *opts, struct sss_domain_info *dom, diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h index fb9a34c6067521f8d28fb403b97ca6394918f303..b6a25cbdec67a6ee2d8700c0f2008a99b591510a 100644 --- a/src/providers/ldap/ldap_common.h +++ b/src/providers/ldap/ldap_common.h @@ -279,6 +279,10 @@ sdap_domain_remove(struct sdap_options *opts, struct sdap_domain *sdap_domain_get(struct sdap_options *opts, struct sss_domain_info *dom); + +struct sdap_domain *sdap_domain_get_by_dn(struct sdap_options *opts, + const char *dn); + errno_t sdap_create_search_base(TALLOC_CTX *mem_ctx, const char *unparsed_base, -- 1.8.3.1