>From 54595459a833d41953c0b92644cb173d7521494b 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 3/8] sdap: add sdap_domain_get_by_dn() This function will find sdap domain by comparing object dn with domain base dn. Resolves: https://fedorahosted.org/sssd/ticket/2064 --- src/providers/ldap/ldap_common.c | 24 ++++++++++++++++++++++++ src/providers/ldap/ldap_common.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index 16a1e4fe9fc870ab92103a674fe58c0844498dd5..0356cb37a89d983b72b3cbadc0e8ba9014d34e09 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -63,6 +63,30 @@ 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; + char *dc = NULL; + + dc = strstr(dn, "dc="); + if (dc == NULL) { + dc = strstr(dn, "DC="); + if (dc == NULL) { + return NULL; + } + } + + DLIST_FOR_EACH(sditer, opts->sdom) { + if (strcasecmp(sditer->basedn, dc) == 0) { + return sditer; + } + } + + return NULL; +} + 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 8b2b1ea918725bf7adbe5d0b9872d8e91b0db3b0..b3bd950e1dca6df0f5668397d5e5a0796e519862 100644 --- a/src/providers/ldap/ldap_common.h +++ b/src/providers/ldap/ldap_common.h @@ -282,6 +282,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