r9700: Change DATA_BLOB in ejs back to struct datablob
authorJelmer Vernooij <jelmer@samba.org>
Sun, 28 Aug 2005 01:37:27 +0000 (01:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:49 +0000 (13:34 -0500)
Support writing idmap mappings to winbind.ldif
(This used to be commit 3709def35303f1afed0f344628fe2c89250ee087)

source4/lib/samba3/idmap.c
source4/lib/samba3/samba3.c
source4/lib/samba3/upgrade.c
source4/scripting/ejs/mprutil.c

index ce3d098d3a59d6e419a15fe4dff4915b94184f20..ad0ef72ef2e81a0c1f6b36cf0b62f8f33f7e47e3 100644 (file)
@@ -46,7 +46,7 @@ NTSTATUS samba3_read_idmap( const char *fn, TALLOC_CTX *ctx, struct samba3_idmap
 
        /* Open idmap repository */
        if (!(tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0644))) {
 
        /* Open idmap repository */
        if (!(tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0644))) {
-               DEBUG(0, ("idmap_init: Unable to open idmap database\n"));
+               DEBUG(0, ("idmap_init: Unable to open idmap database '%s'\n", fn));
                return NT_STATUS_UNSUCCESSFUL;
        }
 
                return NT_STATUS_UNSUCCESSFUL;
        }
 
index f8ee24ee3b559e64425b77935acae6d627ac47d4..08debe96b193a5d42fb5d44a8722e50a6ac755a8 100644 (file)
@@ -107,7 +107,7 @@ NTSTATUS samba3_read(const char *smbconf, const char *libdir, TALLOC_CTX *ctx, s
        samba3_read_grouptdb(dbfile, ctx, &ret->group);
        SAFE_FREE(dbfile);
 
        samba3_read_grouptdb(dbfile, ctx, &ret->group);
        SAFE_FREE(dbfile);
 
-       asprintf(&dbfile, "%s/idmap.tdb", libdir);
+       asprintf(&dbfile, "%s/winbindd_idmap.tdb", libdir);
        samba3_read_idmap(dbfile, ctx, &ret->idmap);
        SAFE_FREE(dbfile);
 
        samba3_read_idmap(dbfile, ctx, &ret->idmap);
        SAFE_FREE(dbfile);
 
index 941b0fe1961010d431bc822b659d6673755d681c..eeb77310ecbdbe953e82522fbd780a3939a33430 100644 (file)
@@ -109,16 +109,48 @@ int samba3_upgrade_registry(struct samba3_regdb *regdb, const char *prefix, stru
        return count;
 }
 
        return count;
 }
 
-int samba3_upgrade_sam(struct samba3 *samba3, struct ldb_context *ctx, struct ldb_message ***msgs)
+int samba3_upgrade_sam(struct samba3 *samba3, struct ldb_context *ldb, struct ldb_message ***msgs)
 {
 {
+       int count = 0;
+       struct ldb_message *msg;
+       struct ldb_dn *domaindn = NULL;
+       *msgs = NULL;
+
+       /* Domain */    
+       msg = msg_array_add(ldb, msgs, &count);
+
+       /* FIXME: Guess domain DN by taking ldap bind dn? */
+
        /* FIXME */
        return -1;
 }
 
        /* FIXME */
        return -1;
 }
 
-int samba3_upgrade_winbind(struct samba3 *samba3, struct ldb_context *ctx, struct ldb_message ***msgs)
+int samba3_upgrade_winbind(struct samba3 *samba3, struct ldb_context *ldb, struct ldb_message ***msgs)
 {
 {
-       /* FIXME */
-       return -1;
+       int i;
+       int count = 0;
+       struct ldb_message *msg;
+       struct ldb_dn *basedn = NULL;
+       *msgs = NULL;
+
+       msg = msg_array_add(ldb, msgs, &count);
+
+       msg->dn = basedn; 
+       
+       ldb_msg_add_fmt(ldb, msg, "userHwm", "%d", samba3->idmap.user_hwm);
+       ldb_msg_add_fmt(ldb, msg, "groupHwm", "%d", samba3->idmap.group_hwm);
+
+       for (i = 0; i < samba3->idmap.mapping_count; i++) {
+               char *sid = dom_sid_string(msg, samba3->idmap.mappings[i].sid);
+               msg = msg_array_add(ldb, msgs, &count);
+               
+               msg->dn = ldb_dn_build_child(ldb, "SID", sid, basedn);
+               ldb_msg_add_string(ldb, msg, "SID", sid);
+               ldb_msg_add_fmt(ldb, msg, "type", "%d", samba3->idmap.mappings[i].type);
+               ldb_msg_add_fmt(ldb, msg, "unixID", "%u", samba3->idmap.mappings[i].unix_id);
+       }
+       
+       return count;
 }
 
 int samba3_upgrade_winsdb(struct samba3 *samba3, struct ldb_context *ldb, struct ldb_message ***msgs)
 }
 
 int samba3_upgrade_winsdb(struct samba3 *samba3, struct ldb_context *ldb, struct ldb_message ***msgs)
index 0e23738b3032b8471d1a7f82195bcb673099e26b..9634c9bf4236ada7d6da304778548f71efafebd8 100644 (file)
@@ -323,7 +323,7 @@ struct MprVar mprNTSTATUS(NTSTATUS status)
 struct MprVar mprDataBlob(DATA_BLOB blob)
 {
        struct MprVar res;
 struct MprVar mprDataBlob(DATA_BLOB blob)
 {
        struct MprVar res;
-       DATA_BLOB *pblob = talloc(mprMemCtx(), DATA_BLOB);
+       struct datablob *pblob = talloc(mprMemCtx(), struct datablob);
        *pblob = data_blob_talloc(pblob, blob.data, blob.length);
 
        res = mprObject("DATA_BLOB");
        *pblob = data_blob_talloc(pblob, blob.data, blob.length);
 
        res = mprObject("DATA_BLOB");
@@ -337,9 +337,9 @@ struct MprVar mprDataBlob(DATA_BLOB blob)
 /*
   return a data blob from a mpr var created using mprDataBlob
 */
 /*
   return a data blob from a mpr var created using mprDataBlob
 */
-struct data_blob *mprToDataBlob(struct MprVar *v)
+struct datablob *mprToDataBlob(struct MprVar *v)
 {
 {
-       return talloc_get_type(mprGetPtr(v, "blob"), struct data_blob);
+       return talloc_get_type(mprGetPtr(v, "blob"), struct datablob);
 }
 
 /*
 }
 
 /*