r12070: make sure a unique record with multiple addresses becauses mhomed
[ira/wip.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", (long long)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], 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, TALLOC_CTX *mem_ctx, struct winsdb_record **_rec)
420 {
421         NTSTATUS status;
422         struct winsdb_record *rec;
423         struct ldb_message_element *el;
424         struct nbt_name *name;
425         uint32_t i, num_values;
426
427         rec = talloc(mem_ctx, struct winsdb_record);
428         if (rec == NULL) {
429                 status = NT_STATUS_NO_MEMORY;
430                 goto failed;
431         }
432
433         status = winsdb_nbt_name(rec, msg->dn, &name);
434         if (!NT_STATUS_IS_OK(status)) goto failed;
435
436         if (strlen(name->name) > 15) {
437                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
438                 goto failed;
439         }
440         if (name->scope && strlen(name->scope) > 238) {
441                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
442                 goto failed;
443         }
444
445         /* parse it into a more convenient winsdb_record structure */
446         rec->name               = name;
447         rec->type               = ldb_msg_find_int(msg, "recordType", WREPL_TYPE_UNIQUE);
448         rec->state              = ldb_msg_find_int(msg, "recordState", WREPL_STATE_RELEASED);
449         rec->node               = ldb_msg_find_int(msg, "nodeType", WREPL_NODE_B);
450         rec->is_static          = ldb_msg_find_int(msg, "isStatic", 0);
451         rec->expire_time        = ldb_string_to_time(ldb_msg_find_string(msg, "expireTime", NULL));
452         rec->version            = ldb_msg_find_uint64(msg, "versionID", 0);
453         rec->wins_owner         = ldb_msg_find_string(msg, "winsOwner", NULL);
454         rec->registered_by      = ldb_msg_find_string(msg, "registeredBy", NULL);
455         talloc_steal(rec, rec->wins_owner);
456         talloc_steal(rec, rec->registered_by);
457
458         if (!rec->wins_owner) {
459                 rec->wins_owner = talloc_strdup(rec, WINSDB_OWNER_LOCAL);
460                 if (rec->wins_owner == NULL) {
461                         status = NT_STATUS_NO_MEMORY;
462                         goto failed;
463                 }
464         }
465
466         el = ldb_msg_find_element(msg, "address");
467         if (el) {
468                 num_values = el->num_values;
469         } else {
470                 num_values = 0;
471         }
472
473         if (rec->type == WREPL_TYPE_UNIQUE || rec->type == WREPL_TYPE_GROUP) {
474                 if (num_values != 1) {
475                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
476                         goto failed;
477                 }
478         }
479         if (rec->state == WREPL_STATE_ACTIVE) {
480                 if (num_values < 1) {
481                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
482                         goto failed;
483                 }
484         }
485
486         rec->addresses     = talloc_array(rec, struct winsdb_addr *, num_values+1);
487         if (rec->addresses == NULL) {
488                 status = NT_STATUS_NO_MEMORY;
489                 goto failed;
490         }
491
492         for (i=0;i<num_values;i++) {
493                 status = winsdb_addr_decode(rec, &el->values[i], rec->addresses, &rec->addresses[i]);
494                 if (!NT_STATUS_IS_OK(status)) goto failed;
495         }
496         rec->addresses[i] = NULL;
497
498         *_rec = rec;
499         return NT_STATUS_OK;
500 failed:
501         if (NT_STATUS_EQUAL(NT_STATUS_INTERNAL_DB_CORRUPTION, status)) {
502                 DEBUG(1,("winsdb_record: corrupted record: %s\n", ldb_dn_linearize(rec, msg->dn)));
503         }
504         talloc_free(rec);
505         return status;
506 }
507
508 /*
509   form a ldb_message from a winsdb_record
510 */
511 struct ldb_message *winsdb_message(struct ldb_context *ldb, 
512                                    struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
513 {
514         int i, ret=0;
515         size_t addr_count;
516         struct ldb_message *msg = ldb_msg_new(mem_ctx);
517         if (msg == NULL) goto failed;
518
519         /* make sure we don't put in corrupted records */
520         addr_count = winsdb_addr_list_length(rec->addresses);
521         if (rec->state == WREPL_STATE_ACTIVE && addr_count == 0) {
522                 rec->state = WREPL_STATE_RELEASED;
523         }
524         if (rec->type == WREPL_TYPE_UNIQUE && addr_count > 1) {
525                 rec->type = WREPL_TYPE_MHOMED;
526         }
527
528         msg->dn = winsdb_dn(msg, rec->name);
529         if (msg->dn == NULL) goto failed;
530         ret |= ldb_msg_add_fmt(msg, "type", "0x%02X", rec->name->type);
531         if (rec->name->name && *rec->name->name) {
532                 ret |= ldb_msg_add_string(msg, "name", rec->name->name);
533         }
534         if (rec->name->scope && *rec->name->scope) {
535                 ret |= ldb_msg_add_string(msg, "scope", rec->name->scope);
536         }
537         ret |= ldb_msg_add_fmt(msg, "objectClass", "winsRecord");
538         ret |= ldb_msg_add_fmt(msg, "recordType", "%u", rec->type);
539         ret |= ldb_msg_add_fmt(msg, "recordState", "%u", rec->state);
540         ret |= ldb_msg_add_fmt(msg, "nodeType", "%u", rec->node);
541         ret |= ldb_msg_add_fmt(msg, "isStatic", "%u", rec->is_static);
542         ret |= ldb_msg_add_string(msg, "expireTime", 
543                                   ldb_timestring(msg, rec->expire_time));
544         ret |= ldb_msg_add_fmt(msg, "versionID", "%llu", (long long)rec->version);
545         ret |= ldb_msg_add_string(msg, "winsOwner", rec->wins_owner);
546         ret |= ldb_msg_add_empty(msg, "address", 0);
547         for (i=0;rec->addresses[i];i++) {
548                 ret |= ldb_msg_add_winsdb_addr(msg, "address", rec->addresses[i]);
549         }
550         ret |= ldb_msg_add_empty(msg, "registeredBy", 0);
551         if (rec->registered_by) {
552                 ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by);
553                 if (ret != 0) goto failed;
554         }
555         return msg;
556
557 failed:
558         talloc_free(msg);
559         return NULL;
560 }
561
562 /*
563   save a WINS record into the database
564 */
565 uint8_t winsdb_add(struct ldb_context *wins_db, struct winsdb_record *rec, uint32_t flags)
566 {
567         struct ldb_message *msg;
568         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
569         int trans = -1;
570         int ret = 0;
571
572         trans = ldb_transaction_start(wins_db);
573         if (trans != LDB_SUCCESS) goto failed;
574
575         if (flags & WINSDB_FLAG_ALLOC_VERSION) {
576                 rec->version = winsdb_allocate_version(wins_db);
577                 if (rec->version == 0) goto failed;
578         }
579         if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) {
580                 rec->wins_owner = WINSDB_OWNER_LOCAL;
581         }
582
583         msg = winsdb_message(wins_db, rec, tmp_ctx);
584         if (msg == NULL) goto failed;
585         ret = ldb_add(wins_db, msg);
586         if (ret != 0) goto failed;
587
588         trans = ldb_transaction_commit(wins_db);
589         if (trans != LDB_SUCCESS) goto failed;
590
591         talloc_free(tmp_ctx);
592         return NBT_RCODE_OK;
593
594 failed:
595         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
596         talloc_free(tmp_ctx);
597         return NBT_RCODE_SVR;
598 }
599
600
601 /*
602   modify a WINS record in the database
603 */
604 uint8_t winsdb_modify(struct ldb_context *wins_db, struct winsdb_record *rec, uint32_t flags)
605 {
606         struct ldb_message *msg;
607         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
608         int trans;
609         int ret;
610         int i;
611
612         trans = ldb_transaction_start(wins_db);
613         if (trans != LDB_SUCCESS) goto failed;
614
615         if (flags & WINSDB_FLAG_ALLOC_VERSION) {
616                 rec->version = winsdb_allocate_version(wins_db);
617                 if (rec->version == 0) goto failed;
618         }
619         if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) {
620                 rec->wins_owner = WINSDB_OWNER_LOCAL;
621         }
622
623         msg = winsdb_message(wins_db, rec, tmp_ctx);
624         if (msg == NULL) goto failed;
625
626         for (i=0;i<msg->num_elements;i++) {
627                 msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
628         }
629
630         ret = ldb_modify(wins_db, msg);
631         if (ret != 0) goto failed;
632
633         trans = ldb_transaction_commit(wins_db);
634         if (trans != LDB_SUCCESS) goto failed;
635
636         talloc_free(tmp_ctx);
637         return NBT_RCODE_OK;
638
639 failed:
640         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
641         talloc_free(tmp_ctx);
642         return NBT_RCODE_SVR;
643 }
644
645
646 /*
647   delete a WINS record from the database
648 */
649 uint8_t winsdb_delete(struct ldb_context *wins_db, struct winsdb_record *rec)
650 {
651         TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
652         const struct ldb_dn *dn;
653         int trans;
654         int ret;
655
656         trans = ldb_transaction_start(wins_db);
657         if (trans != LDB_SUCCESS) goto failed;
658
659         dn = winsdb_dn(tmp_ctx, rec->name);
660         if (dn == NULL) goto failed;
661
662         ret = ldb_delete(wins_db, dn);
663         if (ret != 0) goto failed;
664
665         trans = ldb_transaction_commit(wins_db);
666         if (trans != LDB_SUCCESS) goto failed;
667
668         talloc_free(tmp_ctx);
669         return NBT_RCODE_OK;
670
671 failed:
672         if (trans == LDB_SUCCESS) ldb_transaction_cancel(wins_db);
673         talloc_free(tmp_ctx);
674         return NBT_RCODE_SVR;
675 }
676
677 struct ldb_context *winsdb_connect(TALLOC_CTX *mem_ctx)
678 {
679         return ldb_wrap_connect(mem_ctx, lp_wins_url(), 0, NULL);
680 }