r11900: - make sure address and registered_by are replaced when they're not present
[samba.git] / source4 / nbt_server / wins / winsdb.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    WINS database routines
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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "nbt_server/nbt_server.h"
25 #include "nbt_server/wins/winsdb.h"
26 #include "lib/ldb/include/ldb.h"
27 #include "lib/ldb/include/ldb_errors.h"
28 #include "db_wrap.h"
29 #include "system/time.h"
30
31 /*
32   return the new maxVersion and save it
33 */
34 static uint64_t winsdb_allocate_version(struct ldb_context *wins_db)
35 {
36         int trans;
37         int ret;
38         struct ldb_dn *dn;
39         struct ldb_result *res = NULL;
40         struct ldb_message *msg = NULL;
41         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
42         uint64_t maxVersion = 0;
43
44         trans = ldb_transaction_start(wins_db);
45         if (trans != LDB_SUCCESS) goto failed;
46
47         dn = ldb_dn_explode(tmp_ctx, "CN=VERSION");
48         if (!dn) goto failed;
49
50         /* find the record in the WINS database */
51         ret = ldb_search(wins_db, dn, LDB_SCOPE_BASE, NULL, NULL, &res);
52
53         if (ret != LDB_SUCCESS) goto failed;
54         if (res->count > 1) goto failed;
55
56         talloc_steal(tmp_ctx, res);
57
58         if (res->count == 1) {
59                 maxVersion = ldb_msg_find_uint64(res->msgs[0], "maxVersion", 0);
60         }
61         maxVersion++;
62
63         msg = ldb_msg_new(tmp_ctx);
64         if (!msg) goto failed;
65         msg->dn = dn;
66
67
68         ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE);
69         if (ret != 0) goto failed;
70         ret = ldb_msg_add_string(msg, "objectClass", "winsMaxVersion");
71         if (ret != 0) goto failed;
72         ret = ldb_msg_add_empty(msg, "maxVersion", LDB_FLAG_MOD_REPLACE);
73         if (ret != 0) goto failed;
74         ret = ldb_msg_add_fmt(msg, "maxVersion", "%llu", maxVersion);
75         if (ret != 0) goto failed;
76
77         ret = ldb_modify(wins_db, msg);
78         if (ret != 0) ret = ldb_add(wins_db, msg);
79         if (ret != 0) goto failed;
80
81         trans = ldb_transaction_commit(wins_db);
82         if (trans != LDB_SUCCESS) goto failed;
83
84         talloc_free(tmp_ctx);
85         return maxVersion;
86
87 failed:
88         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
89         talloc_free(tmp_ctx);
90         return 0;
91 }
92
93 /*
94   return a DN for a nbt_name
95 */
96 static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct nbt_name *name)
97 {
98         struct ldb_dn *dn;
99
100         dn = ldb_dn_string_compose(mem_ctx, NULL, "type=0x%02X", name->type);
101         if (dn && name->name && *name->name) {
102                 dn = ldb_dn_string_compose(mem_ctx, dn, "name=%s", name->name);
103         }
104         if (dn && name->scope && *name->scope) {
105                 dn = ldb_dn_string_compose(mem_ctx, dn, "scope=%s", name->scope);
106         }
107         return dn;
108 }
109
110 static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct nbt_name **_name)
111 {
112         NTSTATUS status;
113         struct nbt_name *name;
114         uint32_t cur = 0;
115
116         name = talloc(mem_ctx, struct nbt_name);
117         if (!name) {
118                 status = NT_STATUS_NO_MEMORY;
119                 goto failed;
120         }
121
122         if (dn->comp_num > 3) {
123                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
124                 goto failed;
125         }
126
127         if (dn->comp_num > cur && strcasecmp("scope", dn->components[cur].name) == 0) {
128                 name->scope     = talloc_steal(name, dn->components[cur].value.data);
129                 cur++;
130         } else {
131                 name->scope     = NULL;
132         }
133
134         if (dn->comp_num > cur && strcasecmp("name", dn->components[cur].name) == 0) {
135                 name->name      = talloc_steal(name, dn->components[cur].value.data);
136                 cur++;
137         } else {
138                 name->name      = talloc_strdup(name, "");
139                 if (!name->name) {
140                         status = NT_STATUS_NO_MEMORY;
141                         goto failed;
142                 }
143         }
144
145         if (dn->comp_num > cur && strcasecmp("type", dn->components[cur].name) == 0) {
146                 name->type      = strtoul((char *)dn->components[cur].value.data, NULL, 0);
147                 cur++;
148         } else {
149                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
150                 goto failed;
151         }
152
153         *_name = name;
154         return NT_STATUS_OK;
155 failed:
156         talloc_free(name);
157         return status;
158 }
159
160 /*
161  decode the winsdb_addr("address") attribute:
162  "172.31.1.1" or 
163  "172.31.1.1;winsOwner:172.31.9.202;expireTime:20050923032330.0Z;"
164  are valid records
165 */
166 static NTSTATUS winsdb_addr_decode(struct winsdb_record *rec, struct ldb_val *val,
167                                    TALLOC_CTX *mem_ctx, struct winsdb_addr **_addr)
168 {
169         NTSTATUS status;
170         struct winsdb_addr *addr;
171         char *address;
172         char *wins_owner;
173         char *expire_time;
174         char *p;
175
176         addr = talloc(mem_ctx, struct winsdb_addr);
177         if (!addr) {
178                 status = NT_STATUS_NO_MEMORY;
179                 goto failed;
180         }
181
182         address = (char *)val->data;
183
184         p = strchr(address, ';');
185         if (!p) {
186                 /* support old entries, with only the address */
187                 addr->address           = talloc_steal(addr, val->data);
188                 addr->wins_owner        = talloc_reference(addr, rec->wins_owner);
189                 if (!addr->wins_owner) {
190                         status = NT_STATUS_NO_MEMORY;
191                         goto failed;
192                 }
193                 addr->expire_time       = rec->expire_time;
194                 *_addr = addr;
195                 return NT_STATUS_OK;
196         }
197
198         *p = '\0';p++;
199         addr->address = talloc_strdup(addr, address);
200         if (!addr->address) {
201                 status = NT_STATUS_NO_MEMORY;
202                 goto failed;
203         }
204
205         if (strncmp("winsOwner:", p, 10) != 0) {
206                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
207                 goto failed;
208         }
209         wins_owner = p + 10;
210         p = strchr(wins_owner, ';');
211         if (!p) {
212                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
213                 goto failed;
214         }
215
216         *p = '\0';p++;
217         addr->wins_owner = talloc_strdup(addr, wins_owner);
218         if (!addr->wins_owner) {
219                 status = NT_STATUS_NO_MEMORY;
220                 goto failed;
221         }
222
223         if (strncmp("expireTime:", p, 11) != 0) {
224                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
225                 goto failed;
226         }
227
228         expire_time = p + 11;
229         p = strchr(expire_time, ';');
230         if (!p) {
231                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
232                 goto failed;
233         }
234
235         *p = '\0';p++;
236         addr->expire_time = ldb_string_to_time(expire_time);
237
238         *_addr = addr;
239         return NT_STATUS_OK;
240 failed:
241         talloc_free(addr);
242         return status;
243 }
244
245 /*
246  encode the winsdb_addr("address") attribute like this:
247  "172.31.1.1;winsOwner:172.31.9.202;expireTime:20050923032330.0Z;"
248 */
249 static int ldb_msg_add_winsdb_addr(struct ldb_message *msg, 
250                                    const char *attr_name, struct winsdb_addr *addr)
251 {
252         struct ldb_val val;
253         const char *str;
254
255         str = talloc_asprintf(msg, "%s;winsOwner:%s;expireTime:%s;",
256                               addr->address, addr->wins_owner,
257                               ldb_timestring(msg, addr->expire_time));
258         if (!str) return -1;
259
260         val.data = discard_const_p(uint8_t, str);
261         val.length = strlen(str);
262
263         return ldb_msg_add_value(msg, attr_name, &val);
264 }
265
266 struct winsdb_addr **winsdb_addr_list_make(TALLOC_CTX *mem_ctx)
267 {
268         struct winsdb_addr **addresses;
269
270         addresses = talloc_array(mem_ctx, struct winsdb_addr *, 1);
271         if (!addresses) return NULL;
272
273         addresses[0] = NULL;
274
275         return addresses;
276 }
277
278 struct winsdb_addr **winsdb_addr_list_add(struct winsdb_addr **addresses, const char *address,
279                                           const char *wins_owner, time_t expire_time)
280 {
281         size_t len = winsdb_addr_list_length(addresses);
282
283         addresses = talloc_realloc(addresses, addresses, struct winsdb_addr *, len + 2);
284         if (!addresses) return NULL;
285
286         addresses[len] = talloc(addresses, struct winsdb_addr);
287         if (!addresses[len]) {
288                 talloc_free(addresses);
289                 return NULL;
290         }
291
292         addresses[len]->address = talloc_strdup(addresses[len], address);
293         if (!addresses[len]->address) {
294                 talloc_free(addresses);
295                 return NULL;
296         }
297
298         addresses[len]->wins_owner = talloc_strdup(addresses[len], wins_owner);
299         if (!addresses[len]->wins_owner) {
300                 talloc_free(addresses);
301                 return NULL;
302         }
303
304         addresses[len]->expire_time = expire_time;
305
306         addresses[len+1] = NULL;
307
308         return addresses;
309 }
310
311 void winsdb_addr_list_remove(struct winsdb_addr **addresses, const char *address)
312 {
313         size_t i;
314
315         for (i=0; addresses[i]; i++) {
316                 if (strcmp(addresses[i]->address, address) == 0) {
317                         break;
318                 }
319         }
320         if (!addresses[i]) return;
321
322         for (; addresses[i]; i++) {
323                 addresses[i] = addresses[i+1];
324         }
325
326         return;
327 }
328
329 struct winsdb_addr *winsdb_addr_list_check(struct winsdb_addr **addresses, const char *address)
330 {
331         size_t i;
332
333         for (i=0; addresses[i]; i++) {
334                 if (strcmp(addresses[i]->address, address) == 0) {
335                         return addresses[i];
336                 }
337         }
338
339         return NULL;
340 }
341
342 size_t winsdb_addr_list_length(struct winsdb_addr **addresses)
343 {
344         size_t i;
345         for (i=0; addresses[i]; i++);
346         return i;
347 }
348
349 const char **winsdb_addr_string_list(TALLOC_CTX *mem_ctx, struct winsdb_addr **addresses)
350 {
351         size_t len = winsdb_addr_list_length(addresses);
352         const char **str_list;
353         size_t i;
354
355         str_list = talloc_array(mem_ctx, const char *, len + 1);
356         if (!str_list) return NULL;
357
358         for (i=0; i < len; i++) {
359                 str_list[i] = talloc_strdup(str_list, addresses[i]->address);
360                 if (!str_list[i]) {
361                         talloc_free(str_list);
362                         return NULL;
363                 }
364         }
365
366         str_list[len] = NULL;
367         return str_list;
368 }
369
370 /*
371   load a WINS entry from the database
372 */
373 NTSTATUS winsdb_lookup(struct ldb_context *wins_db, 
374                        struct nbt_name *name,
375                        TALLOC_CTX *mem_ctx,
376                        struct winsdb_record **_rec)
377 {
378         NTSTATUS status;
379         struct ldb_result *res = NULL;
380         int ret;
381         struct winsdb_record *rec;
382         TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
383
384         /* find the record in the WINS database */
385         ret = ldb_search(wins_db, winsdb_dn(tmp_ctx, name), LDB_SCOPE_BASE, 
386                          NULL, NULL, &res);
387
388         if (ret != LDB_SUCCESS || res->count > 1) {
389                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
390                 goto failed;
391         } else if (res->count== 0) {
392                 status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
393                 goto failed;
394         }
395
396         talloc_steal(tmp_ctx, res);
397
398         status = winsdb_record(res->msgs[0], name, tmp_ctx, &rec);
399         if (!NT_STATUS_IS_OK(status)) goto failed;
400
401         /* see if it has already expired */
402         if (rec->state == WREPL_STATE_ACTIVE &&
403             rec->expire_time <= time(NULL)) {
404                 DEBUG(5,("WINS: expiring name %s (expired at %s)\n", 
405                          nbt_name_string(tmp_ctx, rec->name), timestring(tmp_ctx, rec->expire_time)));
406                 rec->state = WREPL_STATE_RELEASED;
407         }
408
409         talloc_steal(mem_ctx, rec);
410         talloc_free(tmp_ctx);
411         *_rec = rec;
412         return NT_STATUS_OK;
413
414 failed:
415         talloc_free(tmp_ctx);
416         return status;
417 }
418
419 NTSTATUS winsdb_record(struct ldb_message *msg, struct nbt_name *name, TALLOC_CTX *mem_ctx, struct winsdb_record **_rec)
420 {
421         NTSTATUS status;
422         struct winsdb_record *rec;
423         struct ldb_message_element *el;
424         uint32_t i, num_values;
425
426         rec = talloc(mem_ctx, struct winsdb_record);
427         if (rec == NULL) {
428                 status = NT_STATUS_NO_MEMORY;
429                 goto failed;
430         }
431
432         if (!name) {
433                 status = winsdb_nbt_name(rec, msg->dn, &name);
434                 if (!NT_STATUS_IS_OK(status)) goto failed;
435         }
436
437         if (strlen(name->name) > 15) {
438                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
439                 goto failed;
440         }
441         if (name->scope && strlen(name->scope) > 238) {
442                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
443                 goto failed;
444         }
445
446         /* parse it into a more convenient winsdb_record structure */
447         rec->name               = name;
448         rec->type               = ldb_msg_find_int(msg, "recordType", WREPL_TYPE_UNIQUE);
449         rec->state              = ldb_msg_find_int(msg, "recordState", WREPL_STATE_RELEASED);
450         rec->node               = ldb_msg_find_int(msg, "nodeType", WREPL_NODE_B);
451         rec->is_static          = ldb_msg_find_int(msg, "isStatic", 0);
452         rec->expire_time        = ldb_string_to_time(ldb_msg_find_string(msg, "expireTime", NULL));
453         rec->version            = ldb_msg_find_uint64(msg, "versionID", 0);
454         rec->wins_owner         = ldb_msg_find_string(msg, "winsOwner", NULL);
455         rec->registered_by      = ldb_msg_find_string(msg, "registeredBy", NULL);
456         talloc_steal(rec, rec->wins_owner);
457         talloc_steal(rec, rec->registered_by);
458
459         if (!rec->wins_owner) {
460                 rec->wins_owner = talloc_strdup(rec, WINSDB_OWNER_LOCAL);
461                 if (rec->wins_owner == NULL) {
462                         status = NT_STATUS_NO_MEMORY;
463                         goto failed;
464                 }
465         }
466
467         el = ldb_msg_find_element(msg, "address");
468         if (el) {
469                 num_values = el->num_values;
470         } else {
471                 num_values = 0;
472         }
473
474         if (rec->type == WREPL_TYPE_UNIQUE || rec->type == WREPL_TYPE_GROUP) {
475                 if (num_values != 1) {
476                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
477                         goto failed;
478                 }
479         }
480         if (rec->state == WREPL_STATE_ACTIVE) {
481                 if (num_values < 1) {
482                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
483                         goto failed;
484                 }
485         }
486
487         rec->addresses     = talloc_array(rec, struct winsdb_addr *, num_values+1);
488         if (rec->addresses == NULL) {
489                 status = NT_STATUS_NO_MEMORY;
490                 goto failed;
491         }
492
493         for (i=0;i<num_values;i++) {
494                 status = winsdb_addr_decode(rec, &el->values[i], rec->addresses, &rec->addresses[i]);
495                 if (!NT_STATUS_IS_OK(status)) goto failed;
496         }
497         rec->addresses[i] = NULL;
498
499         *_rec = rec;
500         return NT_STATUS_OK;
501 failed:
502         if (NT_STATUS_EQUAL(NT_STATUS_INTERNAL_DB_CORRUPTION, status)) {
503                 DEBUG(1,("winsdb_record: corrupted record: %s\n", ldb_dn_linearize(rec, msg->dn)));
504         }
505         talloc_free(rec);
506         return status;
507 }
508
509 /*
510   form a ldb_message from a winsdb_record
511 */
512 struct ldb_message *winsdb_message(struct ldb_context *ldb, 
513                                    struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
514 {
515         int i, ret=0;
516         size_t addr_count;
517         struct ldb_message *msg = ldb_msg_new(mem_ctx);
518         if (msg == NULL) goto failed;
519
520         /* make sure we don't put in corrupted records */
521         addr_count = winsdb_addr_list_length(rec->addresses);
522         if (rec->state == WREPL_STATE_ACTIVE && addr_count == 0) {
523                 rec->state = WREPL_STATE_RELEASED;
524         }
525
526         msg->dn = winsdb_dn(msg, rec->name);
527         if (msg->dn == NULL) goto failed;
528         ret |= ldb_msg_add_fmt(msg, "type", "0x%02X", rec->name->type);
529         if (rec->name->name && *rec->name->name) {
530                 ret |= ldb_msg_add_string(msg, "name", rec->name->name);
531         }
532         if (rec->name->scope && *rec->name->scope) {
533                 ret |= ldb_msg_add_string(msg, "scope", rec->name->scope);
534         }
535         ret |= ldb_msg_add_fmt(msg, "objectClass", "winsRecord");
536         ret |= ldb_msg_add_fmt(msg, "recordType", "%u", rec->type);
537         ret |= ldb_msg_add_fmt(msg, "recordState", "%u", rec->state);
538         ret |= ldb_msg_add_fmt(msg, "nodeType", "%u", rec->node);
539         ret |= ldb_msg_add_fmt(msg, "isStatic", "%u", rec->is_static);
540         ret |= ldb_msg_add_string(msg, "expireTime", 
541                                   ldb_timestring(msg, rec->expire_time));
542         ret |= ldb_msg_add_fmt(msg, "versionID", "%llu", rec->version);
543         ret |= ldb_msg_add_string(msg, "winsOwner", rec->wins_owner);
544         ret |= ldb_msg_add_empty(msg, "address", 0);
545         for (i=0;rec->addresses[i];i++) {
546                 ret |= ldb_msg_add_winsdb_addr(msg, "address", rec->addresses[i]);
547         }
548         ret |= ldb_msg_add_empty(msg, "registeredBy", 0);
549         if (rec->registered_by) {
550                 ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by);
551                 if (ret != 0) goto failed;
552         }
553         return msg;
554
555 failed:
556         talloc_free(msg);
557         return NULL;
558 }
559
560 /*
561   save a WINS record into the database
562 */
563 uint8_t winsdb_add(struct ldb_context *wins_db, struct winsdb_record *rec, uint32_t flags)
564 {
565         struct ldb_message *msg;
566         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
567         int trans = -1;
568         int ret = 0;
569
570         trans = ldb_transaction_start(wins_db);
571         if (trans != LDB_SUCCESS) goto failed;
572
573         if (flags & WINSDB_FLAG_ALLOC_VERSION) {
574                 rec->version = winsdb_allocate_version(wins_db);
575                 if (rec->version == 0) goto failed;
576         }
577         if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) {
578                 rec->wins_owner = WINSDB_OWNER_LOCAL;
579         }
580
581         msg = winsdb_message(wins_db, rec, tmp_ctx);
582         if (msg == NULL) goto failed;
583         ret = ldb_add(wins_db, msg);
584         if (ret != 0) goto failed;
585
586         trans = ldb_transaction_commit(wins_db);
587         if (trans != LDB_SUCCESS) goto failed;
588
589         talloc_free(tmp_ctx);
590         return NBT_RCODE_OK;
591
592 failed:
593         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
594         talloc_free(tmp_ctx);
595         return NBT_RCODE_SVR;
596 }
597
598
599 /*
600   modify a WINS record in the database
601 */
602 uint8_t winsdb_modify(struct ldb_context *wins_db, struct winsdb_record *rec, uint32_t flags)
603 {
604         struct ldb_message *msg;
605         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
606         int trans;
607         int ret;
608         int i;
609
610         trans = ldb_transaction_start(wins_db);
611         if (trans != LDB_SUCCESS) goto failed;
612
613         if (flags & WINSDB_FLAG_ALLOC_VERSION) {
614                 rec->version = winsdb_allocate_version(wins_db);
615                 if (rec->version == 0) goto failed;
616         }
617         if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) {
618                 rec->wins_owner = WINSDB_OWNER_LOCAL;
619         }
620
621         msg = winsdb_message(wins_db, rec, tmp_ctx);
622         if (msg == NULL) goto failed;
623
624         for (i=0;i<msg->num_elements;i++) {
625                 msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
626         }
627
628         ret = ldb_modify(wins_db, msg);
629         if (ret != 0) goto failed;
630
631         trans = ldb_transaction_commit(wins_db);
632         if (trans != LDB_SUCCESS) goto failed;
633
634         talloc_free(tmp_ctx);
635         return NBT_RCODE_OK;
636
637 failed:
638         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
639         talloc_free(tmp_ctx);
640         return NBT_RCODE_SVR;
641 }
642
643
644 /*
645   delete a WINS record from the database
646 */
647 uint8_t winsdb_delete(struct ldb_context *wins_db, struct winsdb_record *rec)
648 {
649         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
650         const struct ldb_dn *dn;
651         int trans;
652         int ret;
653
654         trans = ldb_transaction_start(wins_db);
655         if (trans != LDB_SUCCESS) goto failed;
656
657         dn = winsdb_dn(tmp_ctx, rec->name);
658         if (dn == NULL) goto failed;
659
660         ret = ldb_delete(wins_db, dn);
661         if (ret != 0) goto failed;
662
663         trans = ldb_transaction_commit(wins_db);
664         if (trans != LDB_SUCCESS) goto failed;
665
666         talloc_free(tmp_ctx);
667         return NBT_RCODE_OK;
668
669 failed:
670         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
671         talloc_free(tmp_ctx);
672         return NBT_RCODE_SVR;
673 }
674
675 struct ldb_context *winsdb_connect(TALLOC_CTX *mem_ctx)
676 {
677         return ldb_wrap_connect(mem_ctx, lp_wins_url(), 0, NULL);
678 }