diff options
author | Martin Nagy <mnagy@redhat.com> | 2009-03-12 14:54:56 +0100 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2009-03-16 15:45:47 +0100 |
commit | 038f85774090e12e0c8c61aadaea50f99da1e32b (patch) | |
tree | a81decb941b5f0e07ac9e01060d335d0c16809e6 | |
parent | 37e8990310e7f132cb841f66d2c3713de6501c5f (diff) | |
download | ldap_driver_testing-038f85774090e12e0c8c61aadaea50f99da1e32b.tar.gz ldap_driver_testing-038f85774090e12e0c8c61aadaea50f99da1e32b.tar.xz ldap_driver_testing-038f85774090e12e0c8c61aadaea50f99da1e32b.zip |
Add rdatatype_to_ldap_record() function.
This function will convert dns_rdatatype_t into LDAP attribute name.
-rw-r--r-- | ldap_convert.c | 30 | ||||
-rw-r--r-- | ldap_convert.h | 3 |
2 files changed, 29 insertions, 4 deletions
diff --git a/ldap_convert.c b/ldap_convert.c index 1bf9dea..c22d2da 100644 --- a/ldap_convert.c +++ b/ldap_convert.c @@ -51,10 +51,10 @@ const char *ldap_dns_records[] = { }; const char *dns_records[] = { - "a", "aaaa", "a6", "ns", - "cname", "ptr", "srv", "txt", "mx", - "md", "hinfo", "minfo", "afsdb", "sig", - "key", "loc", "NXT", "NAPTR", "KX", + "A", "AAAA", "A6", "NS", + "CNAME", "PTR", "SRV", "TXT", "MX", + "MD", "HINFO", "MINFO", "AFSDB", "SIG", + "KEY", "LOC", "NXT", "NAPTR", "KX", "CERT", "DNAME", "DS", "SSHFP", "RRSIG", "NSEC", NULL }; @@ -205,6 +205,9 @@ count_rdns(char **exploded) return ret; } +/* + * FIXME: Don't assume that the last RDN consists of the last two labels. + */ isc_result_t dnsname_to_dn(isc_mem_t *mctx, dns_name_t *name, const char *root_dn, ld_string_t *target) @@ -278,3 +281,22 @@ ldap_record_to_rdatatype(const char *ldap_record, dns_rdatatype_t *rdtype) return result; } + +isc_result_t +rdatatype_to_ldap_attribute(dns_rdatatype_t rdtype, const char **target) +{ + unsigned i; + char rdtype_str[DNS_RDATATYPE_FORMATSIZE]; + + dns_rdatatype_format(rdtype, rdtype_str, DNS_RDATATYPE_FORMATSIZE); + for (i = 0; dns_records[i] != NULL; i++) { + if (!strcmp(rdtype_str, dns_records[i])) + break; + } + if (ldap_dns_records[i] == NULL) + return ISC_R_NOTFOUND; + + *target = ldap_dns_records[i]; + + return ISC_R_SUCCESS; +} diff --git a/ldap_convert.h b/ldap_convert.h index 9f62497..fded592 100644 --- a/ldap_convert.h +++ b/ldap_convert.h @@ -38,4 +38,7 @@ isc_result_t dnsname_to_dn(isc_mem_t *mctx, dns_name_t *name, isc_result_t ldap_record_to_rdatatype(const char *ldap_record, dns_rdatatype_t *rdtype); +isc_result_t rdatatype_to_ldap_attribute(dns_rdatatype_t rdtype, + const char **target); + #endif /* !_LD_LDAP_CONVERT_H_ */ |