From 4b868a12602c9588f7beef6664c97b40cf83acf8 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Tue, 10 Sep 2013 14:58:20 +0200 Subject: 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 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/providers/ldap/ldap_common.c') diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index 1db524696..facf102ed 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, -- cgit