1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | idmap PASSDB backend
|
---|
5 |
|
---|
6 | Copyright (C) Simo Sorce 2006
|
---|
7 |
|
---|
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.
|
---|
12 |
|
---|
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.
|
---|
17 |
|
---|
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/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 | #include "idmap.h"
|
---|
24 | #include "passdb.h"
|
---|
25 |
|
---|
26 | #undef DBGC_CLASS
|
---|
27 | #define DBGC_CLASS DBGC_IDMAP
|
---|
28 |
|
---|
29 | /*****************************
|
---|
30 | Initialise idmap database.
|
---|
31 | *****************************/
|
---|
32 |
|
---|
33 | static NTSTATUS idmap_pdb_init(struct idmap_domain *dom)
|
---|
34 | {
|
---|
35 | return NT_STATUS_OK;
|
---|
36 | }
|
---|
37 |
|
---|
38 | /**********************************
|
---|
39 | lookup a set of unix ids.
|
---|
40 | **********************************/
|
---|
41 |
|
---|
42 | static NTSTATUS idmap_pdb_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
|
---|
43 | {
|
---|
44 | int i;
|
---|
45 |
|
---|
46 | for (i = 0; ids[i]; i++) {
|
---|
47 | /* unmapped by default */
|
---|
48 | ids[i]->status = ID_UNMAPPED;
|
---|
49 |
|
---|
50 | if (pdb_id_to_sid(&ids[i]->xid, ids[i]->sid)) {
|
---|
51 | ids[i]->status = ID_MAPPED;
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | return NT_STATUS_OK;
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**********************************
|
---|
59 | lookup a set of sids.
|
---|
60 | **********************************/
|
---|
61 |
|
---|
62 | static NTSTATUS idmap_pdb_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
|
---|
63 | {
|
---|
64 | int i;
|
---|
65 |
|
---|
66 | for (i = 0; ids[i]; i++) {
|
---|
67 | if (pdb_sid_to_id(ids[i]->sid, &ids[i]->xid)) {
|
---|
68 | ids[i]->status = ID_MAPPED;
|
---|
69 | } else {
|
---|
70 | /* Query Failed */
|
---|
71 | ids[i]->status = ID_UNMAPPED;
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | return NT_STATUS_OK;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /**********************************
|
---|
79 | Close the idmap tdb instance
|
---|
80 | **********************************/
|
---|
81 |
|
---|
82 | static struct idmap_methods passdb_methods = {
|
---|
83 |
|
---|
84 | .init = idmap_pdb_init,
|
---|
85 | .unixids_to_sids = idmap_pdb_unixids_to_sids,
|
---|
86 | .sids_to_unixids = idmap_pdb_sids_to_unixids,
|
---|
87 | };
|
---|
88 |
|
---|
89 | NTSTATUS idmap_passdb_init(void)
|
---|
90 | {
|
---|
91 | return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "passdb", &passdb_methods);
|
---|
92 | }
|
---|