s4 - Mapped AD schema to existing FDS schema.
[samba.git] / source4 / dsdb / samdb / ldb_modules / simple_ldap_map.c
index 21b80dccbf3b9d4d60cd0b2c9351cce102788a94..d923e55484a11ca0080e0b317f812b4c81505ab1 100644 (file)
@@ -233,7 +233,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        /* objectGUID */
        {
                .local_name = "objectGUID",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "entryUUID", 
@@ -245,7 +245,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        /* invocationId */
        {
                .local_name = "invocationId",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "invocationId", 
@@ -257,7 +257,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        /* objectSid */
        {
                .local_name = "objectSid",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "objectSid", 
@@ -268,7 +268,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "name",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "samba4RDN"
@@ -277,7 +277,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "whenCreated",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "createTimestamp"
@@ -286,7 +286,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "whenChanged",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "modifyTimestamp"
@@ -295,7 +295,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "objectClasses",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "samba4ObjectClasses"
@@ -304,7 +304,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "dITContentRules",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "samba4DITContentRules"
@@ -313,7 +313,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "attributeTypes",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "samba4AttributeTypes"
@@ -322,7 +322,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "objectCategory",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "objectCategory", 
@@ -333,60 +333,71 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "distinguishedName",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "entryDN"
                         }
                }
        },
+       {
+               .local_name = "primaryGroupID",
+               .type = LDB_MAP_CONVERT,
+               .u = {
+                       .convert = {
+                                .remote_name = "primaryGroupID",
+                                .convert_local = normalise_to_signed32,
+                                .convert_remote = val_copy,
+                       }
+               }
+       },
        {
                .local_name = "groupType",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "groupType",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "userAccountControl",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "userAccountControl",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "sAMAccountType",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "sAMAccountType",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "systemFlags",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "systemFlags",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "usnChanged",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "entryCSN",
@@ -397,7 +408,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "usnCreated",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "createTimestamp",
@@ -408,7 +419,7 @@ static const struct ldb_map_attribute entryuuid_attributes[] =
        },
        {
                .local_name = "*",
-               .type = MAP_KEEP,
+               .type = LDB_MAP_KEEP,
        },
        {
                .local_name = NULL,
@@ -444,30 +455,30 @@ static const struct ldb_map_attribute nsuniqueid_attributes[] =
        /* objectGUID */
        {
                .local_name = "objectGUID",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "nsuniqueid", 
                                .convert_local = guid_ns_string,
                                .convert_remote = encode_ns_guid,
-                       },
-               },
+                       }
+               }
        },
        /* objectSid */ 
        {
                .local_name = "objectSid",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "objectSid", 
                                .convert_local = sid_always_binary,
                                .convert_remote = val_copy,
-                       },
-               },
+                       }
+               }
        },
        {
                .local_name = "whenCreated",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "createTimestamp"
@@ -476,7 +487,7 @@ static const struct ldb_map_attribute nsuniqueid_attributes[] =
        },
        {
                .local_name = "whenChanged",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "modifyTimestamp"
@@ -485,99 +496,267 @@ static const struct ldb_map_attribute nsuniqueid_attributes[] =
        },
        {
                .local_name = "objectCategory",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                .remote_name = "objectCategory", 
                                .convert_local = objectCategory_always_dn,
                                .convert_remote = val_copy,
-                       },
-               },
+                       }
+               }
        },
        {
                .local_name = "distinguishedName",
-               .type = MAP_RENAME,
+               .type = LDB_MAP_RENAME,
                .u = {
                        .rename = {
                                 .remote_name = "entryDN"
                         }
                }
        },
