From b4e40958b7f7406dc6cdd1bef4fa3f824b9cbe3a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 12 Nov 2009 00:51:46 +0100 Subject: s3-kerberos: add smb_krb5_principal_get_realm(). Guenther --- source3/include/includes.h | 2 ++ source3/libsmb/clikrb5.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/source3/include/includes.h b/source3/include/includes.h index 8bd27b99e3..cbf30d6158 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -1086,6 +1086,8 @@ krb5_error_code smb_krb5_get_creds(const char *server_s, const char *cc, const char *impersonate_princ_s, krb5_creds **creds_p); +char *smb_krb5_principal_get_realm(krb5_context context, + krb5_principal principal); #endif /* HAVE_KRB5 */ diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index d5a910bfbd..e86c6c4531 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -2234,6 +2234,31 @@ krb5_error_code smb_krb5_get_creds(const char *server_s, return ret; } +/* + * smb_krb5_principal_get_realm + * + * @brief Get realm of a principal + * + * @param[in] context The krb5_context + * @param[in] principal The principal + * @return pointer to the realm + * + */ + +char *smb_krb5_principal_get_realm(krb5_context context, + krb5_principal principal) +{ +#ifdef HAVE_KRB5_PRINCIPAL_GET_REALM /* Heimdal */ + return krb5_principal_get_realm(context, principal); +#elif defined(krb5_princ_realm) /* MIT */ + krb5_data *realm; + realm = krb5_princ_realm(context, principal); + return (char *)realm->data; +#else + return NULL; +#endif +} + #else /* HAVE_KRB5 */ /* this saves a few linking headaches */ int cli_krb5_get_ticket(const char *principal, time_t time_offset, -- cgit