diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-07-23 16:25:04 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-08-03 13:54:38 -0400 |
commit | 0228e28a3f07b5dc909cdc154dc89c4952f09280 (patch) | |
tree | 4f9d4ec59fed267ad532bfa542c1c7a9602ea1e0 | |
parent | dbd09f5703d721a58210e490609cfacb7eb56fcf (diff) | |
download | sssd-0228e28a3f07b5dc909cdc154dc89c4952f09280.tar.gz sssd-0228e28a3f07b5dc909cdc154dc89c4952f09280.tar.bz2 sssd-0228e28a3f07b5dc909cdc154dc89c4952f09280.zip |
Add sysdb_group_dn_name utility function
-rw-r--r-- | src/db/sysdb.c | 22 | ||||
-rw-r--r-- | src/db/sysdb.h | 2 |
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, |