summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/libcli/cldap/cldap.c26
-rw-r--r--source4/libcli/cldap/cldap.h4
-rw-r--r--source4/param/loadparm.c6
3 files changed, 31 insertions, 5 deletions
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index a28afc6877..75ce0a67db 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -41,7 +41,6 @@
#include "include/asn_1.h"
#define CLDAP_MAX_PACKET_SIZE 2048
-const unsigned CLDAP_PORT = 389;
/*
destroy a pending request
@@ -112,8 +111,12 @@ static void cldap_socket_recv(struct cldap_socket *cldap)
/* find the pending request */
req = idr_find(cldap->idr, ldap_msg.messageid);
if (req == NULL) {
- DEBUG(2,("Mismatched cldap reply %u from %s:%d\n",
- ldap_msg.messageid, src_addr, src_port));
+ if (cldap->incoming.handler) {
+ cldap->incoming.handler(cldap, &ldap_msg, src_addr, src_port);
+ } else {
+ DEBUG(2,("Mismatched cldap reply %u from %s:%d\n",
+ ldap_msg.messageid, src_addr, src_port));
+ }
talloc_free(tmp_ctx);
return;
}
@@ -249,6 +252,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
cldap_socket_handler, cldap);
cldap->send_queue = NULL;
+ cldap->incoming.handler = NULL;
return cldap;
@@ -259,6 +263,20 @@ failed:
/*
+ setup a handler for incoming requests
+*/
+NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
+ void (*handler)(struct cldap_socket *, struct ldap_message *,
+ const char *, int ),
+ void *private)
+{
+ cldap->incoming.handler = handler;
+ cldap->incoming.private = private;
+ EVENT_FD_READABLE(cldap->fde);
+ return NT_STATUS_OK;
+}
+
+/*
queue a cldap request for send
*/
struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
@@ -278,7 +296,7 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
req->dest_addr = talloc_strdup(req, io->in.dest_address);
if (req->dest_addr == NULL) goto failed;
- req->dest_port = CLDAP_PORT;
+ req->dest_port = lp_cldap_port();
req->message_id = idr_get_new_random(cldap->idr, req, UINT16_MAX);
if (req->message_id == -1) goto failed;
diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h
index a8bba7edbe..8a678b4539 100644
--- a/source4/libcli/cldap/cldap.h
+++ b/source4/libcli/cldap/cldap.h
@@ -108,6 +108,10 @@ struct cldap_search {
struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
struct event_context *event_ctx);
+NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
+ void (*handler)(struct cldap_socket *, struct ldap_message *,
+ const char *, int ),
+ void *private);
struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
struct cldap_search *io);
NTSTATUS cldap_search_recv(struct cldap_request *req, TALLOC_CTX *mem_ctx,
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index f436d8fd0b..15dd070c00 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -237,6 +237,7 @@ typedef struct
int iLockSpinTime;
int nbt_port;
int dgram_port;
+ int cldap_port;
char *socket_options;
BOOL bDNSproxy;
BOOL bWINSsupport;
@@ -619,6 +620,7 @@ static struct parm_struct parm_table[] = {
{"smb ports", P_LIST, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"nbt port", P_INTEGER, P_GLOBAL, &Globals.nbt_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"dgram port", P_INTEGER, P_GLOBAL, &Globals.dgram_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
+ {"cldap port", P_INTEGER, P_GLOBAL, &Globals.cldap_port, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER},
{"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_DEVELOPER},
{"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
{"min protocol", P_ENUM, P_GLOBAL, &Globals.minprotocol, NULL, enum_protocol, FLAG_DEVELOPER},
@@ -936,7 +938,7 @@ static void init_globals(void)
do_parameter("max connections", "-1");
do_parameter("dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup");
- do_parameter("server services", "smb rpc nbt");
+ do_parameter("server services", "smb rpc nbt cldap");
do_parameter("auth methods", "anonymous sam_ignoredomain");
do_parameter("smb passwd file", dyn_SMB_PASSWD_FILE);
do_parameter("private dir", dyn_PRIVATE_DIR);
@@ -1054,6 +1056,7 @@ static void init_globals(void)
do_parameter("smb ports", SMB_PORTS);
do_parameter("nbt port", "137");
do_parameter("dgram port", "138");
+ do_parameter("cldap port", "389");
do_parameter("nt status support", "True");
@@ -1156,6 +1159,7 @@ static const char *lp_string(const char *s)
FN_GLOBAL_LIST(lp_smb_ports, &Globals.smb_ports)
FN_GLOBAL_INTEGER(lp_nbt_port, &Globals.nbt_port)
FN_GLOBAL_INTEGER(lp_dgram_port, &Globals.dgram_port)
+FN_GLOBAL_INTEGER(lp_cldap_port, &Globals.cldap_port)
FN_GLOBAL_STRING(lp_dos_charset, &Globals.dos_charset)
FN_GLOBAL_STRING(lp_unix_charset, &Globals.unix_charset)
FN_GLOBAL_STRING(lp_display_charset, &Globals.display_charset)