2 Unix SMB/CIFS implementation.
6 Copyright (C) Simo Sorce 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #define DBGC_CLASS DBGC_IDMAP
29 /*****************************
30 Initialise idmap database.
31 *****************************/
33 static NTSTATUS
idmap_pdb_init(struct idmap_domain
*dom
)
38 /**********************************
39 lookup a set of unix ids.
40 **********************************/
42 static NTSTATUS
idmap_pdb_unixids_to_sids(struct idmap_domain
*dom
, struct id_map
**ids
)
46 for (i
= 0; ids
[i
]; i
++) {
48 /* unmapped by default */
49 ids
[i
]->status
= ID_UNMAPPED
;
51 switch (ids
[i
]->xid
.type
) {
53 if (pdb_uid_to_sid((uid_t
)ids
[i
]->xid
.id
, ids
[i
]->sid
)) {
54 ids
[i
]->status
= ID_MAPPED
;
58 if (pdb_gid_to_sid((gid_t
)ids
[i
]->xid
.id
, ids
[i
]->sid
)) {
59 ids
[i
]->status
= ID_MAPPED
;
63 ids
[i
]->status
= ID_UNKNOWN
;
70 /**********************************
72 **********************************/
74 static NTSTATUS
idmap_pdb_sids_to_unixids(struct idmap_domain
*dom
, struct id_map
**ids
)
78 for (i
= 0; ids
[i
]; i
++) {
79 if (pdb_sid_to_id(ids
[i
]->sid
, &ids
[i
]->xid
)) {
80 ids
[i
]->status
= ID_MAPPED
;
83 ids
[i
]->status
= ID_UNMAPPED
;
90 /**********************************
91 Close the idmap tdb instance
92 **********************************/
94 static struct idmap_methods passdb_methods
= {
96 .init
= idmap_pdb_init
,
97 .unixids_to_sids
= idmap_pdb_unixids_to_sids
,
98 .sids_to_unixids
= idmap_pdb_sids_to_unixids
,
101 NTSTATUS
idmap_passdb_init(void)
103 return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION
, "passdb", &passdb_methods
);