summaryrefslogtreecommitdiff
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 00cff372..5a7626f4 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -52,6 +52,28 @@ struct ldb_dn *sysdb_group_dn(struct sysdb_ctx *ctx, void *memctx,
return ldb_dn_new_fmt(memctx, ctx->ldb, SYSDB_TMPL_GROUP, name, domain);
}
+errno_t sysdb_group_dn_name(struct sysdb_ctx *ctx, void *memctx,
+ const char *_dn, char **_name)
+{
+ struct ldb_dn *dn;
+ *_name = NULL;
+
+ dn = ldb_dn_new_fmt(memctx, ctx->ldb, "%s", _dn);
+ if (dn == NULL) {
+ return ENOMEM;
+ }
+
+ *_name = talloc_strdup(memctx, ldb_dn_get_rdn_name(dn));
+ if (!*_name) {
+ talloc_zfree(dn);
+ return ENOMEM;
+ }
+
+ talloc_zfree(dn);
+
+ return EOK;
+}
+
struct ldb_dn *sysdb_domain_dn(struct sysdb_ctx *ctx, void *memctx,
const char *domain)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index feda51b4..5c0b744f 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -199,6 +199,8 @@ struct ldb_dn *sysdb_user_dn(struct sysdb_ctx *ctx, void *memctx,
const char *domain, const char *name);
struct ldb_dn *sysdb_group_dn(struct sysdb_ctx *ctx, void *memctx,
const char *domain, const char *name);
+errno_t sysdb_group_dn_name(struct sysdb_ctx *ctx, void *memctx,
+ const char *dn_str, char **name);
struct ldb_dn *sysdb_domain_dn(struct sysdb_ctx *ctx, void *memctx,
const char *domain);
struct ldb_dn *sysdb_custom_dn(struct sysdb_ctx *ctx, void *memctx,