1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

r24804: As a temporary workaround, also try to guess the server's principal in the

"not_defined_in_RFC4178@please_ignore" case to make at least LDAP SASL binds
succeed with windows server 2008.

Guenther
(This used to be commit f5b3de4d30)
This commit is contained in:
Günther Deschner 2007-08-30 15:39:51 +00:00 committed by Gerald (Jerry) Carter
parent 941a783f1a
commit 647abf0a7b
3 changed files with 74 additions and 43 deletions

View File

@ -394,4 +394,6 @@ typedef struct {
#define ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY "edacfd8f-ffb3-11d1-b41d-00a0c968f939" #define ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY "edacfd8f-ffb3-11d1-b41d-00a0c968f939"
#define ADS_IGNORE_PRINCIPAL "not_defined_in_RFC4178@please_ignore"
#endif /* _INCLUDE_ADS_H_ */ #endif /* _INCLUDE_ADS_H_ */

View File

@ -657,52 +657,23 @@ static ADS_STATUS ads_generate_service_principal(ADS_STRUCT *ads,
ZERO_STRUCTP(p); ZERO_STRUCTP(p);
/* I've seen a child Windows 2000 domain not send /* I've seen a child Windows 2000 domain not send
the principal name back in the first round of the principal name back in the first round of
the SASL bind reply. So we guess based on server the SASL bind reply. So we guess based on server
name and realm. --jerry */ name and realm. --jerry */
if (given_principal) { /* Also try best guess when we get the w2k8 ignore
principal back - gd */
if (!given_principal ||
strequal(given_principal, ADS_IGNORE_PRINCIPAL)) {
status = ads_guess_service_principal(ads, given_principal,
&p->string);
if (!ADS_ERR_OK(status)) {
return status;
}
} else {
p->string = SMB_STRDUP(given_principal); p->string = SMB_STRDUP(given_principal);
if (!p->string) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
} else 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) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
strlower_m(server);
strupper_m(server_realm);
asprintf(&p->string, "ldap/%s@%s", server, server_realm);
SAFE_FREE(server);
SAFE_FREE(server_realm);
if (!p->string) {
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) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
strlower_m(server);
strupper_m(server_realm);
asprintf(&p->string, "ldap/%s@%s", server, server_realm);
SAFE_FREE(server);
SAFE_FREE(server_realm);
if (!p->string) { if (!p->string) {
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }

View File

@ -51,4 +51,62 @@ failed:
SAFE_FREE(password); SAFE_FREE(password);
return ret; return ret;
} }
ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
const char *given_principal,
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) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
strlower_m(server);
strupper_m(server_realm);
asprintf(&princ, "ldap/%s@%s", server, server_realm);
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) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
strlower_m(server);
strupper_m(server_realm);
asprintf(&princ, "ldap/%s@%s", server, server_realm);
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;
}
#endif #endif