#include "includes.h"
#include "lib/events/events.h"
-#include "lib/util/dlinklist.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"
#include "librpc/gen_ndr/ndr_nbt.h"
-#include "param/param.h"
/*
destroy a pending request
}
/* this initial decode is used to find the message id */
- status = ldap_decode(asn1, ldap_msg);
+ status = ldap_decode(asn1, NULL, ldap_msg);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to decode ldap message: %s\n", nt_errstr(status)));
talloc_free(tmp_ctx);
/*
handle request timeouts
*/
-static void cldap_request_timeout(struct event_context *event_ctx,
- struct timed_event *te, struct timeval t,
- void *private)
+static void cldap_request_timeout(struct tevent_context *event_ctx,
+ struct tevent_timer *te, struct timeval t,
+ void *private_data)
{
- struct cldap_request *req = talloc_get_type(private, struct cldap_request);
+ struct cldap_request *req = talloc_get_type(private_data, struct cldap_request);
/* possibly try again */
if (req->num_retries != 0) {
/*
handle fd events on a cldap_socket
*/
-static void cldap_socket_handler(struct event_context *ev, struct fd_event *fde,
- uint16_t flags, void *private)
+static void cldap_socket_handler(struct tevent_context *ev, struct tevent_fd *fde,
+ uint16_t flags, void *private_data)
{
- struct cldap_socket *cldap = talloc_get_type(private, struct cldap_socket);
+ struct cldap_socket *cldap = talloc_get_type(private_data, struct cldap_socket);
if (flags & EVENT_FD_WRITE) {
cldap_socket_send(cldap);
}
then operations will use that event context
*/
struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
- struct event_context *event_ctx,
+ struct tevent_context *event_ctx,
struct smb_iconv_convenience *iconv_convenience)
{
struct cldap_socket *cldap;
cldap = talloc(mem_ctx, struct cldap_socket);
if (cldap == NULL) goto failed;
- if (event_ctx == NULL) {
- cldap->event_ctx = event_context_init(cldap);
- } else {
- cldap->event_ctx = talloc_reference(cldap, event_ctx);
- }
+ cldap->event_ctx = talloc_reference(cldap, event_ctx);
if (cldap->event_ctx == NULL) goto failed;
cldap->idr = idr_init(cldap);
NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
void (*handler)(struct cldap_socket *, struct ldap_message *,
struct socket_address *),
- void *private)
+ void *private_data)
{
cldap->incoming.handler = handler;
- cldap->incoming.private = private;
+ cldap->incoming.private_data = private_data;
EVENT_FD_READABLE(cldap->fde);
return NT_STATUS_OK;
}
goto failed;
}
- if (!ldap_encode(msg, &req->encoded, req)) {
+ if (!ldap_encode(msg, NULL, &req->encoded, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest->addr, req->dest->port));
goto failed;
msg->type = LDAP_TAG_SearchResultEntry;
msg->r.SearchResultEntry = *io->response;
- if (!ldap_encode(msg, &blob1, req)) {
+ if (!ldap_encode(msg, NULL, &blob1, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest->addr, req->dest->port));
status = NT_STATUS_INVALID_PARAMETER;
msg->type = LDAP_TAG_SearchResultDone;
msg->r.SearchResultDone = *io->result;
- if (!ldap_encode(msg, &blob2, req)) {
+ if (!ldap_encode(msg, NULL, &blob2, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest->addr, req->dest->port));
status = NT_STATUS_INVALID_PARAMETER;
ldap_msg = talloc(mem_ctx, struct ldap_message);
NT_STATUS_HAVE_NO_MEMORY(ldap_msg);
- status = ldap_decode(req->asn1, ldap_msg);
+ status = ldap_decode(req->asn1, NULL, ldap_msg);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to decode cldap search reply: %s\n", nt_errstr(status)));
talloc_free(req);
*io->out.response = ldap_msg->r.SearchResultEntry;
/* decode the 2nd part */
- status = ldap_decode(req->asn1, ldap_msg);
+ status = ldap_decode(req->asn1, NULL, ldap_msg);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to decode cldap search result entry: %s\n", nt_errstr(status)));
talloc_free(req);
struct cldap_netlogon *io)
{
NTSTATUS status;
- enum ndr_err_code ndr_err;
struct cldap_search search;
+ struct cldap_socket *cldap;
DATA_BLOB *data;
+ cldap = req->cldap;
+
status = cldap_search_recv(req, mem_ctx, &search);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
data = search.out.response->attributes[0].values;
- ndr_err = ndr_pull_union_blob_all(data, mem_ctx,
- req->cldap->iconv_convenience,
- &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);
+ status = pull_netlogon_samlogon_response(data, mem_ctx, req->cldap->iconv_convenience,
+ &io->out.netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (io->in.map_response) {
+ map_netlogon_samlogon_response(&io->out.netlogon);
}
-
return NT_STATUS_OK;
}
uint32_t message_id,
struct socket_address *src,
uint32_t version,
- union nbt_cldap_netlogon *netlogon)
+ struct netlogon_samlogon_response *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;
- ndr_err = ndr_push_union_blob(&blob, tmp_ctx,
- cldap->iconv_convenience,
- netlogon, version & 0xF,
- (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(tmp_ctx);
- return ndr_map_error2ntstatus(ndr_err);
+ status = push_netlogon_samlogon_response(&blob, tmp_ctx, cldap->iconv_convenience,
+ netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
reply.messageid = message_id;
reply.dest = src;
reply.response = &response;