summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-06-27 12:48:49 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-28 20:20:59 +0200
commitb2c7b6fe7a6b9ef3af8d4d3037fe83d6e9bfd6a5 (patch)
treeef504ae88eeeee005a7ed9d5122912fca0e80df5 /src/providers
parentbfb40893be20b45279a40188cf16ef0eec1f9423 (diff)
downloadsssd-b2c7b6fe7a6b9ef3af8d4d3037fe83d6e9bfd6a5.tar.gz
sssd-b2c7b6fe7a6b9ef3af8d4d3037fe83d6e9bfd6a5.tar.xz
sssd-b2c7b6fe7a6b9ef3af8d4d3037fe83d6e9bfd6a5.zip
Add sdap_idmap_domain_has_algorithmic_mapping()
This patch implements a wrapper for sss_idmap_domain_has_algorithmic_mapping() for the sdap ID mapping. Fixes https://fedorahosted.org/sssd/ticket/1960
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ldap/sdap_idmap.c59
-rw-r--r--src/providers/ldap/sdap_idmap.h3
2 files changed, 62 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap_idmap.c b/src/providers/ldap/sdap_idmap.c
index a3b725f99..0939c31e4 100644
--- a/src/providers/ldap/sdap_idmap.c
+++ b/src/providers/ldap/sdap_idmap.c
@@ -477,3 +477,62 @@ done:
talloc_free(dom_sid_str);
return ret;
}
+
+bool sdap_idmap_domain_has_algorithmic_mapping(struct sdap_idmap_ctx *ctx,
+ const char *dom_sid)
+{
+ enum idmap_error_code err;
+ bool has_algorithmic_mapping;
+ char *new_dom_sid;
+ int ret;
+ TALLOC_CTX *tmp_ctx = NULL;
+
+ err = sss_idmap_domain_has_algorithmic_mapping(ctx->map, dom_sid,
+ &has_algorithmic_mapping);
+ if (err == IDMAP_SUCCESS) {
+ return has_algorithmic_mapping;
+ } else if (err != IDMAP_SID_UNKNOWN && err != IDMAP_NO_DOMAIN) {
+ return false;
+ }
+
+ /* This is the first time we've seen this domain
+ * Create a new domain for it. We'll use the dom-sid
+ * as the domain name for now, since we don't have
+ * any way to get the real name.
+ */
+
+ if (is_domain_sid(dom_sid)) {
+ new_dom_sid = discard_const(dom_sid);
+ } else {
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("talloc_new failed.\n"));
+ return false;
+ }
+
+ ret = sdap_idmap_get_dom_sid_from_object(tmp_ctx, dom_sid,
+ &new_dom_sid);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ ("Could not parse domain SID from [%s]\n", dom_sid));
+ talloc_free(tmp_ctx);
+ return false;
+ }
+ }
+
+ ret = ctx->find_new_domain(ctx, new_dom_sid, new_dom_sid);
+ talloc_free(tmp_ctx);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ ("Could not add new domain for sid [%s]\n", dom_sid));
+ return false;
+ }
+
+ err = sss_idmap_domain_has_algorithmic_mapping(ctx->map, dom_sid,
+ &has_algorithmic_mapping);
+ if (err == IDMAP_SUCCESS) {
+ return has_algorithmic_mapping;
+ }
+
+ return false;
+}
diff --git a/src/providers/ldap/sdap_idmap.h b/src/providers/ldap/sdap_idmap.h
index 45462c15c..c8bc4e29f 100644
--- a/src/providers/ldap/sdap_idmap.h
+++ b/src/providers/ldap/sdap_idmap.h
@@ -56,4 +56,7 @@ sdap_idmap_sid_to_unix(struct sdap_idmap_ctx *idmap_ctx,
const char *sid_str,
id_t *id);
+bool sdap_idmap_domain_has_algorithmic_mapping(struct sdap_idmap_ctx *ctx,
+ const char *dom_sid);
+
#endif /* SDAP_IDMAP_H_ */