2 Unix SMB/CIFS implementation.
4 Copyright (C) Simo Sorce 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/
23 #define DBGC_CLASS DBGC_IDMAP
25 /*****************************************************************
27 *****************************************************************/
29 NTSTATUS
idmap_uid_to_sid(DOM_SID
*sid
, uid_t uid
, int flags
)
33 DEBUG(10,("idmap_uid_to_sid: uid = [%lu]\n", (unsigned long)uid
));
38 return idmap_get_sid_from_id(sid
, id
, flags
);
41 /*****************************************************************
42 Group mapping is used for gids that maps to Wellknown SIDs
44 *****************************************************************/
46 NTSTATUS
idmap_gid_to_sid(DOM_SID
*sid
, gid_t gid
, int flags
)
50 DEBUG(10,("idmap_gid_to_sid: gid = [%lu]\n", (unsigned long)gid
));
55 return idmap_get_sid_from_id(sid
, id
, flags
);
58 /*****************************************************************
59 if it is a foreign sid or it is in idmap rid range check idmap,
60 otherwise falls back to the legacy algorithmic mapping.
61 Returns True if this name is a user sid and the conversion
62 was done correctly, False if not.
63 *****************************************************************/
65 NTSTATUS
idmap_sid_to_uid(const DOM_SID
*sid
, uid_t
*uid
, uint32 flags
)
67 NTSTATUS ret
= NT_STATUS_UNSUCCESSFUL
;
70 DEBUG(10,("idmap_sid_to_uid: sid = [%s]\n", sid_string_static(sid
)));
74 ret
= idmap_get_id_from_sid(&id
, (int *)&flags
, sid
);
76 if ( NT_STATUS_IS_OK(ret
) ) {
77 DEBUG(10,("idmap_sid_to_uid: uid = [%lu]\n", (unsigned long)id
.uid
));
85 /*****************************************************************
86 *THE CANONICAL* convert SID to gid function.
87 if it is a foreign sid or it is in idmap rid range check idmap,
88 otherwise falls back to the legacy algorithmic mapping.
89 Group mapping is used for gids that maps to Wellknown SIDs
90 Returns True if this name is a user sid and the conversion
91 was done correctly, False if not.
92 *****************************************************************/
94 NTSTATUS
idmap_sid_to_gid(const DOM_SID
*sid
, gid_t
*gid
, uint32 flags
)
96 NTSTATUS ret
= NT_STATUS_UNSUCCESSFUL
;
99 DEBUG(10,("sid_to_gid: sid = [%s]\n", sid_string_static(sid
)));
103 ret
= idmap_get_id_from_sid(&id
, (int *)&flags
, sid
);
105 if ( NT_STATUS_IS_OK(ret
) )
107 DEBUG(10,("idmap_sid_to_gid: gid = [%lu]\n", (unsigned long)id
.gid
));
114 /* placeholder for checking lp_winbind_nss_info() */
115 BOOL
use_nss_info(const char *info
)
118 const char **list
= lp_winbind_nss_info();
120 for (i
=0; list
[i
]; i
++) {
121 if (strequal(list
[i
], info
))