+       {
+               .local_name = "primaryGroupID",
+               .type = LDB_MAP_CONVERT,
+               .u = {
+                       .convert = {
+                                .remote_name = "primaryGroupID",
+                                .convert_local = normalise_to_signed32,
+                                .convert_remote = val_copy,
+                       }
+               }
+       },
        {
                .local_name = "groupType",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
-                                .remote_name = "groupType",
+                                .remote_name = "sambaGroupType",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "userAccountControl",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "userAccountControl",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "sAMAccountType",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "sAMAccountType",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "systemFlags",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "systemFlags",
                                 .convert_local = normalise_to_signed32,
                                 .convert_remote = val_copy,
-                        },
+                        }
                }
        },
        {
                .local_name = "usnChanged",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "modifyTimestamp",
                                 .convert_local = usn_to_timestamp,
                                 .convert_remote = timestamp_to_usn,
-                        },
-               },
+                        }
+               }
        },
        {
                .local_name = "usnCreated",
-               .type = MAP_CONVERT,
+               .type = LDB_MAP_CONVERT,
                .u = {
                        .convert = {
                                 .remote_name = "createTimestamp",
                                 .convert_local = usn_to_timestamp,
                                 .convert_remote = timestamp_to_usn,
-                        },
-               },
+                        }
+               }
+       },
+       {
+               .local_name = "unixHomeDirectory",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "homeDirectory"
+                        }
+               }
+       },
+       {
+               .local_name = "pwdLastSet",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaPwdLastSet"
+                        }
+               }
+       },
+       {
+               .local_name = "lastLogon",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaLogonTime"
+                        }
+               }
+       },
+       {
+               .local_name = "lastLogoff",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaLogoffTime"
+                        }
+               }
+       },
+       {
+               .local_name = "badPwdCount",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaBadPasswordCount"
+                        }
+               }
+       },
+       {
+               .local_name = "logonHours",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaLogonHours"
+                        }
+               }
+       },
+       {
+               .local_name = "homeDrive",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaHomeDrive"
+                        }
+               }
+       },
+       {
+               .local_name = "scriptPath",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaLogonScript"
+                        }
+               }
+       },
+       {
+               .local_name = "profilePath",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaProfilePath"
+                        }
+               }
+       },
+       {
+               .local_name = "userWorkstations",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaUserWorkstations"
+                        }
+               }
+       },
+       {
+               .local_name = "homeDirectory",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaHomePath"
+                        }
+               }
+       },
+       {
+               .local_name = "nextRid",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaNextRid"
+                        }
+               }
+       },
+       {
+               .local_name = "privilegeDisplayName",
+               .type = MAP_RENAME,
+               .u = {
+                       .rename = {
+                                .remote_name = "sambaPrivName"
+                        }
+               }
        },
        {
                .local_name = "*",
-               .type = MAP_KEEP,
+               .type = LDB_MAP_KEEP,
        },
        {
                .local_name = NULL,
        }
 };
 
+/* This objectClass conflicts with builtin classes on FDS */
+const struct ldb_map_objectclass nsuniqueid_objectclasses[] =
+{
+       {
+               .local_name = "domain",
+               .remote_name = "samba4Domain"
+       },
+       {
+               .local_name = "rFC822LocalPart",
+               .remote_name = "samba4RFC822LocalPart"
+       },
+       {
+               .local_name = "mailRecipient",
+               .remote_name = "samba4MailRecipient"
+       },
+       {
+               .local_name = "nisMap",
+               .remote_name = "samba4NisMap"
+       },
+       {
+               .local_name = "person",
+               .remote_name = "samba4Person"
+       },
+       {
+               .local_name = "organizationalPerson",
+               .remote_name = "samba4OrganizationalPerson"
+       },
+       {
+               .local_name = "residentialPerson",
+               .remote_name = "samba4ResidentialPerson"
+       },
+       {
+               .local_name = "inetOrgPerson",
+               .remote_name = "samba4InetOrgPerson"
+       },
+       {
+               .local_name = NULL
+       }
+};
+
 /* These things do not show up in wildcard searches in OpenLDAP, but
  * we need them to show up in the AD-like view */
 static const char * const nsuniqueid_wildcard_attributes[] = {
@@ -604,7 +783,7 @@ static int entryuuid_init(struct ldb_module *module)
 static int nsuniqueid_init(struct ldb_module *module)
 {
         int ret;
-       ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, "extensibleObject", NULL);
+       ret = ldb_map_init(module, nsuniqueid_attributes, nsuniqueid_objectclasses, nsuniqueid_wildcard_attributes, "extensibleObject", NULL);
         if (ret != LDB_SUCCESS)
                 return ret;