2006-12-12 17:52:13 +03:00
/*
Unix SMB / CIFS implementation .
idmap PASSDB backend
Copyright ( C ) Simo Sorce 2006
2011-02-12 21:52:05 +03:00
2006-12-12 17:52:13 +03:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2006-12-12 17:52:13 +03:00
( at your option ) any later version .
2011-02-12 21:52:05 +03:00
2006-12-12 17:52:13 +03:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2011-02-12 21:52:05 +03:00
2006-12-12 17:52:13 +03:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-12-12 17:52:13 +03:00
*/
# include "includes.h"
2010-08-18 20:13:42 +04:00
# include "idmap.h"
2011-03-18 20:58:37 +03:00
# include "passdb.h"
2006-12-12 17:52:13 +03:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_IDMAP
/*****************************
Initialise idmap database .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2011-03-03 01:00:58 +03:00
static NTSTATUS idmap_pdb_init ( struct idmap_domain * dom )
2006-12-12 17:52:13 +03:00
{
return NT_STATUS_OK ;
}
/**********************************
lookup a set of unix ids .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS idmap_pdb_unixids_to_sids ( struct idmap_domain * dom , struct id_map * * ids )
{
int i ;
for ( i = 0 ; ids [ i ] ; i + + ) {
2007-01-14 20:58:24 +03:00
/* unmapped by default */
ids [ i ] - > status = ID_UNMAPPED ;
2014-11-25 04:45:26 +03:00
if ( pdb_id_to_sid ( & ids [ i ] - > xid , ids [ i ] - > sid ) ) {
ids [ i ] - > status = ID_MAPPED ;
2006-12-12 17:52:13 +03:00
}
}
return NT_STATUS_OK ;
}
/**********************************
lookup a set of sids .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS idmap_pdb_sids_to_unixids ( struct idmap_domain * dom , struct id_map * * ids )
{
int i ;
for ( i = 0 ; ids [ i ] ; i + + ) {
2012-03-16 02:16:23 +04:00
if ( pdb_sid_to_id ( ids [ i ] - > sid , & ids [ i ] - > xid ) ) {
ids [ i ] - > status = ID_MAPPED ;
2006-12-12 17:52:13 +03:00
} else {
/* Query Failed */
2007-01-14 20:58:24 +03:00
ids [ i ] - > status = ID_UNMAPPED ;
2006-12-12 17:52:13 +03:00
}
}
return NT_STATUS_OK ;
}
2019-03-21 14:30:37 +03:00
static const struct idmap_methods passdb_methods = {
2006-12-12 17:52:13 +03:00
. init = idmap_pdb_init ,
. unixids_to_sids = idmap_pdb_unixids_to_sids ,
. sids_to_unixids = idmap_pdb_sids_to_unixids ,
} ;
2017-04-20 22:24:43 +03:00
NTSTATUS idmap_passdb_init ( TALLOC_CTX * mem_ctx )
2006-12-12 17:52:13 +03:00
{
return smb_register_idmap ( SMB_IDMAP_INTERFACE_VERSION , " passdb " , & passdb_methods ) ;
}