s3-kerberos: add smb_krb5_principal_get_realm().
authorGünther Deschner <gd@samba.org>
Wed, 11 Nov 2009 23:51:46 +0000 (00:51 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 12 Nov 2009 09:22:39 +0000 (10:22 +0100)
Guenther

source3/include/includes.h
source3/libsmb/clikrb5.c

index 8bd27b99e3c256e4dd10ba2944329acc9654ad42..cbf30d6158b4c60d551c9aa40dbc4561130023c3 100644 (file)
@@ -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 */
 
 
index d5a910bfbda2c51087fc7ca0012f9d511917b39f..e86c6c4531a08f7d6f4fd83cf9f11438ebcc4f0b 100644 (file)
@@ -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,