summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-10-24 11:44:11 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-10-25 15:33:56 +0200
commita5c75692c17498a61babb7045db2dc3f25b0d1af (patch)
treee9ee03d42af210320b561eb554637712890d77a9 /src/lib
parenta8e5bd27abc0d820baa256116fab02917e09df81 (diff)
downloadsssd-a5c75692c17498a61babb7045db2dc3f25b0d1af.tar.gz
sssd-a5c75692c17498a61babb7045db2dc3f25b0d1af.tar.xz
sssd-a5c75692c17498a61babb7045db2dc3f25b0d1af.zip
idmap: add sss_idmap_domain_by_name_has_algorithmic_mapping()
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/idmap/sss_idmap.c33
-rw-r--r--src/lib/idmap/sss_idmap.h44
2 files changed, 73 insertions, 4 deletions
diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c
index 17bd5779e..9278e10d2 100644
--- a/src/lib/idmap/sss_idmap.c
+++ b/src/lib/idmap/sss_idmap.c
@@ -953,3 +953,36 @@ sss_idmap_domain_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
return IDMAP_SID_UNKNOWN;
}
+
+enum idmap_error_code
+sss_idmap_domain_by_name_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
+ const char *dom_name,
+ bool *has_algorithmic_mapping)
+{
+ struct idmap_domain_info *idmap_domain_info;
+
+ if (dom_name == NULL) {
+ return IDMAP_ERROR;
+ }
+
+ CHECK_IDMAP_CTX(ctx, IDMAP_CONTEXT_INVALID);
+
+ if (ctx->idmap_domain_info == NULL) {
+ return IDMAP_NO_DOMAIN;
+ }
+
+ idmap_domain_info = ctx->idmap_domain_info;
+
+ while (idmap_domain_info != NULL) {
+ if (idmap_domain_info->name != NULL
+ && strcmp(dom_name, idmap_domain_info->name) == 0) {
+
+ *has_algorithmic_mapping = !idmap_domain_info->external_mapping;
+ return IDMAP_SUCCESS;
+ }
+
+ idmap_domain_info = idmap_domain_info->next;
+ }
+
+ return IDMAP_NAME_UNKNOWN;
+}
diff --git a/src/lib/idmap/sss_idmap.h b/src/lib/idmap/sss_idmap.h
index 91e5d0bf3..4101fb9a5 100644
--- a/src/lib/idmap/sss_idmap.h
+++ b/src/lib/idmap/sss_idmap.h
@@ -81,7 +81,10 @@ enum idmap_error_code {
IDMAP_COLLISION,
/** External source should be consulted for idmapping */
- IDMAP_EXTERNAL
+ IDMAP_EXTERNAL,
+
+ /** The provided name was not found */
+ IDMAP_NAME_UNKNOWN
};
/**
@@ -524,11 +527,21 @@ bool is_domain_sid(const char *str);
/**
* @brief Check if a domain is configured with algorithmic mapping
*
- * @param[in] ctx Idmap context
- * @param[in] dom_sid SID string, can be either a domain SID or an object SID
+ * @param[in] ctx Idmap context
+ * @param[in] dom_sid SID string, can be either a domain SID
+ * or an object SID
+ * @param[out] has_algorithmic_mapping Boolean value indicating if the given
+ * domain is configured for algorithmic
+ * mapping or not.
*
* @return
- * TODO ....
+ * - #IDMAP_SUCCESS: Domain for the given SID was found and
+ * has_algorithmic_mapping is set accordingly
+ * - #IDMAP_SID_INVALID: Provided SID is invalid
+ * - #IDMAP_CONTEXT_INVALID: Provided idmap context is invalid
+ * - #IDMAP_NO_DOMAIN: No domains are available in the idmap context
+ * - #IDMAP_SID_UNKNOWN: No domain with the given SID was found in the
+ * idmap context
*/
enum idmap_error_code
sss_idmap_domain_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
@@ -536,6 +549,29 @@ sss_idmap_domain_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
bool *has_algorithmic_mapping);
/**
+ * @brief Check if a domain is configured with algorithmic mapping
+ *
+ * @param[in] ctx Idmap context
+ * @param[in] dom_name Name of the domain
+ * @param[out] has_algorithmic_mapping Boolean value indicating if the given
+ * domain is configured for algorithmic
+ * mapping or not.
+ *
+ * @return
+ * - #IDMAP_SUCCESS: Domain for the given name was found and
+ * has_algorithmic_mapping is set accordingly
+ * - #IDMAP_ERROR: Provided name is invalid
+ * - #IDMAP_CONTEXT_INVALID: Provided idmap context is invalid
+ * - #IDMAP_NO_DOMAIN: No domains are available in the idmap context
+ * - #IDMAP_NAME_UNKNOWN: No domain with the given name was found in the
+ * idmap context
+ */
+enum idmap_error_code
+sss_idmap_domain_by_name_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
+ const char *dom_name,
+ bool *has_algorithmic_mapping);
+
+/**
* @brief Convert binary SID to SID structure
*
* @param[in] ctx Idmap context