r23792: convert Samba4 to GPLv3
[amitay/samba.git] / source4 / libcli / cldap / cldap.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    cldap client library
5
6    Copyright (C) Andrew Tridgell 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 /*
23   see RFC1798 for details of CLDAP
24
25   basic properties
26     - carried over UDP on port 389
27     - request and response matched by message ID
28     - request consists of only a single searchRequest element
29     - response can be in one of two forms
30        - a single searchResponse, followed by a searchResult
31        - a single searchResult
32 */
33
34 #include "includes.h"
35 #include "lib/events/events.h"
36 #include "lib/util/dlinklist.h"
37 #include "libcli/ldap/ldap.h"
38 #include "libcli/cldap/cldap.h"
39 #include "lib/socket/socket.h"
40 #include "libcli/security/security.h"
41 #include "librpc/gen_ndr/ndr_nbt.h"
42
43 /*
44   destroy a pending request
45 */
46 static int cldap_request_destructor(struct cldap_request *req)
47 {
48         if (req->state == CLDAP_REQUEST_SEND) {
49                 DLIST_REMOVE(req->cldap->send_queue, req);
50         }
51         if (!req->is_reply && req->message_id != 0) {
52                 idr_remove(req->cldap->idr, req->message_id);
53                 req->message_id = 0;
54         }
55         return 0;
56 }
57
58 /*
59   handle recv events on a cldap socket
60 */
61 static void cldap_socket_recv(struct cldap_socket *cldap)
62 {
63         TALLOC_CTX *tmp_ctx = talloc_new(cldap);
64         NTSTATUS status;
65         struct socket_address *src;
66         DATA_BLOB blob;
67         size_t nread, dsize;
68         struct asn1_data *asn1 = asn1_init(tmp_ctx);
69         struct ldap_message *ldap_msg;
70         struct cldap_request *req;
71
72         if (!asn1) return;
73
74         status = socket_pending(cldap->sock, &dsize);
75         if (!NT_STATUS_IS_OK(status)) {
76                 talloc_free(tmp_ctx);
77                 return;
78         }
79
80         blob = data_blob_talloc(tmp_ctx, NULL, dsize);
81         if (blob.data == NULL) {
82                 talloc_free(tmp_ctx);
83                 return;
84         }
85
86         status = socket_recvfrom(cldap->sock, blob.data, blob.length, &nread,
87                                  tmp_ctx, &src);
88         if (!NT_STATUS_IS_OK(status)) {
89                 talloc_free(tmp_ctx);
90                 return;
91         }
92         blob.length = nread;
93
94         DEBUG(2,("Received cldap packet of length %d from %s:%d\n", 
95                  (int)blob.length, src->addr, src->port));
96
97         if (!asn1_load(asn1, blob)) {
98                 DEBUG(2,("Failed to setup for asn.1 decode\n"));
99                 talloc_free(tmp_ctx);
100                 return;
101         }
102
103         ldap_msg = talloc(tmp_ctx, struct ldap_message);
104         if (ldap_msg == NULL) {
105                 talloc_free(tmp_ctx);
106                 return;
107         }
108
109         /* this initial decode is used to find the message id */
110         status = ldap_decode(asn1, ldap_msg);
111         if (!NT_STATUS_IS_OK(status)) {
112                 DEBUG(2,("Failed to decode ldap message: %s\n", nt_errstr(status)));
113                 talloc_free(tmp_ctx);
114                 return;
115         }
116
117         /* find the pending request */
118         req = idr_find(cldap->idr, ldap_msg->messageid);
119         if (req == NULL) {
120                 if (cldap->incoming.handler) {
121                         cldap->incoming.handler(cldap, ldap_msg, src);
122                 } else {
123                         DEBUG(2,("Mismatched cldap reply %u from %s:%d\n",
124                                  ldap_msg->messageid, src->addr, src->port));
125                 }
126                 talloc_free(tmp_ctx);
127                 return;
128         }
129
130         req->asn1 = talloc_steal(req, asn1);
131         req->asn1->ofs = 0;
132
133         req->state = CLDAP_REQUEST_DONE;
134         talloc_free(req->te);
135
136         talloc_free(tmp_ctx);
137
138         if (req->async.fn) {
139                 req->async.fn(req);
140         }
141 }
142
143 /*
144   handle request timeouts
145 */
146 static void cldap_request_timeout(struct event_context *event_ctx, 
147                                   struct timed_event *te, struct timeval t,
148                                   void *private)
149 {
150         struct cldap_request *req = talloc_get_type(private, struct cldap_request);
151
152         /* possibly try again */
153         if (req->num_retries != 0) {
154                 size_t len = req->encoded.length;
155
156                 req->num_retries--;
157
158                 socket_sendto(req->cldap->sock, &req->encoded, &len, 
159                               req->dest);
160
161                 req->te = event_add_timed(req->cldap->event_ctx, req, 
162                                           timeval_current_ofs(req->timeout, 0),
163                                           cldap_request_timeout, req);
164                 return;
165         }
166
167         req->state = CLDAP_REQUEST_ERROR;
168         req->status = NT_STATUS_IO_TIMEOUT;
169         if (req->async.fn) {
170                 req->async.fn(req);
171         }
172 }
173
174 /*
175   handle send events on a cldap socket
176 */
177 static void cldap_socket_send(struct cldap_socket *cldap)
178 {
179         struct cldap_request *req;
180         NTSTATUS status;
181
182         while ((req = cldap->send_queue)) {
183                 size_t len;
184                 
185                 len = req->encoded.length;
186                 status = socket_sendto(cldap->sock, &req->encoded, &len,
187                                        req->dest);
188                 if (NT_STATUS_IS_ERR(status)) {
189                         DEBUG(0,("Failed to send cldap request of length %u to %s:%d\n",
190                                  (unsigned)req->encoded.length, req->dest->addr, req->dest->port));
191                         DLIST_REMOVE(cldap->send_queue, req);
192                         req->state = CLDAP_REQUEST_ERROR;
193                         req->status = status;
194                         if (req->async.fn) {
195                                 req->async.fn(req);
196                         }
197                         continue;
198                 }
199
200                 if (!NT_STATUS_IS_OK(status)) return;
201
202                 DLIST_REMOVE(cldap->send_queue, req);
203
204                 if (req->is_reply) {
205                         talloc_free(req);
206                 } else {
207                         req->state = CLDAP_REQUEST_WAIT;
208
209                         req->te = event_add_timed(cldap->event_ctx, req, 
210                                                   timeval_current_ofs(req->timeout, 0),
211                                                   cldap_request_timeout, req);
212
213                         EVENT_FD_READABLE(cldap->fde);
214                 }
215         }
216
217         EVENT_FD_NOT_WRITEABLE(cldap->fde);
218         return;
219 }
220
221
222 /*
223   handle fd events on a cldap_socket
224 */
225 static void cldap_socket_handler(struct event_context *ev, struct fd_event *fde,
226                                  uint16_t flags, void *private)
227 {
228         struct cldap_socket *cldap = talloc_get_type(private, struct cldap_socket);
229         if (flags & EVENT_FD_WRITE) {
230                 cldap_socket_send(cldap);
231         } 
232         if (flags & EVENT_FD_READ) {
233                 cldap_socket_recv(cldap);
234         }
235 }
236
237 /*
238   initialise a cldap_socket. The event_ctx is optional, if provided
239   then operations will use that event context
240 */
241 struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx, 
242                                        struct event_context *event_ctx)
243 {
244         struct cldap_socket *cldap;
245         NTSTATUS status;
246
247         cldap = talloc(mem_ctx, struct cldap_socket);
248         if (cldap == NULL) goto failed;
249
250         if (event_ctx == NULL) {
251                 cldap->event_ctx = event_context_init(cldap);
252         } else {
253                 cldap->event_ctx = talloc_reference(cldap, event_ctx);
254         }
255         if (cldap->event_ctx == NULL) goto failed;
256
257         cldap->idr = idr_init(cldap);
258         if (cldap->idr == NULL) goto failed;
259
260         status = socket_create("ip", SOCKET_TYPE_DGRAM, &cldap->sock, 0);
261         if (!NT_STATUS_IS_OK(status)) goto failed;
262
263         talloc_steal(cldap, cldap->sock);
264
265         cldap->fde = event_add_fd(cldap->event_ctx, cldap, 
266                                       socket_get_fd(cldap->sock), 0,
267                                       cldap_socket_handler, cldap);
268
269         cldap->send_queue = NULL;
270         cldap->incoming.handler = NULL;
271         
272         return cldap;
273
274 failed:
275         talloc_free(cldap);
276         return NULL;
277 }
278
279
280 /*
281   setup a handler for incoming requests
282 */
283 NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
284                                   void (*handler)(struct cldap_socket *, struct ldap_message *, 
285                                                   struct socket_address *),
286                                   void *private)
287 {
288         cldap->incoming.handler = handler;
289         cldap->incoming.private = private;
290         EVENT_FD_READABLE(cldap->fde);
291         return NT_STATUS_OK;
292 }
293
294 /*
295   queue a cldap request for send
296 */
297 struct cldap_request *cldap_search_send(struct cldap_socket *cldap, 
298                                         struct cldap_search *io)
299 {
300         struct ldap_message *msg;
301         struct cldap_request *req;
302         struct ldap_SearchRequest *search;
303
304         req = talloc_zero(cldap, struct cldap_request);
305         if (req == NULL) goto failed;
306
307         req->cldap       = cldap;
308         req->state       = CLDAP_REQUEST_SEND;
309         req->timeout     = io->in.timeout;
310         req->num_retries = io->in.retries;
311         req->is_reply    = False;
312         req->asn1        = asn1_init(req);
313         if (!req->asn1) {
314                 goto failed;
315         }
316
317         req->dest = socket_address_from_strings(req, cldap->sock->backend_name,
318                                                 io->in.dest_address, lp_cldap_port());
319         if (!req->dest) goto failed;
320
321         req->message_id = idr_get_new_random(cldap->idr, req, UINT16_MAX);
322         if (req->message_id == -1) goto failed;
323
324         talloc_set_destructor(req, cldap_request_destructor);
325
326         msg = talloc(req, struct ldap_message);
327         if (msg == NULL) goto failed;
328         msg->messageid       = req->message_id;
329         msg->type            = LDAP_TAG_SearchRequest;
330         msg->controls        = NULL;
331         search = &msg->r.SearchRequest;
332
333         search->basedn         = "";
334         search->scope          = LDAP_SEARCH_SCOPE_BASE;
335         search->deref          = LDAP_DEREFERENCE_NEVER;
336         search->timelimit      = 0;
337         search->sizelimit      = 0;
338         search->attributesonly = False;
339         search->num_attributes = str_list_length(io->in.attributes);
340         search->attributes     = io->in.attributes;
341         search->tree           = ldb_parse_tree(req, io->in.filter);
342         if (search->tree == NULL) {
343                 goto failed;
344         }
345
346         if (!ldap_encode(msg, &req->encoded, req)) {
347                 DEBUG(0,("Failed to encode cldap message to %s:%d\n",
348                          req->dest->addr, req->dest->port));
349                 goto failed;
350         }
351
352         DLIST_ADD_END(cldap->send_queue, req, struct cldap_request *);
353
354         EVENT_FD_WRITEABLE(cldap->fde);
355
356         return req;
357
358 failed:
359         talloc_free(req);
360         return NULL;
361 }
362
363
364 /*
365   queue a cldap reply for send
366 */
367 NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
368 {
369         struct ldap_message *msg;
370         struct cldap_request *req;
371         DATA_BLOB blob1, blob2;
372         NTSTATUS status = NT_STATUS_NO_MEMORY;
373
374         req = talloc_zero(cldap, struct cldap_request);
375         if (req == NULL) goto failed;
376
377         req->cldap       = cldap;
378         req->state       = CLDAP_REQUEST_SEND;
379         req->is_reply    = True;
380         req->asn1        = asn1_init(req);
381         if (!req->asn1) {
382                 goto failed;
383         }
384
385         req->dest        = io->dest;
386         if (talloc_reference(req, io->dest) == NULL) goto failed;
387
388         talloc_set_destructor(req, cldap_request_destructor);
389
390         msg = talloc(req, struct ldap_message);
391         if (msg == NULL) goto failed;
392         msg->messageid       = io->messageid;
393         msg->controls        = NULL;
394         
395         if (io->response) {
396                 msg->type = LDAP_TAG_SearchResultEntry;
397                 msg->r.SearchResultEntry = *io->response;
398
399                 if (!ldap_encode(msg, &blob1, req)) {
400                         DEBUG(0,("Failed to encode cldap message to %s:%d\n",
401                                  req->dest->addr, req->dest->port));
402                         status = NT_STATUS_INVALID_PARAMETER;
403                         goto failed;
404                 }
405         } else {
406                 blob1 = data_blob(NULL, 0);
407         }
408
409         msg->type = LDAP_TAG_SearchResultDone;
410         msg->r.SearchResultDone = *io->result;
411
412         if (!ldap_encode(msg, &blob2, req)) {
413                 DEBUG(0,("Failed to encode cldap message to %s:%d\n",
414                          req->dest->addr, req->dest->port));
415                 status = NT_STATUS_INVALID_PARAMETER;
416                 goto failed;
417         }
418
419         req->encoded = data_blob_talloc(req, NULL, blob1.length + blob2.length);
420         if (req->encoded.data == NULL) goto failed;
421
422         memcpy(req->encoded.data, blob1.data, blob1.length);
423         memcpy(req->encoded.data+blob1.length, blob2.data, blob2.length);
424
425         DLIST_ADD_END(cldap->send_queue, req, struct cldap_request *);
426
427         EVENT_FD_WRITEABLE(cldap->fde);
428
429         return NT_STATUS_OK;
430
431 failed:
432         talloc_free(req);
433         return status;
434 }
435
436 /*
437   receive a cldap reply
438 */
439 NTSTATUS cldap_search_recv(struct cldap_request *req, 
440                            TALLOC_CTX *mem_ctx, 
441                            struct cldap_search *io)
442 {
443         struct ldap_message *ldap_msg;
444         NTSTATUS status;
445
446         if (req == NULL) {
447                 return NT_STATUS_NO_MEMORY;
448         }
449
450         while (req->state < CLDAP_REQUEST_DONE) {
451                 if (event_loop_once(req->cldap->event_ctx) != 0) {
452                         talloc_free(req);
453                         return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
454                 }
455         }
456
457         if (req->state == CLDAP_REQUEST_ERROR) {
458                 status = req->status;
459                 talloc_free(req);
460                 return status;
461         }
462
463         ldap_msg = talloc(mem_ctx, struct ldap_message);
464         NT_STATUS_HAVE_NO_MEMORY(ldap_msg);
465
466         status = ldap_decode(req->asn1, ldap_msg);
467         if (!NT_STATUS_IS_OK(status)) {
468                 DEBUG(2,("Failed to decode cldap search reply: %s\n", nt_errstr(status)));
469                 talloc_free(req);
470                 return status;
471         }
472
473         ZERO_STRUCT(io->out);
474
475         /* the first possible form has a search result in first place */
476         if (ldap_msg->type == LDAP_TAG_SearchResultEntry) {
477                 io->out.response = talloc(mem_ctx, struct ldap_SearchResEntry);
478                 NT_STATUS_HAVE_NO_MEMORY(io->out.response);
479                 *io->out.response = ldap_msg->r.SearchResultEntry;
480
481                 /* decode the 2nd part */
482                 status = ldap_decode(req->asn1, ldap_msg);
483                 if (!NT_STATUS_IS_OK(status)) {
484                         DEBUG(2,("Failed to decode cldap search result entry: %s\n", nt_errstr(status)));
485                         talloc_free(req);
486                         return status;
487                 }
488         }
489
490         if (ldap_msg->type != LDAP_TAG_SearchResultDone) {
491                 talloc_free(req);
492                 return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
493         }
494
495         io->out.result = talloc(mem_ctx, struct ldap_Result);
496         NT_STATUS_HAVE_NO_MEMORY(io->out.result);
497         *io->out.result = ldap_msg->r.SearchResultDone;
498
499         talloc_free(req);
500
501         if (io->out.result->resultcode != LDAP_SUCCESS) {
502                 return NT_STATUS_LDAP(io->out.result->resultcode);
503         }
504         return NT_STATUS_OK;
505 }
506
507
508 /*
509   synchronous cldap search
510 */
511 NTSTATUS cldap_search(struct cldap_socket *cldap, 
512                       TALLOC_CTX *mem_ctx, 
513                       struct cldap_search *io)
514 {
515         struct cldap_request *req = cldap_search_send(cldap, io);
516         return cldap_search_recv(req, mem_ctx, io);
517 }
518
519
520
521 /*
522   queue a cldap netlogon for send
523 */
524 struct cldap_request *cldap_netlogon_send(struct cldap_socket *cldap, 
525                                           struct cldap_netlogon *io)
526 {
527         struct cldap_search search;
528         char *filter;
529         struct cldap_request *req;
530         const char *attr[] = { "NetLogon", NULL };
531         TALLOC_CTX *tmp_ctx = talloc_new(cldap);
532
533         filter = talloc_asprintf(tmp_ctx, "(&(NtVer=%s)", 
534                                  ldap_encode_ndr_uint32(tmp_ctx, io->in.version));
535         if (filter == NULL) goto failed;
536         if (io->in.user) {
537                 filter = talloc_asprintf_append(filter, "(User=%s)", io->in.user);
538                 if (filter == NULL) goto failed;
539         }
540         if (io->in.host) {
541                 filter = talloc_asprintf_append(filter, "(Host=%s)", io->in.host);
542                 if (filter == NULL) goto failed;
543         }
544         if (io->in.realm) {
545                 filter = talloc_asprintf_append(filter, "(DnsDomain=%s)", io->in.realm);
546                 if (filter == NULL) goto failed;
547         }
548         if (io->in.acct_control != -1) {
549                 filter = talloc_asprintf_append(filter, "(AAC=%s)", 
550                                                 ldap_encode_ndr_uint32(tmp_ctx, io->in.acct_control));
551                 if (filter == NULL) goto failed;
552         }
553         if (io->in.domain_sid) {
554                 struct dom_sid *sid = dom_sid_parse_talloc(tmp_ctx, io->in.domain_sid);
555                 if (sid == NULL) goto failed;
556                 filter = talloc_asprintf_append(filter, "(domainSid=%s)",
557                                                 ldap_encode_ndr_dom_sid(tmp_ctx, sid));
558                 if (filter == NULL) goto failed;
559         }
560         if (io->in.domain_guid) {
561                 struct GUID guid;
562                 NTSTATUS status;
563                 status = GUID_from_string(io->in.domain_guid, &guid);
564                 if (!NT_STATUS_IS_OK(status)) goto failed;
565                 filter = talloc_asprintf_append(filter, "(DomainGuid=%s)",
566                                                 ldap_encode_ndr_GUID(tmp_ctx, &guid));
567                 if (filter == NULL) goto failed;
568         }
569         filter = talloc_asprintf_append(filter, ")");
570         if (filter == NULL) goto failed;
571
572         search.in.dest_address = io->in.dest_address;
573         search.in.filter       = filter;
574         search.in.attributes   = attr;
575         search.in.timeout      = 2;
576         search.in.retries      = 2;
577
578         req = cldap_search_send(cldap, &search);
579
580         talloc_free(tmp_ctx);
581         return req;
582 failed:
583         talloc_free(tmp_ctx);
584         return NULL;
585 }
586
587
588 /*
589   receive a cldap netlogon reply
590 */
591 NTSTATUS cldap_netlogon_recv(struct cldap_request *req, 
592                              TALLOC_CTX *mem_ctx, 
593                              struct cldap_netlogon *io)
594 {
595         NTSTATUS status;
596         struct cldap_search search;
597         DATA_BLOB *data;
598
599         status = cldap_search_recv(req, mem_ctx, &search);
600         if (!NT_STATUS_IS_OK(status)) {
601                 return status;
602         }
603         if (search.out.response == NULL) {
604                 return NT_STATUS_NOT_FOUND;
605         }
606
607         if (search.out.response->num_attributes != 1 ||
608             strcasecmp(search.out.response->attributes[0].name, "netlogon") != 0 ||
609             search.out.response->attributes[0].num_values != 1 ||
610             search.out.response->attributes[0].values->length < 2) {
611                 return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
612         }
613         data = search.out.response->attributes[0].values;
614
615         status = ndr_pull_union_blob(data, mem_ctx, &io->out.netlogon, 
616                                      io->in.version & 0xF,
617                                      (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
618         if (!NT_STATUS_IS_OK(status)) {
619                 DEBUG(2,("cldap failed to parse netlogon response of type 0x%02x\n",
620                          SVAL(data->data, 0)));
621                 dump_data(10, data->data, data->length);
622         }
623
624         return status;
625 }
626
627 /*
628   sync cldap netlogon search
629 */
630 NTSTATUS cldap_netlogon(struct cldap_socket *cldap, 
631                         TALLOC_CTX *mem_ctx, struct cldap_netlogon *io)
632 {
633         struct cldap_request *req = cldap_netlogon_send(cldap, io);
634         return cldap_netlogon_recv(req, mem_ctx, io);
635 }
636
637
638 /*
639   send an empty reply (used on any error, so the client doesn't keep waiting
640   or send the bad request again)
641 */
642 NTSTATUS cldap_empty_reply(struct cldap_socket *cldap, 
643                            uint32_t message_id,
644                            struct socket_address *src)
645 {
646         NTSTATUS status;
647         struct cldap_reply reply;
648         struct ldap_Result result;
649
650         reply.messageid    = message_id;
651         reply.dest         = src;
652         reply.response     = NULL;
653         reply.result       = &result;
654
655         ZERO_STRUCT(result);
656
657         status = cldap_reply_send(cldap, &reply);
658
659         return status;
660 }
661
662 /*
663   send an error reply (used on any error, so the client doesn't keep waiting
664   or send the bad request again)
665 */
666 NTSTATUS cldap_error_reply(struct cldap_socket *cldap, 
667                            uint32_t message_id,
668                            struct socket_address *src,
669                            int resultcode,
670                            const char *errormessage)
671 {
672         NTSTATUS status;
673         struct cldap_reply reply;
674         struct ldap_Result result;
675
676         reply.messageid    = message_id;
677         reply.dest         = src;
678         reply.response     = NULL;
679         reply.result       = &result;
680
681         ZERO_STRUCT(result);
682         result.resultcode       = resultcode;
683         result.errormessage     = errormessage;
684
685         status = cldap_reply_send(cldap, &reply);
686
687         return status;
688 }
689
690
691 /*
692   send a netlogon reply 
693 */
694 NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap, 
695                               uint32_t message_id,
696                               struct socket_address *src,
697                               uint32_t version,
698                               union nbt_cldap_netlogon *netlogon)
699 {
700         NTSTATUS status;
701         struct cldap_reply reply;
702         struct ldap_SearchResEntry response;
703         struct ldap_Result result;
704         TALLOC_CTX *tmp_ctx = talloc_new(cldap);
705         DATA_BLOB blob;
706
707         status = ndr_push_union_blob(&blob, tmp_ctx, netlogon, version & 0xF, 
708                                      (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon);
709         if (!NT_STATUS_IS_OK(status)) {
710                 talloc_free(tmp_ctx);
711                 return status;
712         }
713
714         reply.messageid    = message_id;
715         reply.dest         = src;
716         reply.response     = &response;
717         reply.result       = &result;
718
719         ZERO_STRUCT(result);
720
721         response.dn = "";
722         response.num_attributes = 1;
723         response.attributes = talloc(tmp_ctx, struct ldb_message_element);
724         NT_STATUS_HAVE_NO_MEMORY(response.attributes);
725         response.attributes->name = "netlogon";
726         response.attributes->num_values = 1;
727         response.attributes->values = &blob;
728
729         status = cldap_reply_send(cldap, &reply);
730
731         talloc_free(tmp_ctx);
732
733         return status;
734 }
735
736