s4-samldb: the samldb module requires that the primary group exists
[ira/wip.git] / source4 / dsdb / samdb / ldb_modules / samba3sam.c
index 4b1d4329329e5e835de3e0501293256a5456d48c..f5ddff95ed0e9c8bf29c5929de4b016ff7d807a7 100644 (file)
@@ -6,9 +6,7 @@
 */
 
 #include "includes.h"
-#include "ldb/include/ldb.h"
-#include "ldb/include/ldb_private.h"
-#include "ldb/include/ldb_errors.h"
+#include "ldb_module.h"
 #include "ldb/ldb_map/ldb_map.h"
 #include "system/passwd.h"
 
@@ -26,7 +24,6 @@
  * sambaTrustPassword
  * sambaUnixIdPool
  * sambaIdmapEntry
- * sambaAccountPolicy
  * sambaSidEntry
  * sambaAcctFlags -> systemFlags ?
  * sambaPasswordHistory  -> ntPwdHistory*/
@@ -118,20 +115,23 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char
 static struct ldb_val convert_uid_samaccount(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
 {
        struct ldb_val out = data_blob(NULL, 0);
-       ldb_handler_copy(module->ldb, ctx, val, &out);
+       out = ldb_val_dup(ctx, val);
 
        return out;
 }
 
 static struct ldb_val lookup_homedir(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
 {
+       struct ldb_context *ldb;
        struct passwd *pwd; 
        struct ldb_val retval;
-       
+
+       ldb = ldb_module_get_ctx(module);
+
        pwd = getpwnam((char *)val->data);
 
        if (!pwd) {
-               ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data);
+               ldb_debug(ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data);
                return *talloc_zero(ctx, struct ldb_val);
        }
 
@@ -145,7 +145,7 @@ static struct ldb_val lookup_gid(struct ldb_module *module, TALLOC_CTX *ctx, con
 {
        struct passwd *pwd; 
        struct ldb_val retval;
-       
+
        pwd = getpwnam((char *)val->data);
 
        if (!pwd) {
@@ -848,9 +848,9 @@ const struct ldb_map_attribute samba3_attributes[] =
                .type = MAP_IGNORE,
        },
 
-       /* sambaPassword */
+       /* userPassword */
        {
-               .local_name = "sambaPassword",
+               .local_name = "userPassword",
                .type = MAP_IGNORE,
        },
 
@@ -925,7 +925,7 @@ static int samba3sam_init(struct ldb_module *module)
        return ldb_next_init(module);
 }
 
-const struct ldb_module_ops ldb_samba3sam_module_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_samba3sam_module_ops = {
        LDB_MAP_OPS
        .name              = "samba3sam",
        .init_context      = samba3sam_init,