r9624: Support writing wins.ldif
authorJelmer Vernooij <jelmer@samba.org>
Thu, 25 Aug 2005 22:57:56 +0000 (22:57 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:35 +0000 (13:34 -0500)
(This used to be commit b0595d238bbcc4a3927914d1fd6032e9293da5cc)

source4/lib/samba3/upgrade.c

index 907df75..941b0fe 100644 (file)
@@ -121,8 +121,29 @@ int samba3_upgrade_winbind(struct samba3 *samba3, struct ldb_context *ctx, struc
        return -1;
 }
 
-int samba3_upgrade_winsdb(struct samba3 *samba3, struct ldb_context *ctx, struct ldb_message ***msgs)
+int samba3_upgrade_winsdb(struct samba3 *samba3, struct ldb_context *ldb, struct ldb_message ***msgs)
 {
-       /* FIXME */
-       return -1;
+       int i;
+       int count = 0;
+       
+       for (i = 0; i < samba3->winsdb_count; i++) {
+               struct samba3_winsdb_entry *e = &samba3->winsdb_entries[i];
+               int j;
+               struct ldb_message *msg = msg_array_add(ldb, msgs, &count);
+
+               msg->dn = ldb_dn_string_compose(ldb, NULL, "type=%d,name=%s", e->type, e->name);
+
+               ldb_msg_add_string(ldb, msg, "name", e->name);
+               ldb_msg_add_fmt(ldb, msg, "type", "%d", e->type);
+               ldb_msg_add_string(ldb, msg, "objectClass", "wins");
+               ldb_msg_add_fmt(ldb, msg, "nbFlags", "%x", e->nb_flags);
+               ldb_msg_add_string(ldb, msg, "expires", 
+                                 ldap_timestring(msg, e->ttl));
+
+               for (j = 0; j < e->ip_count; j++) {
+                       ldb_msg_add_string(ldb, msg, "address", sys_inet_ntoa(e->ips[j]));
+               }
+       }
+
+       return count;
 }