summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.c22
-rw-r--r--src/db/sysdb.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 5396b7fc8..ffe9ff774 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -372,6 +372,28 @@ int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
return EOK;
}
+errno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
+ bool *value)
+{
+ struct ldb_message_element *el;
+ int ret;
+
+ ret = sysdb_attrs_get_el_int(attrs, name, false, &el);
+ if (ret) {
+ return ret;
+ }
+
+ if (el->num_values != 1) {
+ return ERANGE;
+ }
+
+ if (strcmp((const char *)el->values[0].data, "TRUE") == 0)
+ *value = true;
+ else
+ *value = false;
+ return EOK;
+}
+
int sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
TALLOC_CTX *mem_ctx, const char ***string)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 190e8120e..68fc69864 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -207,6 +207,8 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
const char **string);
int sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
TALLOC_CTX *mem_ctx, const char ***string);
+errno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
+ bool *value);
int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
uint32_t *value);