summaryrefslogtreecommitdiff
path: root/src/providers/krb5/krb5_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/providers/krb5/krb5_common.c')
-rw-r--r--src/providers/krb5/krb5_common.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index 81ad4e9d..4d577257 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -653,3 +653,28 @@ errno_t krb5_install_sigterm_handler(struct tevent_context *ev,
return EOK;
}
+
+errno_t krb5_get_simple_upn(TALLOC_CTX *mem_ctx, struct krb5_ctx *krb5_ctx,
+ const char *username, const char **_upn)
+{
+ const char *realm;
+ char *upn;
+
+ realm = dp_opt_get_cstring(krb5_ctx->opts, KRB5_REALM);
+ if (realm == NULL) {
+ DEBUG(1, ("Missing Kerberos realm.\n"));
+ return ENOENT;
+ }
+
+ /* NOTE: this is a hack, works only in some environments */
+ upn = talloc_asprintf(mem_ctx, "%s@%s", username, realm);
+ if (upn == NULL) {
+ DEBUG(1, ("talloc_asprintf failed.\n"));
+ return ENOMEM;
+ }
+
+ DEBUG(9, ("Using simple UPN [%s].\n", upn));
+
+ *_upn = upn;
+ return EOK;
+}