mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
CLDAP: generate NetBIOS name like ipa-adtrust-install does
Fixes https://fedorahosted.org/freeipa/ticket/4116
This commit is contained in:
parent
b4401a1770
commit
311b2b1acf
@ -51,6 +51,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <dirsrv/slapi-plugin.h>
|
||||
#include <talloc.h>
|
||||
#include "util.h"
|
||||
|
||||
#define IPA_CLDAP_PLUGIN_NAME "CLDAP Server"
|
||||
@ -106,4 +107,5 @@ int ipa_cldap_netlogon(struct ipa_cldap_ctx *ctx,
|
||||
struct ipa_cldap_req *req,
|
||||
struct berval *reply);
|
||||
|
||||
char *make_netbios_name(TALLOC_CTX *mem_ctx, const char *s);
|
||||
#endif /* _IPA_CLDAP_H_ */
|
||||
|
@ -121,6 +121,38 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *make_netbios_name(TALLOC_CTX *mem_ctx, const char *s)
|
||||
{
|
||||
char *nb_name;
|
||||
const char *p;
|
||||
size_t c = 0;
|
||||
|
||||
if (s == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nb_name = talloc_zero_size(mem_ctx, NETBIOS_NAME_MAX + 1);
|
||||
if (nb_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (p = s; *p && c < NETBIOS_NAME_MAX; p++) {
|
||||
/* Create the NetBIOS name from the first segment of the hostname */
|
||||
if (*p == '.') {
|
||||
break;
|
||||
} else if (isalnum(*p)) {
|
||||
nb_name[c++] = toupper(*p);
|
||||
}
|
||||
}
|
||||
|
||||
if (*nb_name == '\0') {
|
||||
talloc_free(nb_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nb_name;
|
||||
}
|
||||
|
||||
#define NETLOGON_SAM_LOGON_RESPONSE_EX_pusher \
|
||||
(ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX
|
||||
|
||||
@ -131,8 +163,6 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
|
||||
struct NETLOGON_SAM_LOGON_RESPONSE_EX *nlr;
|
||||
enum ndr_err_code ndr_err;
|
||||
DATA_BLOB blob;
|
||||
char *pdc_name;
|
||||
char *p;
|
||||
int ret;
|
||||
|
||||
nlr = talloc_zero(NULL, struct NETLOGON_SAM_LOGON_RESPONSE_EX);
|
||||
@ -162,18 +192,7 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
|
||||
nlr->pdc_dns_name = fq_hostname;
|
||||
nlr->domain_name = name;
|
||||
|
||||
/* copy the first 15 characters of the fully qualified hostname*/
|
||||
pdc_name = talloc_asprintf(nlr, "%.*s", NETBIOS_NAME_MAX, fq_hostname);
|
||||
|
||||
for (p = pdc_name; *p; p++) {
|
||||
/* Create the NetBIOS name from the first segment of the hostname */
|
||||
if (*p == '.') {
|
||||
*p = '\0';
|
||||
break;
|
||||
}
|
||||
*p = toupper(*p);
|
||||
}
|
||||
nlr->pdc_name = pdc_name;
|
||||
nlr->pdc_name = make_netbios_name(nlr, fq_hostname);
|
||||
nlr->user_name = "";
|
||||
nlr->server_site = "Default-First-Site-Name";
|
||||
nlr->client_site = "Default-First-Site-Name";
|
||||
|
Loading…
Reference in New Issue
Block a user