LCOV - code coverage report
Current view: top level - source4/dsdb/samdb/ldb_modules - samba3sam.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 87 141 61.7 %
Date: 2024-02-29 22:57:05 Functions: 9 13 69.2 %

          Line data    Source code
       1             : /*
       2             :    ldb database library - Samba3 SAM compatibility backend
       3             : 
       4             :    Copyright (C) Jelmer Vernooij 2005
       5             :    Copyright (C) Martin Kuehl <mkhl@samba.org> 2006
       6             : */
       7             : 
       8             : #include "includes.h"
       9             : #include "ldb_module.h"
      10             : #include "ldb/ldb_map/ldb_map.h"
      11             : #include "system/passwd.h"
      12             : 
      13             : #include "librpc/gen_ndr/ndr_security.h"
      14             : #include "librpc/gen_ndr/ndr_samr.h"
      15             : #include "librpc/ndr/libndr.h"
      16             : #include "libcli/security/security.h"
      17             : #include "lib/samba3/samba3.h"
      18             : 
      19             : /*
      20             :  * sambaSID -> member  (dn!)
      21             :  * sambaSIDList -> member (dn!)
      22             :  * sambaDomainName -> name
      23             :  * sambaTrustPassword
      24             :  * sambaUnixIdPool
      25             :  * sambaIdmapEntry
      26             :  * sambaSidEntry
      27             :  * sambaAcctFlags -> systemFlags ?
      28             :  * sambaPasswordHistory  -> ntPwdHistory*/
      29             : 
      30             : /* Not necessary:
      31             :  * sambaConfig
      32             :  * sambaShare
      33             :  * sambaConfigOption
      34             :  * sambaNextGroupRid
      35             :  * sambaNextUserRid
      36             :  * sambaAlgorithmicRidBase
      37             :  */
      38             : 
      39             : /* Not in Samba4:
      40             :  * sambaKickoffTime
      41             :  * sambaPwdCanChange
      42             :  * sambaPwdMustChange
      43             :  * sambaHomePath
      44             :  * sambaHomeDrive
      45             :  * sambaLogonScript
      46             :  * sambaProfilePath
      47             :  * sambaUserWorkstations
      48             :  * sambaMungedDial
      49             :  * sambaLogonHours */
      50             : 
      51             : /* In Samba4 but not in Samba3:
      52             : */
      53             : 
      54             : /* From a sambaPrimaryGroupSID, generate a primaryGroupID (integer) attribute */
      55          50 : static struct ldb_message_element *generate_primaryGroupID(struct ldb_module *module, TALLOC_CTX *ctx, const char *local_attr, const struct ldb_message *remote)
      56             : {
      57          50 :         struct ldb_message_element *el;
      58          50 :         const char *sid = ldb_msg_find_attr_as_string(remote, "sambaPrimaryGroupSID", NULL);
      59          50 :         const char *p;
      60             :         
      61          50 :         if (!sid)
      62           0 :                 return NULL;
      63             : 
      64          14 :         p = strrchr(sid, '-');
      65          14 :         if (!p)
      66           0 :                 return NULL;
      67             : 
      68          14 :         el = talloc_zero(ctx, struct ldb_message_element);
      69          14 :         el->name = talloc_strdup(ctx, "primaryGroupID");
      70          14 :         el->num_values = 1;
      71          14 :         el->values = talloc_array(ctx, struct ldb_val, 1);
      72          14 :         el->values[0].data = (uint8_t *)talloc_strdup(el->values, p+1);
      73          14 :         el->values[0].length = strlen((char *)el->values[0].data);
      74             : 
      75          14 :         return el;
      76             : }
      77             : 
      78           2 : static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char *local_attr, const struct ldb_message *local, struct ldb_message *remote_mp, struct ldb_message *remote_fb)
      79             : {
      80           2 :         const struct ldb_val *sidval;
      81           2 :         char *sidstring;
      82           2 :         struct dom_sid *sid;
      83           2 :         enum ndr_err_code ndr_err;
      84             : 
      85             :         /* We need the domain, so we get it from the objectSid that we hope is here... */
      86           2 :         sidval = ldb_msg_find_ldb_val(local, "objectSid");
      87             : 
      88           2 :         if (!sidval)
      89           0 :                 return; /* Sorry, no SID today.. */
      90             : 
      91           1 :         sid = talloc(remote_mp, struct dom_sid);
      92           1 :         if (sid == NULL) {
      93           0 :                 return;
      94             :         }
      95             : 
      96           1 :         ndr_err = ndr_pull_struct_blob(sidval, sid, sid, (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
      97           1 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
      98           0 :                 talloc_free(sid);
      99           0 :                 return;
     100             :         }
     101             : 
     102           1 :         if (!ldb_msg_find_ldb_val(local, "primaryGroupID"))
     103           0 :                 return; /* Sorry, no SID today.. */
     104             : 
     105           1 :         sid->num_auths--;
     106             : 
     107           1 :         sidstring = dom_sid_string(remote_mp, sid);
     108           1 :         talloc_free(sid);
     109           1 :         ldb_msg_add_fmt(remote_mp, "sambaPrimaryGroupSID", "%s-%u", sidstring,
     110             :                         ldb_msg_find_attr_as_uint(local, "primaryGroupID", 0));
     111           1 :         talloc_free(sidstring);
     112             : }
     113             : 
     114             : /* Just copy the old value. */
     115           9 : static struct ldb_val convert_uid_samaccount(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     116             : {
     117           9 :         struct ldb_val out = data_blob(NULL, 0);
     118           9 :         out = ldb_val_dup(ctx, val);
     119             : 
     120           9 :         return out;
     121             : }
     122             : 
     123           0 : static struct ldb_val lookup_homedir(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     124             : {
     125           0 :         struct ldb_context *ldb;
     126           0 :         struct passwd *pwd; 
     127           0 :         struct ldb_val retval;
     128             : 
     129           0 :         ldb = ldb_module_get_ctx(module);
     130             : 
     131           0 :         pwd = getpwnam((char *)val->data);
     132             : 
     133           0 :         if (!pwd) {
     134           0 :                 ldb_debug(ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data);
     135           0 :                 return *talloc_zero(ctx, struct ldb_val);
     136             :         }
     137             : 
     138           0 :         retval.data = (uint8_t *)talloc_strdup(ctx, pwd->pw_dir);
     139           0 :         retval.length = strlen((char *)retval.data);
     140             : 
     141           0 :         return retval;
     142             : }
     143             : 
     144           0 : static struct ldb_val lookup_gid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     145             : {
     146           0 :         struct passwd *pwd; 
     147           0 :         struct ldb_val retval;
     148             : 
     149           0 :         pwd = getpwnam((char *)val->data);
     150             : 
     151           0 :         if (!pwd) {
     152           0 :                 return *talloc_zero(ctx, struct ldb_val);
     153             :         }
     154             : 
     155             :         /* "pw_gid" is per POSIX definition "unsigned".
     156             :          * But write it out as "signed" for LDAP compliance. */
     157           0 :         retval.data = (uint8_t *)talloc_asprintf(ctx, "%d", (int) pwd->pw_gid);
     158           0 :         retval.length = strlen((char *)retval.data);
     159             : 
     160           0 :         return retval;
     161             : }
     162             : 
     163           0 : static struct ldb_val lookup_uid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     164             : {
     165           0 :         struct passwd *pwd; 
     166           0 :         struct ldb_val retval;
     167             :         
     168           0 :         pwd = getpwnam((char *)val->data);
     169             : 
     170           0 :         if (!pwd) {
     171           0 :                 return *talloc_zero(ctx, struct ldb_val);
     172             :         }
     173             : 
     174             :         /* "pw_uid" is per POSIX definition "unsigned".
     175             :          * But write it out as "signed" for LDAP compliance. */
     176           0 :         retval.data = (uint8_t *)talloc_asprintf(ctx, "%d", (int) pwd->pw_uid);
     177           0 :         retval.length = strlen((char *)retval.data);
     178             : 
     179           0 :         return retval;
     180             : }
     181             : 
     182             : /* Encode a sambaSID to an objectSid. */
     183          36 : static struct ldb_val encode_sid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     184             : {
     185          36 :         struct ldb_val out = data_blob(NULL, 0);
     186          36 :         struct dom_sid *sid;
     187          36 :         enum ndr_err_code ndr_err;
     188             : 
     189          36 :         sid = dom_sid_parse_talloc(ctx, (char *)val->data);
     190          36 :         if (sid == NULL) {
     191           0 :                 return out;
     192             :         }
     193             : 
     194          36 :         ndr_err = ndr_push_struct_blob(&out, ctx, 
     195             :                                        sid, (ndr_push_flags_fn_t)ndr_push_dom_sid);
     196          36 :         talloc_free(sid);
     197          36 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     198           0 :                 return out;
     199             :         }
     200             : 
     201          36 :         return out;
     202             : }
     203             : 
     204             : /* Decode an objectSid to a sambaSID. */
     205           2 : static struct ldb_val decode_sid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     206             : {
     207           2 :         struct ldb_val out = data_blob(NULL, 0);
     208           2 :         struct dom_sid *sid;
     209           2 :         enum ndr_err_code ndr_err;
     210             : 
     211           2 :         sid = talloc(ctx, struct dom_sid);
     212           2 :         if (sid == NULL) {
     213           0 :                 return out;
     214             :         }
     215             : 
     216           2 :         ndr_err = ndr_pull_struct_blob(val, sid, sid,
     217             :                                        (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
     218           2 :         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     219           0 :                 goto done;
     220             :         }
     221             : 
     222           2 :         out.data = (uint8_t *)dom_sid_string(ctx, sid);
     223           2 :         if (out.data == NULL) {
     224           0 :                 goto done;
     225             :         }
     226           2 :         out.length = strlen((const char *)out.data);
     227             : 
     228           2 : done:
     229           2 :         talloc_free(sid);
     230           2 :         return out;
     231             : }
     232             : 
     233             : /* Convert 16 bytes to 32 hex digits. */
     234           0 : static struct ldb_val bin2hex(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     235             : {
     236           0 :         struct ldb_val out;
     237           0 :         struct samr_Password pwd;
     238           0 :         if (val->length != sizeof(pwd.hash)) {
     239           0 :                 return data_blob(NULL, 0);
     240             :         }
     241           0 :         memcpy(pwd.hash, val->data, sizeof(pwd.hash));
     242           0 :         out = data_blob_string_const(smbpasswd_sethexpwd(ctx, &pwd, 0));
     243           0 :         if (!out.data) {
     244           0 :                 return data_blob(NULL, 0);
     245             :         }
     246           0 :         return out;
     247             : }
     248             : 
     249             : /* Convert 32 hex digits to 16 bytes. */
     250          10 : static struct ldb_val hex2bin(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
     251             : {
     252          10 :         struct ldb_val out;
     253          10 :         struct samr_Password *pwd;
     254          10 :         pwd = smbpasswd_gethexpwd(ctx, (const char *)val->data);
     255          10 :         if (!pwd) {
     256           4 :                 return data_blob(NULL, 0);
     257             :         }
     258           6 :         out = data_blob_talloc(ctx, pwd->hash, sizeof(pwd->hash));
     259           6 :         return out;
     260             : }
     261             : 
     262             : const struct ldb_map_objectclass samba3_objectclasses[] = {
     263             :         {
     264             :                 .local_name = "user",
     265             :                 .remote_name = "posixAccount",
     266             :                 .base_classes = { "top", NULL },
     267             :                 .musts = { "cn", "uid", "uidNumber", "gidNumber", "homeDirectory", NULL },
     268             :                 .mays = { "userPassword", "loginShell", "gecos", "description", NULL },
     269             :         },
     270             :         {
     271             :                 .local_name = "group",
     272             :                 .remote_name = "posixGroup",
     273             :                 .base_classes = { "top", NULL },
     274             :                 .musts = { "cn", "gidNumber", NULL },
     275             :                 .mays = { "userPassword", "memberUid", "description", NULL },
     276             :         },
     277             :         {
     278             :                 .local_name = "group",
     279             :                 .remote_name = "sambaGroupMapping",
     280             :                 .base_classes = { "top", "posixGroup", NULL },
     281             :                 .musts = { "gidNumber", "sambaSID", "sambaGroupType", NULL },
     282             :                 .mays = { "displayName", "description", "sambaSIDList", NULL },
     283             :         },
     284             :         {
     285             :                 .local_name = "user",
     286             :                 .remote_name = "sambaSAMAccount",
     287             :                 .base_classes = { "top", "posixAccount", NULL },
     288             :                 .musts = { "uid", "sambaSID", NULL },
     289             :                 .mays = { "cn", "sambaLMPassword", "sambaNTPassword",
     290             :                         "sambaPwdLastSet", "sambaLogonTime", "sambaLogoffTime",
     291             :                         "sambaKickoffTime", "sambaPwdCanChange", "sambaPwdMustChange",
     292             :                         "sambaAcctFlags", "displayName", "sambaHomePath", "sambaHomeDrive",
     293             :                         "sambaLogonScript", "sambaProfilePath", "description", "sambaUserWorkstations",
     294             :                         "sambaPrimaryGroupSID", "sambaDomainName", "sambaMungedDial",
     295             :                         "sambaBadPasswordCount", "sambaBadPasswordTime",
     296             :                 "sambaPasswordHistory", "sambaLogonHours", NULL }
     297             : 
     298             :         },
     299             :         {
     300             :                 .local_name = "domain",
     301             :                 .remote_name = "sambaDomain",
     302             :                 .base_classes = { "top", NULL },
     303             :                 .musts = { "sambaDomainName", "sambaSID", NULL },
     304             :                 .mays = { "sambaNextRid", "sambaNextGroupRid", "sambaNextUserRid", "sambaAlgorithmicRidBase", NULL },
     305             :         },
     306             :         { .local_name = NULL }
     307             : };
     308             : 
     309             : const struct ldb_map_attribute samba3_attributes[] =
     310             : {
     311             :         /* sambaNextRid -> nextRid */
     312             :         {
     313             :                 .local_name = "nextRid",
     314             :                 .type = LDB_MAP_RENAME,
     315             :                 .u = {
     316             :                         .rename = {
     317             :                                 .remote_name = "sambaNextRid",
     318             :                         },
     319             :                 },
     320             :         },
     321             : 
     322             :         /* sambaBadPasswordTime -> badPasswordtime*/
     323             :         {
     324             :                 .local_name = "badPasswordTime",
     325             :                 .type = LDB_MAP_RENAME,
     326             :                 .u = {
     327             :                         .rename = {
     328             :                                 .remote_name = "sambaBadPasswordTime",
     329             :                         },
     330             :                 },
     331             :         },
     332             : 
     333             :         /* sambaLMPassword -> lmPwdHash*/
     334             :         {
     335             :                 .local_name = "dBCSPwd",
     336             :                 .type = LDB_MAP_CONVERT,
     337             :                 .u = {
     338             :                         .convert = {
     339             :                                 .remote_name = "sambaLMPassword",
     340             :                                 .convert_local = bin2hex,
     341             :                                 .convert_remote = hex2bin,
     342             :                         },
     343             :                 },
     344             :         },
     345             : 
     346             :         /* sambaGroupType -> groupType */
     347             :         {
     348             :                 .local_name = "groupType",
     349             :                 .type = LDB_MAP_RENAME,
     350             :                 .u = {
     351             :                         .rename = {
     352             :                                 .remote_name = "sambaGroupType",
     353             :                         },
     354             :                 },
     355             :         },
     356             : 
     357             :         /* sambaNTPassword -> ntPwdHash*/
     358             :         {
     359             :                 .local_name = "ntpwdhash",
     360             :                 .type = LDB_MAP_CONVERT,
     361             :                 .u = {
     362             :                         .convert = {
     363             :                                 .remote_name = "sambaNTPassword",
     364             :                                 .convert_local = bin2hex,
     365             :                                 .convert_remote = hex2bin,
     366             :                         },
     367             :                 },
     368             :         },
     369             : 
     370             :         /* sambaPrimaryGroupSID -> primaryGroupID */
     371             :         {
     372             :                 .local_name = "primaryGroupID",
     373             :                 .type = LDB_MAP_GENERATE,
     374             :                 .u = {
     375             :                         .generate = {
     376             :                                 .remote_names = { "sambaPrimaryGroupSID", NULL },
     377             :                                 .generate_local = generate_primaryGroupID,
     378             :                                 .generate_remote = generate_sambaPrimaryGroupSID,
     379             :                         },
     380             :                 },
     381             :         },
     382             : 
     383             :         /* sambaBadPasswordCount -> badPwdCount */
     384             :         {
     385             :                 .local_name = "badPwdCount",
     386             :                 .type = LDB_MAP_RENAME,
     387             :                 .u = {
     388             :                         .rename = {
     389             :                                 .remote_name = "sambaBadPasswordCount",
     390             :                         },
     391             :                 },
     392             :         },
     393             : 
     394             :         /* sambaLogonTime -> lastLogon*/
     395             :         {
     396             :                 .local_name = "lastLogon",
     397             :                 .type = LDB_MAP_RENAME,
     398             :                 .u = {
     399             :                         .rename = {
     400             :                                 .remote_name = "sambaLogonTime",
     401             :                         },
     402             :                 },
     403             :         },
     404             : 
     405             :         /* sambaLogoffTime -> lastLogoff*/
     406             :         {
     407             :                 .local_name = "lastLogoff",
     408             :                 .type = LDB_MAP_RENAME,
     409             :                 .u = {
     410             :                         .rename = {
     411             :                                 .remote_name = "sambaLogoffTime",
     412             :                         },
     413             :                 },
     414             :         },
     415             : 
     416             :         /* uid -> unixName */
     417             :         {
     418             :                 .local_name = "unixName",
     419             :                 .type = LDB_MAP_RENAME,
     420             :                 .u = {
     421             :                         .rename = {
     422             :                                 .remote_name = "uid",
     423             :                         },
     424             :                 },
     425             :         },
     426             : 
     427             :         /* displayName -> name */
     428             :         {
     429             :                 .local_name = "name",
     430             :                 .type = LDB_MAP_RENAME,
     431             :                 .u = {
     432             :                         .rename = {
     433             :                                 .remote_name = "displayName",
     434             :                         },
     435             :                 },
     436             :         },
     437             : 
     438             :         /* cn */
     439             :         {
     440             :                 .local_name = "cn",
     441             :                 .type = LDB_MAP_KEEP,
     442             :         },
     443             : 
     444             :         /* sAMAccountName -> cn */
     445             :         {
     446             :                 .local_name = "sAMAccountName",
     447             :                 .type = LDB_MAP_CONVERT,
     448             :                 .u = {
     449             :                         .convert = {
     450             :                                 .remote_name = "uid",
     451             :                                 .convert_remote = convert_uid_samaccount,
     452             :                         },
     453             :                 },
     454             :         },
     455             : 
     456             :         /* objectCategory */
     457             :         {
     458             :                 .local_name = "objectCategory",
     459             :                 .type = LDB_MAP_IGNORE,
     460             :         },
     461             : 
     462             :         /* objectGUID */
     463             :         {
     464             :                 .local_name = "objectGUID",
     465             :                 .type = LDB_MAP_IGNORE,
     466             :         },
     467             : 
     468             :         /* objectVersion */
     469             :         {
     470             :                 .local_name = "objectVersion",
     471             :                 .type = LDB_MAP_IGNORE,
     472             :         },
     473             : 
     474             :         /* codePage */
     475             :         {
     476             :                 .local_name = "codePage",
     477             :                 .type = LDB_MAP_IGNORE,
     478             :         },
     479             : 
     480             :         /* dNSHostName */
     481             :         {
     482             :                 .local_name = "dNSHostName",
     483             :                 .type = LDB_MAP_IGNORE,
     484             :         },
     485             : 
     486             : 
     487             :         /* dnsDomain */
     488             :         {
     489             :                 .local_name = "dnsDomain",
     490             :                 .type = LDB_MAP_IGNORE,
     491             :         },
     492             : 
     493             :         /* dnsRoot */
     494             :         {
     495             :                 .local_name = "dnsRoot",
     496             :                 .type = LDB_MAP_IGNORE,
     497             :         },
     498             : 
     499             :         /* countryCode */
     500             :         {
     501             :                 .local_name = "countryCode",
     502             :                 .type = LDB_MAP_IGNORE,
     503             :         },
     504             : 
     505             :         /* nTMixedDomain */
     506             :         {
     507             :                 .local_name = "nTMixedDomain",
     508             :                 .type = LDB_MAP_IGNORE,
     509             :         },
     510             : 
     511             :         /* operatingSystem */
     512             :         {
     513             :                 .local_name = "operatingSystem",
     514             :                 .type = LDB_MAP_IGNORE,
     515             :         },
     516             : 
     517             :         /* operatingSystemVersion */
     518             :         {
     519             :                 .local_name = "operatingSystemVersion",
     520             :                 .type = LDB_MAP_IGNORE,
     521             :         },
     522             : 
     523             : 
     524             :         /* servicePrincipalName */
     525             :         {
     526             :                 .local_name = "servicePrincipalName",
     527             :                 .type = LDB_MAP_IGNORE,
     528             :         },
     529             : 
     530             :         /* msDS-Behavior-Version */
     531             :         {
     532             :                 .local_name = "msDS-Behavior-Version",
     533             :                 .type = LDB_MAP_IGNORE,
     534             :         },
     535             : 
     536             :         /* msDS-KeyVersionNumber */
     537             :         {
     538             :                 .local_name = "msDS-KeyVersionNumber",
     539             :                 .type = LDB_MAP_IGNORE,
     540             :         },
     541             : 
     542             :         /* msDs-masteredBy */
     543             :         {
     544             :                 .local_name = "msDs-masteredBy",
     545             :                 .type = LDB_MAP_IGNORE,
     546             :         },
     547             : 
     548             :         /* ou */
     549             :         {
     550             :                 .local_name = "ou",
     551             :                 .type = LDB_MAP_KEEP,
     552             :         },
     553             : 
     554             :         /* dc */
     555             :         {
     556             :                 .local_name = "dc",
     557             :                 .type = LDB_MAP_KEEP,
     558             :         },
     559             : 
     560             :         /* description */
     561             :         {
     562             :                 .local_name = "description",
     563             :                 .type = LDB_MAP_KEEP,
     564             :         },
     565             : 
     566             :         /* sambaSID -> objectSid*/
     567             :         {
     568             :                 .local_name = "objectSid",
     569             :                 .type = LDB_MAP_CONVERT,
     570             :                 .u = {
     571             :                         .convert = {
     572             :                                 .remote_name = "sambaSID",
     573             :                                 .convert_local = decode_sid,
     574             :                                 .convert_remote = encode_sid,
     575             :                         },
     576             :                 },
     577             :         },
     578             : 
     579             :         /* sambaPwdLastSet -> pwdLastSet */
     580             :         {
     581             :                 .local_name = "pwdLastSet",
     582             :                 .type = LDB_MAP_RENAME,
     583             :                 .u = {
     584             :                         .rename = {
     585             :                                 .remote_name = "sambaPwdLastSet",
     586             :                         },
     587             :                 },
     588             :         },
     589             : 
     590             :         /* accountExpires */
     591             :         {
     592             :                 .local_name = "accountExpires",
     593             :                 .type = LDB_MAP_IGNORE,
     594             :         },
     595             : 
     596             :         /* adminCount */
     597             :         {
     598             :                 .local_name = "adminCount",
     599             :                 .type = LDB_MAP_IGNORE,
     600             :         },
     601             : 
     602             :         /* canonicalName */
     603             :         {
     604             :                 .local_name = "canonicalName",
     605             :                 .type = LDB_MAP_IGNORE,
     606             :         },
     607             : 
     608             :         /* createTimestamp */
     609             :         {
     610             :                 .local_name = "createTimestamp",
     611             :                 .type = LDB_MAP_IGNORE,
     612             :         },
     613             : 
     614             :         /* creationTime */
     615             :         {
     616             :                 .local_name = "creationTime",
     617             :                 .type = LDB_MAP_IGNORE,
     618             :         },
     619             : 
     620             :         /* dMDLocation */
     621             :         {
     622             :                 .local_name = "dMDLocation",
     623             :                 .type = LDB_MAP_IGNORE,
     624             :         },
     625             : 
     626             :         /* fSMORoleOwner */
     627             :         {
     628             :                 .local_name = "fSMORoleOwner",
     629             :                 .type = LDB_MAP_IGNORE,
     630             :         },
     631             : 
     632             :         /* forceLogoff */
     633             :         {
     634             :                 .local_name = "forceLogoff",
     635             :                 .type = LDB_MAP_IGNORE,
     636             :         },
     637             : 
     638             :         /* instanceType */
     639             :         {
     640             :                 .local_name = "instanceType",
     641             :                 .type = LDB_MAP_IGNORE,
     642             :         },
     643             : 
     644             :         /* invocationId */
     645             :         {
     646             :                 .local_name = "invocationId",
     647             :                 .type = LDB_MAP_IGNORE,
     648             :         },
     649             : 
     650             :         /* isCriticalSystemObject */
     651             :         {
     652             :                 .local_name = "isCriticalSystemObject",
     653             :                 .type = LDB_MAP_IGNORE,
     654             :         },
     655             : 
     656             :         /* localPolicyFlags */
     657             :         {
     658             :                 .local_name = "localPolicyFlags",
     659             :                 .type = LDB_MAP_IGNORE,
     660             :         },
     661             : 
     662             :         /* lockOutObservationWindow */
     663             :         {
     664             :                 .local_name = "lockOutObservationWindow",
     665             :                 .type = LDB_MAP_IGNORE,
     666             :         },
     667             : 
     668             :         /* lockoutDuration */
     669             :         {
     670             :                 .local_name = "lockoutDuration",
     671             :                 .type = LDB_MAP_IGNORE,
     672             :         },
     673             : 
     674             :         /* lockoutThreshold */
     675             :         {
     676             :                 .local_name = "lockoutThreshold",
     677             :                 .type = LDB_MAP_IGNORE,
     678             :         },
     679             : 
     680             :         /* logonCount */
     681             :         {
     682             :                 .local_name = "logonCount",
     683             :                 .type = LDB_MAP_IGNORE,
     684             :         },
     685             : 
     686             :         /* masteredBy */
     687             :         {
     688             :                 .local_name = "masteredBy",
     689             :                 .type = LDB_MAP_IGNORE,
     690             :         },
     691             : 
     692             :         /* maxPwdAge */
     693             :         {
     694             :                 .local_name = "maxPwdAge",
     695             :                 .type = LDB_MAP_IGNORE,
     696             :         },
     697             : 
     698             :         /* member */
     699             :         {
     700             :                 .local_name = "member",
     701             :                 .type = LDB_MAP_IGNORE,
     702             :         },
     703             : 
     704             :         /* memberOf */
     705             :         {
     706             :                 .local_name = "memberOf",
     707             :                 .type = LDB_MAP_IGNORE,
     708             :         },
     709             : 
     710             :         /* minPwdAge */
     711             :         {
     712             :                 .local_name = "minPwdAge",
     713             :                 .type = LDB_MAP_IGNORE,
     714             :         },
     715             : 
     716             :         /* minPwdLength */
     717             :         {
     718             :                 .local_name = "minPwdLength",
     719             :                 .type = LDB_MAP_IGNORE,
     720             :         },
     721             : 
     722             :         /* modifiedCount */
     723             :         {
     724             :                 .local_name = "modifiedCount",
     725             :                 .type = LDB_MAP_IGNORE,
     726             :         },
     727             : 
     728             :         /* modifiedCountAtLastProm */
     729             :         {
     730             :                 .local_name = "modifiedCountAtLastProm",
     731             :                 .type = LDB_MAP_IGNORE,
     732             :         },
     733             : 
     734             :         /* modifyTimestamp */
     735             :         {
     736             :                 .local_name = "modifyTimestamp",
     737             :                 .type = LDB_MAP_IGNORE,
     738             :         },
     739             : 
     740             :         /* nCName */
     741             :         {
     742             :                 .local_name = "nCName",
     743             :                 .type = LDB_MAP_IGNORE,
     744             :         },
     745             : 
     746             :         /* nETBIOSName */
     747             :         {
     748             :                 .local_name = "nETBIOSName",
     749             :                 .type = LDB_MAP_IGNORE,
     750             :         },
     751             : 
     752             :         /* oEMInformation */
     753             :         {
     754             :                 .local_name = "oEMInformation",
     755             :                 .type = LDB_MAP_IGNORE,
     756             :         },
     757             : 
     758             :         /* privilege */
     759             :         {
     760             :                 .local_name = "privilege",
     761             :                 .type = LDB_MAP_IGNORE,
     762             :         },
     763             : 
     764             :         /* pwdHistoryLength */
     765             :         {
     766             :                 .local_name = "pwdHistoryLength",
     767             :                 .type = LDB_MAP_IGNORE,
     768             :         },
     769             : 
     770             :         /* pwdProperties */
     771             :         {
     772             :                 .local_name = "pwdProperties",
     773             :                 .type = LDB_MAP_IGNORE,
     774             :         },
     775             : 
     776             :         /* rIDAvailablePool */
     777             :         {
     778             :                 .local_name = "rIDAvailablePool",
     779             :                 .type = LDB_MAP_IGNORE,
     780             :         },
     781             : 
     782             :         /* revision */
     783             :         {
     784             :                 .local_name = "revision",
     785             :                 .type = LDB_MAP_IGNORE,
     786             :         },
     787             : 
     788             :         /* ridManagerReference */
     789             :         {
     790             :                 .local_name = "ridManagerReference",
     791             :                 .type = LDB_MAP_IGNORE,
     792             :         },
     793             : 
     794             :         /* sAMAccountType */
     795             :         {
     796             :                 .local_name = "sAMAccountType",
     797             :                 .type = LDB_MAP_IGNORE,
     798             :         },
     799             : 
     800             :         /* sPNMappings */
     801             :         {
     802             :                 .local_name = "sPNMappings",
     803             :                 .type = LDB_MAP_IGNORE,
     804             :         },
     805             : 
     806             :         /* serverReference */
     807             :         {
     808             :                 .local_name = "serverReference",
     809             :                 .type = LDB_MAP_IGNORE,
     810             :         },
     811             : 
     812             :         /* serverState */
     813             :         {
     814             :                 .local_name = "serverState",
     815             :                 .type = LDB_MAP_IGNORE,
     816             :         },
     817             : 
     818             :         /* showInAdvancedViewOnly */
     819             :         {
     820             :                 .local_name = "showInAdvancedViewOnly",
     821             :                 .type = LDB_MAP_IGNORE,
     822             :         },
     823             : 
     824             :         /* subRefs */
     825             :         {
     826             :                 .local_name = "subRefs",
     827             :                 .type = LDB_MAP_IGNORE,
     828             :         },
     829             : 
     830             :         /* systemFlags */
     831             :         {
     832             :                 .local_name = "systemFlags",
     833             :                 .type = LDB_MAP_IGNORE,
     834             :         },
     835             : 
     836             :         /* uASCompat */
     837             :         {
     838             :                 .local_name = "uASCompat",
     839             :                 .type = LDB_MAP_IGNORE,
     840             :         },
     841             : 
     842             :         /* uSNChanged */
     843             :         {
     844             :                 .local_name = "uSNChanged",
     845             :                 .type = LDB_MAP_IGNORE,
     846             :         },
     847             : 
     848             :         /* uSNCreated */
     849             :         {
     850             :                 .local_name = "uSNCreated",
     851             :                 .type = LDB_MAP_IGNORE,
     852             :         },
     853             : 
     854             :         /* userPassword */
     855             :         {
     856             :                 .local_name = "userPassword",
     857             :                 .type = LDB_MAP_IGNORE,
     858             :         },
     859             : 
     860             :         /* userAccountControl */
     861             :         {
     862             :                 .local_name = "userAccountControl",
     863             :                 .type = LDB_MAP_IGNORE,
     864             :         },
     865             : 
     866             :         /* whenChanged */
     867             :         {
     868             :                 .local_name = "whenChanged",
     869             :                 .type = LDB_MAP_IGNORE,
     870             :         },
     871             : 
     872             :         /* whenCreated */
     873             :         {
     874             :                 .local_name = "whenCreated",
     875             :                 .type = LDB_MAP_IGNORE,
     876             :         },
     877             : 
     878             :         /* uidNumber */
     879             :         {
     880             :                 .local_name = "unixName",
     881             :                 .type = LDB_MAP_CONVERT,
     882             :                 .u = {
     883             :                         .convert = {
     884             :                                 .remote_name = "uidNumber",
     885             :                                 .convert_local = lookup_uid,
     886             :                         },
     887             :                 },
     888             :         },
     889             : 
     890             :         /* gidNumber. Perhaps make into generate so we can distinguish between 
     891             :          * groups and accounts? */
     892             :         {
     893             :                 .local_name = "unixName",
     894             :                 .type = LDB_MAP_CONVERT,
     895             :                 .u = {
     896             :                         .convert = {
     897             :                                 .remote_name = "gidNumber",
     898             :                                 .convert_local = lookup_gid,
     899             :                         },
     900             :                 },
     901             :         },
     902             : 
     903             :         /* homeDirectory */
     904             :         {
     905             :                 .local_name = "unixName",
     906             :                 .type = LDB_MAP_CONVERT,
     907             :                 .u = {
     908             :                         .convert = {
     909             :                                 .remote_name = "homeDirectory",
     910             :                                 .convert_local = lookup_homedir,
     911             :                         },
     912             :                 },
     913             :         },
     914             :         {
     915             :                 .local_name = NULL,
     916             :         }
     917             : };
     918             : 
     919             : /* the context init function */
     920          11 : static int samba3sam_init(struct ldb_module *module)
     921             : {
     922          11 :         int ret;
     923             : 
     924          11 :         ret = ldb_map_init(module, samba3_attributes, samba3_objectclasses, NULL, NULL, "samba3sam");
     925          11 :         if (ret != LDB_SUCCESS)
     926           0 :                 return ret;
     927             : 
     928          11 :         return ldb_next_init(module);
     929             : }
     930             : 
     931             : static const struct ldb_module_ops ldb_samba3sam_module_ops = {
     932             :         LDB_MAP_OPS
     933             :         .name              = "samba3sam",
     934             :         .init_context      = samba3sam_init,
     935             : };
     936             : 
     937             : 
     938             : /* A dummy module to help the samba3sam tests */
     939         507 : static int show_deleted_ignore_search(struct ldb_module *module, struct ldb_request *req)
     940             : {
     941         507 :         struct ldb_control *show_del, *show_rec;
     942             : 
     943             :         /* check if there's a show deleted control */
     944         507 :         show_del = ldb_request_get_control(req, LDB_CONTROL_SHOW_DELETED_OID);
     945             :         /* check if there's a show recycled control */
     946         507 :         show_rec = ldb_request_get_control(req, LDB_CONTROL_SHOW_RECYCLED_OID);
     947             : 
     948             :         /* mark the controls as done */
     949         507 :         if (show_del != NULL) {
     950          19 :                 show_del->critical = 0;
     951             :         }
     952         507 :         if (show_rec != NULL) {
     953           5 :                 show_rec->critical = 0;
     954             :         }
     955             : 
     956             :         /* perform the search */
     957         507 :         return ldb_next_request(module, req);
     958             : }
     959             : 
     960             : static const struct ldb_module_ops ldb_show_deleted_module_ops = {
     961             :         .name              = "show_deleted_ignore",
     962             :         .search            = show_deleted_ignore_search
     963             : };
     964             : 
     965        5950 : int ldb_samba3sam_module_init(const char *version)
     966             : {
     967         393 :         int ret;
     968             :         
     969        5950 :         LDB_MODULE_CHECK_VERSION(version);
     970        5950 :         ret = ldb_register_module(&ldb_show_deleted_module_ops);
     971        5950 :         if (ret != LDB_SUCCESS) {
     972           0 :                 return ret;
     973             :         }
     974             : 
     975        5950 :         return ldb_register_module(&ldb_samba3sam_module_ops);
     976             : }
     977             : 

Generated by: LCOV version 1.14