s3-winbindd: rework reconnect logic in winbindd_lookup_sids().
[Samba.git] / source3 / winbindd / idmap_tdb_common.h
blob3343b58c21e2db4f1e7a7eb0729996505a5fb03b
1 /*
2 Unix SMB/CIFS implementation.
4 common functions for TDB based idmapping backends
6 Copyright (C) Christian Ambach 2012
8 These functions were initially copied over from idmap_tdb.c and idmap_tdb2.c
9 which are:
11 Copyright (C) Tim Potter 2000
12 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
13 Copyright (C) Jeremy Allison 2006
14 Copyright (C) Simo Sorce 2003-2006
15 Copyright (C) Michael Adam 2009-2010
16 Copyright (C) Andrew Tridgell 2007
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #ifndef _IDMAP_TDB_COMMON_H_
34 #define _IDMAP_TDB_COMMON_H_
36 #include "includes.h"
37 #include "idmap.h"
38 #include "dbwrap/dbwrap.h"
41 * this must be stored in idmap_domain->private_data
42 * when using idmap_tdb_common_get_new_id and the
43 * mapping functions idmap_tdb_common_unixid(s)_to_sids
45 * private_data can be used for backend specific
46 * configuration data (e.g. idmap script in idmap_tdb2)
49 struct idmap_tdb_common_context {
50 struct db_context *db;
51 struct idmap_rw_ops *rw_ops;
53 * what is the maximum xid to be allocated
54 * this is typically just dom->high_id
56 uint32_t max_id;
57 const char *hwmkey_uid;
58 const char *hwmkey_gid;
59 /**
60 * if not set, idmap_tdb_common_unixids_to_sid will be used by
61 * idmap_tdb_common_unixids_to_sids
63 NTSTATUS(*unixid_to_sid_fn) (struct idmap_domain *dom,
64 struct id_map * map);
66 * if not set, idmap_tdb_common_sid_to_id will be used by
67 * idmap_tdb_common_sids_to_unixids
69 NTSTATUS(*sid_to_unixid_fn) (struct idmap_domain *dom,
70 struct id_map * map);
71 void *private_data;
74 /**
75 * Allocate a new unix-ID.
76 * For now this is for the default idmap domain only.
77 * Should be extended later on.
79 NTSTATUS idmap_tdb_common_get_new_id(struct idmap_domain *dom,
80 struct unixid *id);
83 * store a mapping into the idmap database
85 * the entries that will be stored are
86 * UID map->xid.id => map->sid and map->sid => UID map->xid.id
87 * or
88 * GID map->xid.id => map->sid and map->sid => GID map->xid.id
90 * for example
91 * UID 12345 = S-1-5-21-297746067-1479432880-4056370663
92 * S-1-5-21-297746067-1479432880-4056370663 = UID 12345
95 NTSTATUS idmap_tdb_common_set_mapping(struct idmap_domain *dom,
96 const struct id_map *map);
99 * Create a new mapping for an unmapped SID, also allocating a new ID.
100 * This should be run inside a transaction.
102 * TODO:
103 * Properly integrate this with multi domain idmap config:
104 * Currently, the allocator is default-config only.
106 NTSTATUS idmap_tdb_common_new_mapping(struct idmap_domain *dom,
107 struct id_map *map);
110 * default multiple id to sid lookup function
112 * will call idmap_tdb_common_unixid_to_sid for each mapping
113 * if no other function to lookup unixid_to_sid was given in
114 * idmap_tdb_common_context
116 NTSTATUS idmap_tdb_common_unixids_to_sids(struct idmap_domain *dom,
117 struct id_map **ids);
120 * default single id to sid lookup function
122 * will read the entries written by idmap_tdb_common_set_mapping
124 NTSTATUS idmap_tdb_common_unixid_to_sid(struct idmap_domain *dom,
125 struct id_map *map);
127 /**********************************
128 Single sid to id lookup function.
129 **********************************/
131 NTSTATUS idmap_tdb_common_sid_to_unixid(struct idmap_domain *dom,
132 struct id_map *map);
134 NTSTATUS idmap_tdb_common_sids_to_unixids(struct idmap_domain *dom,
135 struct id_map **ids);
137 #endif /* _IDMAP_TDB_COMMON_H_ */