#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "libcli/ldap/ldap.h"
+#include "libcli/ldap/ldap_ndr.h"
#include "libcli/cldap/cldap.h"
#include "lib/socket/socket.h"
#include "libcli/security/security.h"
req->state = CLDAP_REQUEST_SEND;
req->timeout = io->in.timeout;
req->num_retries = io->in.retries;
- req->is_reply = False;
+ req->is_reply = false;
req->asn1 = asn1_init(req);
if (!req->asn1) {
goto failed;
req->dest = socket_address_from_strings(req, cldap->sock->backend_name,
io->in.dest_address,
- lp_cldap_port());
+ io->in.dest_port);
if (!req->dest) goto failed;
req->message_id = idr_get_new_random(cldap->idr, req, UINT16_MAX);
search->deref = LDAP_DEREFERENCE_NEVER;
search->timelimit = 0;
search->sizelimit = 0;
- search->attributesonly = False;
+ search->attributesonly = false;
search->num_attributes = str_list_length(io->in.attributes);
search->attributes = io->in.attributes;
search->tree = ldb_parse_tree(req, io->in.filter);
req->cldap = cldap;
req->state = CLDAP_REQUEST_SEND;
- req->is_reply = True;
+ req->is_reply = true;
req->asn1 = asn1_init(req);
if (!req->asn1) {
goto failed;
ldap_encode_ndr_uint32(tmp_ctx, io->in.version));
if (filter == NULL) goto failed;
if (io->in.user) {
- filter = talloc_asprintf_append(filter, "(User=%s)", io->in.user);
+ filter = talloc_asprintf_append_buffer(filter, "(User=%s)", io->in.user);
if (filter == NULL) goto failed;
}
if (io->in.host) {
- filter = talloc_asprintf_append(filter, "(Host=%s)", io->in.host);
+ filter = talloc_asprintf_append_buffer(filter, "(Host=%s)", io->in.host);
if (filter == NULL) goto failed;
}
if (io->in.realm) {
- filter = talloc_asprintf_append(filter, "(DnsDomain=%s)", io->in.realm);
+ filter = talloc_asprintf_append_buffer(filter, "(DnsDomain=%s)", io->in.realm);
if (filter == NULL) goto failed;
}
if (io->in.acct_control != -1) {
- filter = talloc_asprintf_append(filter, "(AAC=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(AAC=%s)",
ldap_encode_ndr_uint32(tmp_ctx, io->in.acct_control));
if (filter == NULL) goto failed;
}
if (io->in.domain_sid) {
struct dom_sid *sid = dom_sid_parse_talloc(tmp_ctx, io->in.domain_sid);
if (sid == NULL) goto failed;
- filter = talloc_asprintf_append(filter, "(domainSid=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(domainSid=%s)",
ldap_encode_ndr_dom_sid(tmp_ctx, sid));
if (filter == NULL) goto failed;
}
NTSTATUS status;
status = GUID_from_string(io->in.domain_guid, &guid);
if (!NT_STATUS_IS_OK(status)) goto failed;
- filter = talloc_asprintf_append(filter, "(DomainGuid=%s)",
+ filter = talloc_asprintf_append_buffer(filter, "(DomainGuid=%s)",
ldap_encode_ndr_GUID(tmp_ctx, &guid));
if (filter == NULL) goto failed;
}
- filter = talloc_asprintf_append(filter, ")");
+ filter = talloc_asprintf_append_buffer(filter, ")");
if (filter == NULL) goto failed;
search.in.dest_address = io->in.dest_address;
+ search.in.dest_port = io->in.dest_port;
search.in.filter = filter;
search.in.attributes = attr;
search.in.timeout = 2;
struct cldap_netlogon *io)
{
NTSTATUS status;
+ enum ndr_err_code ndr_err;
struct cldap_search search;
DATA_BLOB *data;
}
data = search.out.response->attributes[0].values;
- status = ndr_pull_union_blob(data, mem_ctx, &io->out.netlogon,
- io->in.version & 0xF,
- (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_pull_union_blob_all(data, mem_ctx,
+ lp_iconv_convenience(global_loadparm),
+ &io->out.netlogon,
+ io->in.version & 0xF,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
DEBUG(2,("cldap failed to parse netlogon response of type 0x%02x\n",
SVAL(data->data, 0)));
dump_data(10, data->data, data->length);
+ return ndr_map_error2ntstatus(ndr_err);
}
- return status;
+ return NT_STATUS_OK;
}
/*
union nbt_cldap_netlogon *netlogon)
{
NTSTATUS status;
+ enum ndr_err_code ndr_err;
struct cldap_reply reply;
struct ldap_SearchResEntry response;
struct ldap_Result result;
TALLOC_CTX *tmp_ctx = talloc_new(cldap);
DATA_BLOB blob;
- status = ndr_push_union_blob(&blob, tmp_ctx, netlogon, version & 0xF,
+ ndr_err = ndr_push_union_blob(&blob, tmp_ctx,
+ lp_iconv_convenience(global_loadparm),
+ netlogon, version & 0xF,
(ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
- return status;
+ return ndr_map_error2ntstatus(ndr_err);
}
reply.messageid = message_id;