return (int)ret;
}
+#ifdef HAVE_ADS
+
/**********************************************************************
Adds a single service principal, i.e. 'host' to the system keytab
***********************************************************************/
goto out;
}
- my_fqdn = ads_get_dnshostname(ads, tmpctx, global_myname());
+ my_fqdn = ads_get_dnshostname(ads, tmpctx, lp_netbios_name());
if (!my_fqdn) {
DEBUG(0, (__location__ ": unable to determine machine "
"account's dns name in AD!\n"));
goto out;
}
- machine_name = ads_get_samaccountname(ads, tmpctx, global_myname());
+ machine_name = ads_get_samaccountname(ads, tmpctx, lp_netbios_name());
if (!machine_name) {
DEBUG(0, (__location__ ": unable to determine machine "
"account's short name in AD!\n"));
"'%s'\n", princ_s));
aderr = ads_add_service_principal_name(ads,
- global_myname(), my_fqdn, srvPrinc);
+ lp_netbios_name(), my_fqdn, srvPrinc);
if (!ADS_ERR_OK(aderr)) {
DEBUG(1, (__location__ ": failed to "
"ads_add_service_principal_name.\n"));
}
}
- kvno = (krb5_kvno)ads_get_machine_kvno(ads, global_myname());
+ kvno = (krb5_kvno)ads_get_machine_kvno(ads, lp_netbios_name());
if (kvno == -1) {
/* -1 indicates failure, everything else is OK */
DEBUG(1, (__location__ ": ads_get_machine_kvno failed to "
goto out;
}
- kvno = (krb5_kvno)ads_get_machine_kvno(ads, global_myname());
+ kvno = (krb5_kvno)ads_get_machine_kvno(ads, lp_netbios_name());
if (kvno == -1) {
/* -1 indicates a failure */
DEBUG(1, (__location__ ": Error determining the kvno.\n"));
goto out;
}
- aderr = ads_clear_service_principal_names(ads, global_myname());
+ aderr = ads_clear_service_principal_names(ads, lp_netbios_name());
if (!ADS_ERR_OK(aderr)) {
DEBUG(1, (__location__ ": Error while clearing service "
"principal listings in LDAP.\n"));
goto done;
}
- machine_name = talloc_strdup(tmpctx, global_myname());
+ machine_name = talloc_strdup(tmpctx, lp_netbios_name());
if (!machine_name) {
ret = -1;
goto done;
/* upper case the sAMAccountName to make it easier for apps to
know what case to use in the keytab file */
- strupper_m(sam_account_name);
+ if (!strupper_m(sam_account_name)) {
+ ret = -1;
+ goto done;
+ }
ret = ads_keytab_add_entry(ads, sam_account_name);
if (ret != 0) {
return ret;
}
+#endif /* HAVE_ADS */
+
/**********************************************************************
List system keytab.
***********************************************************************/
goto out;
}
- printf("Vno Type Principal\n");
+ printf("Vno Type Principal\n");
while (krb5_kt_next_entry(context, keytab, &kt_entry, &cursor) == 0) {
goto out;
}
- printf("%3d %s\t\t %s\n", kt_entry.vno, etype_s, princ_s);
+ printf("%3d %-43s %s\n", kt_entry.vno, etype_s, princ_s);
TALLOC_FREE(princ_s);
SAFE_FREE(etype_s);