Check for zero records and warn

git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@329 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
Ben Klang
2006-06-13 16:42:14 +00:00
parent e88f805d1a
commit 793ec55e98

View File

@@ -606,6 +606,10 @@ static void read_resourcerecords(char* dn, int znix)
if ( (ldaperr = ldap_search_ext_s(ldap_con, dn, LDAP_SCOPE_SUBTREE, "objectclass=DNSrrset", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS )
die_ldap(ldaperr);
if (ldap_count_entries(ldap_con, res) < 1) {
fprintf(stderr, "[**] Warning: No records returned from search. Check for correct credentials,\n[**] LDAP hostname, and search base DN.\n\n");
return;
}
for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) {
BerElement* ber = NULL;
char* attr;
@@ -803,6 +807,11 @@ static void calc_checksum(int* num, int* sum)
*num = *sum = 0;
if ( ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSzone", attr_list, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res)!=LDAP_SUCCESS )
die_ldap(ldaperr);
if (ldap_count_entries(ldap_con, res) < 1) {
fprintf(stderr, "[**] Warning: No records returned from search. Check for correct credentials,\n[**] LDAP hostname, and search base DN.\n\n");
return;
}
for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) {
BerElement* ber = NULL;
char* attr = ldap_first_attribute(ldap_con, m, &ber);
@@ -835,6 +844,10 @@ static void read_dnszones(void)
fprintf(namedmaster, "# Automatically generated by ldap2dns v%s - DO NOT EDIT!\n", VERSION);
if ( (ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSzone", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS )
die_ldap(ldaperr);
if (ldap_count_entries(ldap_con, res) < 1) {
fprintf(stderr, "[**] Warning: No records returned from search. Check for correct credentials,\n[**] LDAP hostname, and search base DN.\n\n");
return;
}
for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) {
BerElement* ber = NULL;
char* attr;
@@ -976,6 +989,10 @@ static void read_loccodes(void)
if ( (ldaperr = ldap_search_ext_s(ldap_con, options.searchbase[0] ? options.searchbase : NULL, LDAP_SCOPE_SUBTREE, "objectclass=DNSloccodes", NULL, 0, NULL, NULL, &options.searchtimeout, options.reclimit, &res))!=LDAP_SUCCESS )
die_ldap(ldaperr);
if (ldap_count_entries(ldap_con, res) < 1) {
fprintf(stderr, "[**] Warning: No records returned from search. Check for correct credentials,\n[**] LDAP hostname, and search base DN.\n\n");
return;
}
for (m = ldap_first_entry(ldap_con, res); m; m = ldap_next_entry(ldap_con, m)) {
BerElement* ber = NULL;
char* attr;