summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/providers/ldap/ldap_common.c24
-rw-r--r--src/providers/ldap/ldap_common.h4
2 files changed, 28 insertions, 0 deletions
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,
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
index 8b2b1ea91..b3bd950e1 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,