util:ldb Allow multiple entries to be added in one LDIF snippit
authorAndrew Bartlett <abartlet@samba.org>
Thu, 22 Oct 2009 07:20:07 +0000 (18:20 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 23 Oct 2009 04:41:25 +0000 (15:41 +1100)
lib/util/util_ldb.c

index ac1e11566e89fb989fa2ad294ec0d7a5e009c441..e92e3a2dffc98edaee1146ec2fe3b1d8c36315e5 100644 (file)
@@ -116,11 +116,14 @@ int gendb_search_dn(struct ldb_context *ldb,
 int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string)
 {
        struct ldb_ldif *ldif;
+       const char *s = ldif_string;
        int ret;
-       ldif = ldb_ldif_read_string(ldb, &ldif_string);
-       if (ldif == NULL) return -1;
-       ret = ldb_add(ldb, ldif->msg);
-       talloc_free(ldif);
+       while (s && *s != '\0') {
+               ldif = ldb_ldif_read_string(ldb, &s);
+               if (ldif == NULL) return -1;
+               ret = ldb_add(ldb, ldif->msg);
+               talloc_free(ldif);
+       }
        return ret;
 }