Merge branch 'master' of ssh://git.samba.org/data/git/samba into arc4
[jra/samba/.git] / source4 / cldap_server / cldap_server.c
index 58e9e2d89b53af56db9002fac2d322e749af27e5..240f2b1dc23d3cb5ba9ea5d94e2ed8d9ac3bf2db 100644 (file)
@@ -127,6 +127,7 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l
        int num_interfaces;
        TALLOC_CTX *tmp_ctx = talloc_new(cldapd);
        NTSTATUS status;
+       int i;
 
        num_interfaces = iface_count(ifaces);
 
@@ -135,14 +136,14 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l
        if (!lp_bind_interfaces_only(lp_ctx)) {
                status = cldapd_add_socket(cldapd, lp_ctx, "0.0.0.0");
                NT_STATUS_NOT_OK_RETURN(status);
-       } else {
-               int i;
-
-               for (i=0; i<num_interfaces; i++) {
-                       const char *address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i));
-                       status = cldapd_add_socket(cldapd, lp_ctx, address);
-                       NT_STATUS_NOT_OK_RETURN(status);
-               }
+       }
+
+       /* now we have to also listen on the specific interfaces,
+          so that replies always come from the right IP */
+       for (i=0; i<num_interfaces; i++) {
+               const char *address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i));
+               status = cldapd_add_socket(cldapd, lp_ctx, address);
+               NT_STATUS_NOT_OK_RETURN(status);
        }
 
        talloc_free(tmp_ctx);
@@ -187,7 +188,7 @@ static void cldapd_task_init(struct task_server *task)
        }
 
        cldapd->task = task;
-       cldapd->samctx = samdb_connect(cldapd, task->event_ctx, task->lp_ctx, anonymous_session(cldapd, task->event_ctx, task->lp_ctx));
+       cldapd->samctx = samdb_connect(cldapd, task->event_ctx, task->lp_ctx, system_session(cldapd, task->lp_ctx));
        if (cldapd->samctx == NULL) {
                task_server_terminate(task, "cldapd failed to open samdb");
                return;