summaryrefslogtreecommitdiff
path: root/source3/libads/sasl.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-02-11 11:14:27 +0100
committerGünther Deschner <gd@samba.org>2011-02-11 12:22:41 +0100
commitf076c76260f24e15be11394ea0bb9456564dda49 (patch)
tree873de80db04f57d91065ac4fe74ad3515d178bcb /source3/libads/sasl.c
parent16229e4cefb01c3bdf1cb1cef81f0eab1f1cc0e6 (diff)
downloadsamba-f076c76260f24e15be11394ea0bb9456564dda49.tar.gz
s3-libads: make ads_guess_service_principal static.
Guenther
Diffstat (limited to 'source3/libads/sasl.c')
-rw-r--r--source3/libads/sasl.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 2ba347486a6..e7daa8aec63 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -644,6 +644,75 @@ static void ads_free_service_principal(struct ads_service_principal *p)
ZERO_STRUCTP(p);
}
+
+static ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
+ char **returned_principal)
+{
+ char *princ = NULL;
+
+ if (ads->server.realm && ads->server.ldap_server) {
+ char *server, *server_realm;
+
+ server = SMB_STRDUP(ads->server.ldap_server);
+ server_realm = SMB_STRDUP(ads->server.realm);
+
+ if (!server || !server_realm) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ strlower_m(server);
+ strupper_m(server_realm);
+ if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+
+ if (!princ) {
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+ } else if (ads->config.realm && ads->config.ldap_server_name) {
+ char *server, *server_realm;
+
+ server = SMB_STRDUP(ads->config.ldap_server_name);
+ server_realm = SMB_STRDUP(ads->config.realm);
+
+ if (!server || !server_realm) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ strlower_m(server);
+ strupper_m(server_realm);
+ if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+
+ if (!princ) {
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+ }
+
+ if (!princ) {
+ return ADS_ERROR(LDAP_PARAM_ERROR);
+ }
+
+ *returned_principal = princ;
+
+ return ADS_SUCCESS;
+}
+
static ADS_STATUS ads_generate_service_principal(ADS_STRUCT *ads,
const char *given_principal,
struct ads_service_principal *p)