diff options
author | Amitay Isaacs <amitay@gmail.com> | 2011-12-19 12:13:46 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2011-12-23 16:18:25 +1100 |
commit | e398bdb76bf6a85c757d3152be77d02fd0febac4 (patch) | |
tree | efc27f426f87f48b8542436df8faeca448d56b2b /source4/rpc_server | |
parent | f14ddcc2e13cae85545e516bdd44e93d2a7301c5 (diff) | |
download | samba-e398bdb76bf6a85c757d3152be77d02fd0febac4.tar.gz samba-e398bdb76bf6a85c757d3152be77d02fd0febac4.tar.bz2 samba-e398bdb76bf6a85c757d3152be77d02fd0febac4.zip |
s4:rpc-dnsserver: Add multiple DNS records in a single operation
This allows to add dnsNode objectclass with multiple DNS records in a
single operation. Useful for creating @ record which has NS and SOA
records.
Diffstat (limited to 'source4/rpc_server')
-rw-r--r-- | source4/rpc_server/dnsserver/dnsdb.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/source4/rpc_server/dnsserver/dnsdb.c b/source4/rpc_server/dnsserver/dnsdb.c index e7bd28d382..939365840b 100644 --- a/source4/rpc_server/dnsserver/dnsdb.c +++ b/source4/rpc_server/dnsserver/dnsdb.c @@ -300,15 +300,18 @@ static unsigned int dnsserver_update_soa(TALLOC_CTX *mem_ctx, } +/* Add DNS record to the database */ static WERROR dnsserver_db_do_add_rec(TALLOC_CTX *mem_ctx, struct ldb_context *samdb, struct ldb_dn *dn, + int num_rec, struct dnsp_DnssrvRpcRecord *rec) { struct ldb_message *msg; struct ldb_val v; int ret; enum ndr_err_code ndr_err; + int i; msg = ldb_msg_new(mem_ctx); W_ERROR_HAVE_NO_MEMORY(msg); @@ -319,16 +322,18 @@ static WERROR dnsserver_db_do_add_rec(TALLOC_CTX *mem_ctx, return WERR_NOMEM; } - if (rec) { - ndr_err = ndr_push_struct_blob(&v, mem_ctx, rec, - (ndr_push_flags_fn_t)ndr_push_dnsp_DnssrvRpcRecord); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return WERR_GENERAL_FAILURE; - } + if (num_rec > 0 && rec) { + for (i=0; i<num_rec; i++) { + ndr_err = ndr_push_struct_blob(&v, mem_ctx, &rec[i], + (ndr_push_flags_fn_t)ndr_push_dnsp_DnssrvRpcRecord); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return WERR_GENERAL_FAILURE; + } - ret = ldb_msg_add_value(msg, "dnsRecord", &v, NULL); - if (ret != LDB_SUCCESS) { - return WERR_NOMEM; + ret = ldb_msg_add_value(msg, "dnsRecord", &v, NULL); + if (ret != LDB_SUCCESS) { + return WERR_NOMEM; + } } } @@ -369,7 +374,7 @@ WERROR dnsserver_db_add_empty_node(TALLOC_CTX *mem_ctx, return WERR_NOMEM; } - return dnsserver_db_do_add_rec(mem_ctx, samdb, dn, NULL); + return dnsserver_db_do_add_rec(mem_ctx, samdb, dn, 0, NULL); } @@ -414,7 +419,7 @@ WERROR dnsserver_db_add_record(TALLOC_CTX *mem_ctx, dn = dnsserver_name_to_dn(mem_ctx, z, name); W_ERROR_HAVE_NO_MEMORY(dn); - return dnsserver_db_do_add_rec(mem_ctx, samdb, dn, rec); + return dnsserver_db_do_add_rec(mem_ctx, samdb, dn, 1, rec); } el = ldb_msg_find_element(res->msgs[0], "dnsRecord"); |