2000-10-26 07:31:41 +04:00
/*
2002-01-30 09:08:46 +03:00
* Unix SMB / CIFS implementation .
* SMB parameters and setup
2003-07-11 09:33:40 +04:00
* Copyright ( C ) Andrew Tridgell 1992 - 1998
2005-01-13 21:20:37 +03:00
* Copyright ( C ) Simo Sorce 2000 - 2003
2003-07-11 09:33:40 +04:00
* Copyright ( C ) Gerald Carter 2000
* Copyright ( C ) Jeremy Allison 2001
* Copyright ( C ) Andrew Bartlett 2002
2005-10-12 00:14:04 +04:00
* Copyright ( C ) Jim McDonough < jmcd @ us . ibm . com > 2005
2000-10-26 07:31:41 +04: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 the Free
* Software Foundation ; either version 2 of the License , or ( at your option )
* any later version .
*
* 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 .
*
* You should have received a copy of the GNU General Public License along with
* this program ; if not , write to the Free Software Foundation , Inc . , 675
* Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2002-07-15 14:35:28 +04:00
#if 0 /* when made a module use this */
static int tdbsam_debug_level = DBGC_ALL ;
# undef DBGC_CLASS
# define DBGC_CLASS tdbsam_debug_level
# else
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_PASSDB
# endif
2004-07-08 10:39:22 +04:00
# define TDBSAM_VERSION 2 /* Most recent TDBSAM version */
2004-02-13 17:48:20 +03:00
# define TDBSAM_VERSION_STRING "INFO / version"
2002-02-02 02:20:08 +03:00
# define PASSDB_FILE_NAME "passdb.tdb"
2000-11-21 08:55:16 +03:00
# define USERPREFIX "USER_"
2000-12-06 21:22:29 +03:00
# define RIDPREFIX "RID_"
2005-01-13 21:20:37 +03:00
# define PRIVPREFIX "PRIV_"
2004-02-13 17:48:20 +03:00
# define tdbsamver_t int32
2000-10-26 07:31:41 +04:00
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
struct tdbsam_privates {
2004-02-13 17:48:20 +03:00
TDB_CONTEXT * passwd_tdb ;
2000-10-26 07:31:41 +04:00
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
/* retrive-once info */
const char * tdbsam_location ;
} ;
2000-11-14 02:03:34 +03:00
2004-02-12 00:10:04 +03:00
struct pwent_list {
struct pwent_list * prev , * next ;
TDB_DATA key ;
} ;
static struct pwent_list * tdbsam_pwent_list ;
2001-09-26 00:21:21 +04:00
2004-02-12 08:07:44 +03:00
2004-02-13 17:48:20 +03:00
/**
* Convert old TDBSAM to the latest version .
* @ param pdb_tdb A pointer to the opened TDBSAM file which must be converted .
* This file must be opened with read / write access .
* @ param from Current version of the TDBSAM file .
* @ return True if the conversion has been successful , false otherwise .
* */
static BOOL tdbsam_convert ( TDB_CONTEXT * pdb_tdb , tdbsamver_t from )
2004-02-12 08:07:44 +03:00
{
2004-02-13 17:48:20 +03:00
const char * vstring = TDBSAM_VERSION_STRING ;
SAM_ACCOUNT * user = NULL ;
const char * prefix = USERPREFIX ;
TDB_DATA data , key , old_key ;
uint8 * buf = NULL ;
BOOL ret ;
if ( pdb_tdb = = NULL ) {
DEBUG ( 0 , ( " tdbsam_convert: Bad TDB Context pointer. \n " ) ) ;
return False ;
}
/* handle a Samba upgrade */
tdb_lock_bystring ( pdb_tdb , vstring , 0 ) ;
if ( ! NT_STATUS_IS_OK ( pdb_init_sam ( & user ) ) ) {
DEBUG ( 0 , ( " tdbsam_convert: cannot initialized a SAM_ACCOUNT. \n " ) ) ;
return False ;
}
/* Enumerate all records and convert them */
key = tdb_firstkey ( pdb_tdb ) ;
while ( key . dptr ) {
/* skip all non-USER entries (eg. RIDs) */
while ( ( key . dsize ! = 0 ) & & ( strncmp ( key . dptr , prefix , strlen ( prefix ) ) ) ) {
old_key = key ;
/* increment to next in line */
key = tdb_nextkey ( pdb_tdb , key ) ;
SAFE_FREE ( old_key . dptr ) ;
}
if ( key . dptr ) {
/* read from tdbsam */
data = tdb_fetch ( pdb_tdb , key ) ;
if ( ! data . dptr ) {
DEBUG ( 0 , ( " tdbsam_convert: database entry not found: %s. \n " , key . dptr ) ) ;
return False ;
}
if ( ! NT_STATUS_IS_OK ( pdb_reset_sam ( user ) ) ) {
DEBUG ( 0 , ( " tdbsam_convert: cannot reset SAM_ACCOUNT. \n " ) ) ;
SAFE_FREE ( data . dptr ) ;
return False ;
}
/* unpack the buffer from the former format */
DEBUG ( 10 , ( " tdbsam_convert: Try unpacking a record with (key:%s) (version:%d) \n " , key . dptr , from ) ) ;
switch ( from ) {
case 0 :
ret = init_sam_from_buffer_v0 ( user , ( uint8 * ) data . dptr , data . dsize ) ;
break ;
case 1 :
ret = init_sam_from_buffer_v1 ( user , ( uint8 * ) data . dptr , data . dsize ) ;
break ;
2004-07-08 10:39:22 +04:00
case 2 :
ret = init_sam_from_buffer_v2 ( user , ( uint8 * ) data . dptr , data . dsize ) ;
break ;
2004-02-13 17:48:20 +03:00
default :
/* unknown tdbsam version */
ret = False ;
}
if ( ! ret ) {
DEBUG ( 0 , ( " tdbsam_convert: Bad SAM_ACCOUNT entry returned from TDB (key:%s) (version:%d) \n " , key . dptr , from ) ) ;
SAFE_FREE ( data . dptr ) ;
return False ;
}
2004-07-09 01:01:30 +04:00
/* We're finished with the old data. */
SAFE_FREE ( data . dptr ) ;
2004-02-13 17:48:20 +03:00
/* pack from the buffer into the new format */
DEBUG ( 10 , ( " tdbsam_convert: Try packing a record (key:%s) (version:%d) \n " , key . dptr , from ) ) ;
if ( ( data . dsize = init_buffer_from_sam ( & buf , user , False ) ) = = - 1 ) {
DEBUG ( 0 , ( " tdbsam_convert: cannot pack the SAM_ACCOUNT into the new format \n " ) ) ;
SAFE_FREE ( data . dptr ) ;
return False ;
}
data . dptr = ( char * ) buf ;
/* Store the buffer inside the TDBSAM */
if ( tdb_store ( pdb_tdb , key , data , TDB_MODIFY ) ! = TDB_SUCCESS ) {
DEBUG ( 0 , ( " tdbsam_convert: cannot store the SAM_ACCOUNT (key:%s) in new format \n " , key . dptr ) ) ;
SAFE_FREE ( data . dptr ) ;
return False ;
}
SAFE_FREE ( data . dptr ) ;
/* increment to next in line */
old_key = key ;
key = tdb_nextkey ( pdb_tdb , key ) ;
SAFE_FREE ( old_key . dptr ) ;
}
2004-02-12 08:07:44 +03:00
2004-02-13 17:48:20 +03:00
}
pdb_free_sam ( & user ) ;
/* upgrade finished */
tdb_store_int32 ( pdb_tdb , vstring , TDBSAM_VERSION ) ;
tdb_unlock_bystring ( pdb_tdb , vstring ) ;
return ( True ) ;
}
/**
* Open the TDB passwd database , check version and convert it if needed .
* @ param name filename of the tdbsam file .
* @ param open_flags file access mode .
* @ return a TDB_CONTEXT handle on the tdbsam file .
* */
static TDB_CONTEXT * tdbsam_tdbopen ( const char * name , int open_flags )
{
TDB_CONTEXT * pdb_tdb ;
tdbsamver_t version ;
/* Try to open tdb passwd */
if ( ! ( pdb_tdb = tdb_open_log ( name , 0 , TDB_DEFAULT ,
open_flags , 0600 ) ) ) {
2004-02-12 08:07:44 +03:00
DEBUG ( 0 , ( " Unable to open/create TDB passwd \n " ) ) ;
return NULL ;
}
2004-02-13 17:48:20 +03:00
/* Check the version */
version = ( tdbsamver_t ) tdb_fetch_int32 ( pdb_tdb ,
TDBSAM_VERSION_STRING ) ;
if ( version = = - 1 )
version = 0 ; /* Version not found, assume version 0 */
/* Compare the version */
if ( version > TDBSAM_VERSION ) {
/* Version more recent than the latest known */
DEBUG ( 0 , ( " TDBSAM version unknown: %d \n " , version ) ) ;
tdb_close ( pdb_tdb ) ;
pdb_tdb = NULL ;
}
else if ( version < TDBSAM_VERSION ) {
/* Older version, must be converted */
DEBUG ( 1 , ( " TDBSAM version too old (%d), trying to convert it. \n " , version ) ) ;
/* Reopen the pdb file with read-write access if needed */
if ( ! ( open_flags & O_RDWR ) ) {
DEBUG ( 10 , ( " tdbsam_tdbopen: TDB file opened with read only access, reopen it with read-write access. \n " ) ) ;
tdb_close ( pdb_tdb ) ;
pdb_tdb = tdb_open_log ( name , 0 , TDB_DEFAULT , ( open_flags & 07777770 ) | O_RDWR , 0600 ) ;
}
/* Convert */
if ( ! tdbsam_convert ( pdb_tdb , version ) ) {
DEBUG ( 0 , ( " tdbsam_tdbopen: Error when trying to convert tdbsam: %s \n " , name ) ) ;
tdb_close ( pdb_tdb ) ;
pdb_tdb = NULL ;
} else {
DEBUG ( 1 , ( " TDBSAM converted successfully. \n " ) ) ;
}
/* Reopen the pdb file as it must be */
if ( ! ( open_flags & O_RDWR ) ) {
tdb_close ( pdb_tdb ) ;
pdb_tdb = tdb_open_log ( name , 0 , TDB_DEFAULT , open_flags , 0600 ) ;
}
}
return pdb_tdb ;
2004-02-12 08:07:44 +03:00
}
/*****************************************************************************
2004-02-13 17:48:20 +03:00
Utility functions to close the tdb sam database
2004-02-12 08:07:44 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void tdbsam_tdbclose ( struct tdbsam_privates * state )
{
if ( ! state )
return ;
if ( state - > passwd_tdb ) {
tdb_close ( state - > passwd_tdb ) ;
state - > passwd_tdb = NULL ;
}
return ;
}
2004-02-12 00:10:04 +03:00
/****************************************************************************
creates a list of user keys
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int tdbsam_traverse_setpwent ( TDB_CONTEXT * t , TDB_DATA key , TDB_DATA data , void * state )
2000-10-26 07:31:41 +04:00
{
2004-02-12 00:10:04 +03:00
const char * prefix = USERPREFIX ;
int prefixlen = strlen ( prefix ) ;
struct pwent_list * ptr ;
2000-11-21 08:55:16 +03:00
2004-02-12 00:10:04 +03:00
if ( strncmp ( key . dptr , prefix , prefixlen ) = = 0 ) {
2004-12-07 21:25:53 +03:00
if ( ! ( ptr = SMB_MALLOC_P ( struct pwent_list ) ) ) {
2004-02-12 00:10:04 +03:00
DEBUG ( 0 , ( " tdbsam_traverse_setpwent: Failed to malloc new entry for list \n " ) ) ;
/* just return 0 and let the traversal continue */
return 0 ;
}
ZERO_STRUCTP ( ptr ) ;
/* save a copy of the key */
ptr - > key . dptr = memdup ( key . dptr , key . dsize ) ;
ptr - > key . dsize = key . dsize ;
DLIST_ADD ( tdbsam_pwent_list , ptr ) ;
}
return 0 ;
}
/***************************************************************
Open the TDB passwd database for SAM account enumeration .
Save a list of user keys for iteration .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-01-19 19:13:26 +03:00
static NTSTATUS tdbsam_setsampwent ( struct pdb_methods * my_methods , BOOL update , uint16 acb_mask )
2004-02-12 00:10:04 +03:00
{
2004-02-12 08:07:44 +03:00
uint32 flags = update ? ( O_RDWR | O_CREAT ) : O_RDONLY ;
2004-02-12 00:10:04 +03:00
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
2004-02-12 08:07:44 +03:00
if ( ! ( tdb_state - > passwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , flags ) ) )
2004-02-12 00:10:04 +03:00
return NT_STATUS_UNSUCCESSFUL ;
tdb_traverse ( tdb_state - > passwd_tdb , tdbsam_traverse_setpwent , NULL ) ;
2004-02-12 08:07:44 +03:00
2004-02-12 00:10:04 +03:00
return NT_STATUS_OK ;
}
2000-10-26 07:31:41 +04:00
/***************************************************************
End enumeration of the TDB passwd list .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-07-15 14:35:28 +04:00
static void tdbsam_endsampwent ( struct pdb_methods * my_methods )
2000-10-26 07:31:41 +04:00
{
2002-07-15 14:35:28 +04:00
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
2004-02-12 01:47:12 +03:00
struct pwent_list * ptr , * ptr_next ;
2004-02-12 00:10:04 +03:00
2004-02-12 08:07:44 +03:00
tdbsam_tdbclose ( tdb_state ) ;
2000-11-21 08:55:16 +03:00
2004-02-12 00:10:04 +03:00
/* clear out any remaining entries in the list */
2004-02-12 01:47:12 +03:00
for ( ptr = tdbsam_pwent_list ; ptr ; ptr = ptr_next ) {
ptr_next = ptr - > next ;
2004-02-12 00:10:04 +03:00
DLIST_REMOVE ( tdbsam_pwent_list , ptr ) ;
SAFE_FREE ( ptr - > key . dptr ) ;
SAFE_FREE ( ptr ) ;
}
2001-12-30 22:21:25 +03:00
DEBUG ( 7 , ( " endtdbpwent: closed sam database. \n " ) ) ;
2000-10-26 07:31:41 +04:00
}
2000-11-21 08:55:16 +03:00
/*****************************************************************
Get one SAM_ACCOUNT from the TDB ( next in line )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_getsampwent ( struct pdb_methods * my_methods , SAM_ACCOUNT * user )
2000-10-26 07:31:41 +04:00
{
2004-02-12 00:10:04 +03:00
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL ;
2002-07-15 14:35:28 +04:00
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
2004-02-12 00:10:04 +03:00
TDB_DATA data ;
struct pwent_list * pkey ;
2001-05-04 18:01:33 +04:00
2004-02-12 00:10:04 +03:00
if ( ! user ) {
DEBUG ( 0 , ( " tdbsam_getsampwent: SAM_ACCOUNT is NULL. \n " ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2001-05-04 19:44:27 +04:00
}
2004-02-12 00:10:04 +03:00
if ( ! tdbsam_pwent_list ) {
DEBUG ( 4 , ( " tdbsam_getsampwent: end of list \n " ) ) ;
2004-02-12 08:07:44 +03:00
tdbsam_tdbclose ( tdb_state ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-11-21 08:55:16 +03:00
}
2004-02-12 08:07:44 +03:00
if ( ! tdb_state - > passwd_tdb ) {
if ( ! ( tdb_state - > passwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_RDONLY ) ) )
return nt_status ;
}
2000-10-26 07:31:41 +04:00
2004-02-12 00:10:04 +03:00
/* pull the next entry */
pkey = tdbsam_pwent_list ;
DLIST_REMOVE ( tdbsam_pwent_list , pkey ) ;
data = tdb_fetch ( tdb_state - > passwd_tdb , pkey - > key ) ;
SAFE_FREE ( pkey - > key . dptr ) ;
SAFE_FREE ( pkey ) ;
2001-09-26 00:21:21 +04:00
if ( ! data . dptr ) {
2004-02-12 00:10:04 +03:00
DEBUG ( 5 , ( " pdb_getsampwent: database entry not found. Was the user deleted? \n " ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-11-21 08:55:16 +03:00
}
2000-10-26 07:31:41 +04:00
2003-08-15 05:42:30 +04:00
if ( ! init_sam_from_buffer ( user , ( unsigned char * ) data . dptr , data . dsize ) ) {
2000-11-21 08:55:16 +03:00
DEBUG ( 0 , ( " pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB! \n " ) ) ;
}
2004-02-12 00:10:04 +03:00
SAFE_FREE ( data . dptr ) ;
2003-06-18 16:00:52 +04:00
2002-09-26 22:37:55 +04:00
return NT_STATUS_OK ;
2000-10-26 07:31:41 +04:00
}
2000-11-21 08:55:16 +03:00
/******************************************************************
Lookup a name in the SAM TDB
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_getsampwnam ( struct pdb_methods * my_methods , SAM_ACCOUNT * user , const char * sname )
2000-10-26 07:31:41 +04:00
{
2002-09-26 22:37:55 +04:00
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL ;
2002-07-15 14:35:28 +04:00
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
2000-12-12 19:50:23 +03:00
TDB_CONTEXT * pwd_tdb ;
TDB_DATA data , key ;
fstring keystr ;
fstring name ;
2001-05-04 19:44:27 +04:00
2004-02-12 08:07:44 +03:00
if ( ! user ) {
2001-05-04 19:44:27 +04:00
DEBUG ( 0 , ( " pdb_getsampwnam: SAM_ACCOUNT is NULL. \n " ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2001-05-04 19:44:27 +04:00
}
2004-02-13 17:48:20 +03:00
2001-09-26 15:36:37 +04:00
/* Data is stored in all lower-case */
2003-04-23 04:56:06 +04:00
fstrcpy ( name , sname ) ;
2003-07-03 23:11:31 +04:00
strlower_m ( name ) ;
2001-09-26 15:36:37 +04:00
2000-11-21 08:55:16 +03:00
/* set search key */
2001-04-09 00:31:39 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , USERPREFIX , name ) ;
2000-11-21 08:55:16 +03:00
key . dptr = keystr ;
2001-12-30 22:21:25 +03:00
key . dsize = strlen ( keystr ) + 1 ;
2000-10-26 07:31:41 +04:00
2000-11-21 08:55:16 +03:00
/* open the accounts TDB */
2004-02-12 08:07:44 +03:00
if ( ! ( pwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_RDONLY ) ) ) {
2003-07-21 01:43:41 +04:00
if ( errno = = ENOENT ) {
/*
* TDB file doesn ' t exist , so try to create new one . This is useful to avoid
* confusing error msg when adding user account first time
*/
2006-01-27 03:09:03 +03:00
if ( ( pwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_CREAT | O_RDWR ) ) ! = NULL ) {
2003-07-21 01:43:41 +04:00
DEBUG ( 0 , ( " pdb_getsampwnam: TDB passwd (%s) did not exist. File successfully created. \n " ,
tdb_state - > tdbsam_location ) ) ;
2006-01-28 20:08:24 +03:00
tdb_close ( pwd_tdb ) ;
2003-07-21 01:43:41 +04:00
} else {
DEBUG ( 0 , ( " pdb_getsampwnam: TDB passwd (%s) does not exist. Couldn't create new one. Error was: %s \n " ,
tdb_state - > tdbsam_location , strerror ( errno ) ) ) ;
}
/* requested user isn't there anyway */
nt_status = NT_STATUS_NO_SUCH_USER ;
return nt_status ;
}
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
DEBUG ( 0 , ( " pdb_getsampwnam: Unable to open TDB passwd (%s)! \n " , tdb_state - > tdbsam_location ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-11-21 08:55:16 +03:00
}
2000-10-26 07:31:41 +04:00
2000-11-21 08:55:16 +03:00
/* get the record */
2001-12-30 22:21:25 +03:00
data = tdb_fetch ( pwd_tdb , key ) ;
2001-09-26 00:21:21 +04:00
if ( ! data . dptr ) {
2000-11-21 08:55:16 +03:00
DEBUG ( 5 , ( " pdb_getsampwnam (TDB): error fetching database. \n " ) ) ;
2000-12-06 21:22:29 +03:00
DEBUGADD ( 5 , ( " Error: %s \n " , tdb_errorstr ( pwd_tdb ) ) ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
DEBUGADD ( 5 , ( " Key: %s \n " , keystr ) ) ;
2001-12-30 22:21:25 +03:00
tdb_close ( pwd_tdb ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-10-26 07:31:41 +04:00
}
2000-11-21 08:55:16 +03:00
/* unpack the buffer */
2003-08-15 05:42:30 +04:00
if ( ! init_sam_from_buffer ( user , ( unsigned char * ) data . dptr , data . dsize ) ) {
2000-11-21 08:55:16 +03:00
DEBUG ( 0 , ( " pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB! \n " ) ) ;
2001-09-25 13:58:36 +04:00
SAFE_FREE ( data . dptr ) ;
2001-12-30 22:21:25 +03:00
tdb_close ( pwd_tdb ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-11-21 08:55:16 +03:00
}
2001-09-25 13:58:36 +04:00
SAFE_FREE ( data . dptr ) ;
2001-12-30 22:21:25 +03:00
2001-12-31 18:48:03 +03:00
/* no further use for database, close it now */
2001-12-30 22:21:25 +03:00
tdb_close ( pwd_tdb ) ;
2000-11-21 08:55:16 +03:00
2002-09-26 22:37:55 +04:00
return NT_STATUS_OK ;
2000-10-26 07:31:41 +04:00
}
2000-11-21 08:55:16 +03:00
/***************************************************************************
Search by rid
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_getsampwrid ( struct pdb_methods * my_methods , SAM_ACCOUNT * user , uint32 rid )
2000-10-26 07:31:41 +04:00
{
2002-09-26 22:37:55 +04:00
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL ;
2002-07-15 14:35:28 +04:00
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
2000-12-06 21:22:29 +03:00
TDB_CONTEXT * pwd_tdb ;
TDB_DATA data , key ;
fstring keystr ;
fstring name ;
2001-05-04 19:44:27 +04:00
if ( user = = NULL ) {
DEBUG ( 0 , ( " pdb_getsampwrid: SAM_ACCOUNT is NULL. \n " ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2001-05-04 19:44:27 +04:00
}
2000-12-06 21:22:29 +03:00
/* set search key */
2001-04-09 00:31:39 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%.8x " , RIDPREFIX , rid ) ;
2000-12-06 21:22:29 +03:00
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2000-10-26 07:31:41 +04:00
2000-12-06 21:22:29 +03:00
/* open the accounts TDB */
2004-02-13 17:48:20 +03:00
if ( ! ( pwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_RDONLY ) ) ) {
2000-12-06 21:22:29 +03:00
DEBUG ( 0 , ( " pdb_getsampwrid: Unable to open TDB rid database! \n " ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-12-06 21:22:29 +03:00
}
/* get the record */
data = tdb_fetch ( pwd_tdb , key ) ;
2004-02-13 17:48:20 +03:00
if ( ! data . dptr ) {
2002-01-26 04:52:52 +03:00
DEBUG ( 5 , ( " pdb_getsampwrid (TDB): error looking up RID %d by key %s. \n " , rid , keystr ) ) ;
2000-12-06 21:22:29 +03:00
DEBUGADD ( 5 , ( " Error: %s \n " , tdb_errorstr ( pwd_tdb ) ) ) ;
tdb_close ( pwd_tdb ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-12-06 21:22:29 +03:00
}
2004-02-13 17:48:20 +03:00
2003-05-12 22:12:31 +04:00
fstrcpy ( name , data . dptr ) ;
2001-09-25 13:58:36 +04:00
SAFE_FREE ( data . dptr ) ;
2000-11-21 08:55:16 +03:00
2000-12-06 21:22:29 +03:00
tdb_close ( pwd_tdb ) ;
2002-07-15 14:35:28 +04:00
return tdbsam_getsampwnam ( my_methods , user , name ) ;
}
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_getsampwsid ( struct pdb_methods * my_methods , SAM_ACCOUNT * user , const DOM_SID * sid )
2002-07-15 14:35:28 +04:00
{
uint32 rid ;
if ( ! sid_peek_check_rid ( get_global_sam_sid ( ) , sid , & rid ) )
2002-09-26 22:37:55 +04:00
return NT_STATUS_UNSUCCESSFUL ;
2002-07-15 14:35:28 +04:00
return tdbsam_getsampwrid ( my_methods , user , rid ) ;
2000-10-26 07:31:41 +04:00
}
2005-10-12 00:14:04 +04:00
static BOOL tdb_delete_samacct_only ( TDB_CONTEXT * pwd_tdb ,
struct pdb_methods * my_methods ,
SAM_ACCOUNT * sam_pass )
{
TDB_DATA key ;
fstring keystr ;
fstring name ;
fstrcpy ( name , pdb_get_username ( sam_pass ) ) ;
strlower_m ( name ) ;
/* set the search key */
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , USERPREFIX , name ) ;
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
/* it's outaa here! 8^) */
if ( tdb_delete ( pwd_tdb , key ) ! = TDB_SUCCESS ) {
DEBUG ( 5 , ( " Error deleting entry from tdb passwd database! \n " ) ) ;
DEBUGADD ( 5 , ( " Error: %s \n " , tdb_errorstr ( pwd_tdb ) ) ) ;
tdb_close ( pwd_tdb ) ;
return False ;
}
return True ;
}
2000-11-21 08:55:16 +03:00
/***************************************************************************
Delete a SAM_ACCOUNT
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_delete_sam_account ( struct pdb_methods * my_methods , SAM_ACCOUNT * sam_pass )
2000-10-26 07:31:41 +04:00
{
2002-09-26 22:37:55 +04:00
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL ;
2002-07-15 14:35:28 +04:00
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
2000-11-21 08:55:16 +03:00
TDB_CONTEXT * pwd_tdb ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
TDB_DATA key ;
2000-11-21 08:55:16 +03:00
fstring keystr ;
2000-12-06 21:22:29 +03:00
uint32 rid ;
fstring name ;
2003-04-23 04:56:06 +04:00
fstrcpy ( name , pdb_get_username ( sam_pass ) ) ;
2003-07-03 23:11:31 +04:00
strlower_m ( name ) ;
2000-11-21 08:55:16 +03:00
/* open the TDB */
2004-02-12 08:07:44 +03:00
if ( ! ( pwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_RDWR ) ) ) {
2000-11-21 08:55:16 +03:00
DEBUG ( 0 , ( " Unable to open TDB passwd! " ) ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-11-21 08:55:16 +03:00
}
/* set the search key */
2001-04-09 00:31:39 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , USERPREFIX , name ) ;
2000-11-21 08:55:16 +03:00
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2001-09-25 18:40:25 +04:00
rid = pdb_get_user_rid ( sam_pass ) ;
2000-12-06 21:22:29 +03:00
/* it's outaa here! 8^) */
2001-09-26 00:21:21 +04:00
if ( tdb_delete ( pwd_tdb , key ) ! = TDB_SUCCESS ) {
2000-12-06 21:22:29 +03:00
DEBUG ( 5 , ( " Error deleting entry from tdb passwd database! \n " ) ) ;
DEBUGADD ( 5 , ( " Error: %s \n " , tdb_errorstr ( pwd_tdb ) ) ) ;
tdb_close ( pwd_tdb ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-12-06 21:22:29 +03:00
}
2001-05-04 18:01:33 +04:00
/* delete also the RID key */
2000-12-06 21:22:29 +03:00
/* set the search key */
2001-04-09 00:31:39 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%.8x " , RIDPREFIX , rid ) ;
2000-12-06 21:22:29 +03:00
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
2000-11-21 08:55:16 +03:00
/* it's outaa here! 8^) */
2001-09-26 00:21:21 +04:00
if ( tdb_delete ( pwd_tdb , key ) ! = TDB_SUCCESS ) {
2000-12-06 21:22:29 +03:00
DEBUG ( 5 , ( " Error deleting entry from tdb rid database! \n " ) ) ;
DEBUGADD ( 5 , ( " Error: %s \n " , tdb_errorstr ( pwd_tdb ) ) ) ;
2000-11-21 08:55:16 +03:00
tdb_close ( pwd_tdb ) ;
2002-09-26 22:37:55 +04:00
return nt_status ;
2000-11-21 08:55:16 +03:00
}
tdb_close ( pwd_tdb ) ;
2000-12-06 21:22:29 +03:00
2002-09-26 22:37:55 +04:00
return NT_STATUS_OK ;
2000-10-26 07:31:41 +04:00
}
2005-10-12 00:14:04 +04:00
2000-11-21 08:55:16 +03:00
/***************************************************************************
2005-10-12 00:14:04 +04:00
Update the TDB SAM account record only
2000-11-21 08:55:16 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-10-12 00:14:04 +04:00
static BOOL tdb_update_samacct_only ( TDB_CONTEXT * pwd_tdb ,
struct pdb_methods * my_methods ,
SAM_ACCOUNT * newpwd , int flag )
2000-10-26 07:31:41 +04:00
{
2000-11-21 08:55:16 +03:00
TDB_DATA key , data ;
2001-03-11 03:51:54 +03:00
uint8 * buf = NULL ;
2000-11-21 08:55:16 +03:00
fstring keystr ;
2000-12-06 21:22:29 +03:00
fstring name ;
2001-09-25 13:58:36 +04:00
BOOL ret = True ;
2003-07-11 19:17:06 +04:00
2000-11-21 08:55:16 +03:00
/* copy the SAM_ACCOUNT struct into a BYTE buffer for storage */
2003-07-09 01:58:29 +04:00
if ( ( data . dsize = init_buffer_from_sam ( & buf , newpwd , False ) ) = = - 1 ) {
2000-11-21 08:55:16 +03:00
DEBUG ( 0 , ( " tdb_update_sam: ERROR - Unable to copy SAM_ACCOUNT info BYTE buffer! \n " ) ) ;
2001-09-25 13:58:36 +04:00
ret = False ;
goto done ;
2000-11-21 08:55:16 +03:00
}
2003-08-15 05:42:30 +04:00
data . dptr = ( char * ) buf ;
2000-10-26 07:31:41 +04:00
2003-04-23 04:56:06 +04:00
fstrcpy ( name , pdb_get_username ( newpwd ) ) ;
2003-07-03 23:11:31 +04:00
strlower_m ( name ) ;
2000-12-06 21:22:29 +03:00
2005-10-12 00:14:04 +04:00
DEBUG ( 5 , ( " Storing %saccount %s with RID %d \n " ,
flag = = TDB_INSERT ? " (new) " : " " , name ,
pdb_get_user_rid ( newpwd ) ) ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
2000-12-06 21:22:29 +03:00
/* setup the USER index key */
2001-04-09 00:31:39 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%s " , USERPREFIX , name ) ;
2000-11-21 08:55:16 +03:00
key . dptr = keystr ;
2003-05-12 22:12:31 +04:00
key . dsize = strlen ( keystr ) + 1 ;
2000-11-21 08:55:16 +03:00
/* add the account */
2001-09-26 00:21:21 +04:00
if ( tdb_store ( pwd_tdb , key , data , flag ) ! = TDB_SUCCESS ) {
2001-05-04 18:01:33 +04:00
DEBUG ( 0 , ( " Unable to modify passwd TDB! " ) ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
DEBUGADD ( 0 , ( " Error: %s " , tdb_errorstr ( pwd_tdb ) ) ) ;
2005-10-12 00:14:04 +04:00
DEBUGADD ( 0 , ( " occured while storing the main record (%s) \n " ,
keystr ) ) ;
2001-09-25 13:58:36 +04:00
ret = False ;
goto done ;
2000-11-21 08:55:16 +03:00
}
2005-10-12 00:14:04 +04:00
done :
/* cleanup */
SAFE_FREE ( buf ) ;
2000-12-06 21:22:29 +03:00
2005-10-12 00:14:04 +04:00
return ( ret ) ;
}
/***************************************************************************
Update the TDB SAM RID record only
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static BOOL tdb_update_ridrec_only ( TDB_CONTEXT * pwd_tdb ,
struct pdb_methods * my_methods ,
SAM_ACCOUNT * newpwd , int flag )
{
TDB_DATA key , data ;
fstring keystr ;
fstring name ;
fstrcpy ( name , pdb_get_username ( newpwd ) ) ;
strlower_m ( name ) ;
2000-12-12 19:50:23 +03:00
/* setup RID data */
2003-05-12 22:12:31 +04:00
data . dsize = strlen ( name ) + 1 ;
2000-12-06 21:22:29 +03:00
data . dptr = name ;
2000-11-21 08:55:16 +03:00
2000-12-06 21:22:29 +03:00
/* setup the RID index key */
2005-10-12 00:14:04 +04:00
slprintf ( keystr , sizeof ( keystr ) - 1 , " %s%.8x " , RIDPREFIX ,
pdb_get_user_rid ( newpwd ) ) ;
2000-12-06 21:22:29 +03:00
key . dptr = keystr ;
key . dsize = strlen ( keystr ) + 1 ;
/* add the reference */
2001-09-26 00:21:21 +04:00
if ( tdb_store ( pwd_tdb , key , data , flag ) ! = TDB_SUCCESS ) {
2001-05-04 18:01:33 +04:00
DEBUG ( 0 , ( " Unable to modify TDB passwd ! " ) ) ;
2000-12-06 21:22:29 +03:00
DEBUGADD ( 0 , ( " Error: %s \n " , tdb_errorstr ( pwd_tdb ) ) ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
DEBUGADD ( 0 , ( " occured while storing the RID index (%s) \n " , keystr ) ) ;
2005-10-12 00:14:04 +04:00
return False ;
}
return True ;
}
/***************************************************************************
Update the TDB SAM
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static BOOL tdb_update_sam ( struct pdb_methods * my_methods , SAM_ACCOUNT * newpwd , int flag )
{
struct tdbsam_privates * tdb_state = ( struct tdbsam_privates * ) my_methods - > private_data ;
TDB_CONTEXT * pwd_tdb = NULL ;
BOOL ret = True ;
uint32 user_rid ;
/* invalidate the existing TDB iterator if it is open */
if ( tdb_state - > passwd_tdb ) {
tdb_close ( tdb_state - > passwd_tdb ) ;
tdb_state - > passwd_tdb = NULL ;
}
/* open the account TDB passwd*/
pwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_RDWR | O_CREAT ) ;
if ( ! pwd_tdb ) {
DEBUG ( 0 , ( " tdb_update_sam: Unable to open TDB passwd (%s)! \n " ,
tdb_state - > tdbsam_location ) ) ;
return False ;
}
if ( ! pdb_get_group_rid ( newpwd ) ) {
DEBUG ( 0 , ( " tdb_update_sam: Failing to store a SAM_ACCOUNT for [%s] without a primary group RID \n " ,
pdb_get_username ( newpwd ) ) ) ;
ret = False ;
goto done ;
}
if ( ! ( user_rid = pdb_get_user_rid ( newpwd ) ) ) {
DEBUG ( 0 , ( " tdb_update_sam: SAM_ACCOUNT (%s) with no RID! \n " , pdb_get_username ( newpwd ) ) ) ;
ret = False ;
goto done ;
}
if ( ! tdb_update_samacct_only ( pwd_tdb , my_methods , newpwd , flag ) | |
! tdb_update_ridrec_only ( pwd_tdb , my_methods , newpwd , flag ) ) {
2001-09-25 13:58:36 +04:00
ret = False ;
goto done ;
2000-12-06 21:22:29 +03:00
}
2001-09-25 13:58:36 +04:00
done :
2000-12-06 21:22:29 +03:00
/* cleanup */
tdb_close ( pwd_tdb ) ;
2001-09-27 06:05:30 +04:00
return ( ret ) ;
2000-10-26 07:31:41 +04:00
}
2000-11-21 08:55:16 +03:00
/***************************************************************************
Modifies an existing SAM_ACCOUNT
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_update_sam_account ( struct pdb_methods * my_methods , SAM_ACCOUNT * newpwd )
2000-10-26 07:31:41 +04:00
{
2002-09-26 22:37:55 +04:00
if ( tdb_update_sam ( my_methods , newpwd , TDB_MODIFY ) )
return NT_STATUS_OK ;
else
return NT_STATUS_UNSUCCESSFUL ;
2000-10-26 07:31:41 +04:00
}
2000-11-21 08:55:16 +03:00
/***************************************************************************
Adds an existing SAM_ACCOUNT
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-26 00:21:21 +04:00
2002-09-26 22:37:55 +04:00
static NTSTATUS tdbsam_add_sam_account ( struct pdb_methods * my_methods , SAM_ACCOUNT * newpwd )
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
{
2002-09-26 22:37:55 +04:00
if ( tdb_update_sam ( my_methods , newpwd , TDB_INSERT ) )
return NT_STATUS_OK ;
else
return NT_STATUS_UNSUCCESSFUL ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
}
2005-10-12 00:14:04 +04:00
/***************************************************************************
Renames a SAM_ACCOUNT
- check for the posix user / rename user script
- Add and lock the new user record
- rename the posix user
- rewrite the rid - > username record
- delete the old user
- unlock the new user record
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS tdbsam_rename_sam_account ( struct pdb_methods * my_methods ,
2005-10-21 00:40:47 +04:00
SAM_ACCOUNT * old_acct ,
const char * newname )
2005-10-12 00:14:04 +04:00
{
struct tdbsam_privates * tdb_state =
( struct tdbsam_privates * ) my_methods - > private_data ;
SAM_ACCOUNT * new_acct = NULL ;
pstring rename_script ;
TDB_CONTEXT * pwd_tdb = NULL ;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL ;
BOOL interim_account = False ;
if ( ! * ( lp_renameuser_script ( ) ) )
goto done ;
2005-10-21 00:40:47 +04:00
if ( ! pdb_copy_sam_account ( old_acct , & new_acct ) | |
2005-10-12 00:14:04 +04:00
! pdb_set_username ( new_acct , newname , PDB_CHANGED ) )
goto done ;
/* invalidate the existing TDB iterator if it is open */
if ( tdb_state - > passwd_tdb ) {
tdb_close ( tdb_state - > passwd_tdb ) ;
tdb_state - > passwd_tdb = NULL ;
}
/* open the account TDB passwd */
pwd_tdb = tdbsam_tdbopen ( tdb_state - > tdbsam_location , O_RDWR | O_CREAT ) ;
if ( ! pwd_tdb ) {
DEBUG ( 0 , ( " tdb_update_sam: Unable to open TDB passwd (%s)! \n " ,
tdb_state - > tdbsam_location ) ) ;
goto done ;
}
/* add the new account and lock it */
if ( ! tdb_update_samacct_only ( pwd_tdb , my_methods , new_acct ,
TDB_INSERT ) )
goto done ;
interim_account = True ;
if ( tdb_lock_bystring ( pwd_tdb , newname , 30 ) = = - 1 ) {
goto done ;
}
/* rename the posix user */
pstrcpy ( rename_script , lp_renameuser_script ( ) ) ;
if ( * rename_script ) {
int rename_ret ;
pstring_sub ( rename_script , " %unew " , newname ) ;
2005-10-21 00:40:47 +04:00
pstring_sub ( rename_script , " %uold " ,
pdb_get_username ( old_acct ) ) ;
2005-10-12 00:14:04 +04:00
rename_ret = smbrun ( rename_script , NULL ) ;
DEBUG ( rename_ret ? 0 : 3 , ( " Running the command `%s' gave %d \n " , rename_script , rename_ret ) ) ;
if ( rename_ret )
goto done ;
} else {
goto done ;
}
/* rewrite the rid->username record */
if ( ! tdb_update_ridrec_only ( pwd_tdb , my_methods , new_acct , TDB_MODIFY ) )
goto done ;
interim_account = False ;
tdb_unlock_bystring ( pwd_tdb , newname ) ;
2005-10-21 00:40:47 +04:00
tdb_delete_samacct_only ( pwd_tdb , my_methods , old_acct ) ;
2005-10-12 00:14:04 +04:00
ret = NT_STATUS_OK ;
done :
/* cleanup */
if ( interim_account ) {
tdb_unlock_bystring ( pwd_tdb , newname ) ;
tdb_delete_samacct_only ( pwd_tdb , my_methods , new_acct ) ;
}
if ( pwd_tdb )
tdb_close ( pwd_tdb ) ;
if ( new_acct )
pdb_free_sam ( & new_acct ) ;
return ( ret ) ;
}
2006-02-04 01:19:41 +03:00
static BOOL tdbsam_rid_algorithm ( struct pdb_methods * methods )
{
return False ;
}
/*
* Historically , winbind was responsible for allocating RIDs , so the next RID
* value was stored in winbindd_idmap . tdb . It has been moved to passdb now ,
* but for compatibility reasons we still keep the the next RID counter in
* winbindd_idmap . tdb .
*/
/*****************************************************************************
Initialise idmap database . For now ( Dec 2005 ) this is a copy of the code in
sam / idmap_tdb . c . Maybe at a later stage we can remove that capability from
winbind completely and store the RID counter in passdb . tdb .
Dont ' fully initialize with the HWM values , if it ' s new , we ' re only
interested in the RID counter .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static BOOL init_idmap_tdb ( TDB_CONTEXT * tdb )
{
int32 version ;
if ( tdb_lock_bystring ( tdb , " IDMAP_VERSION " , 0 ) ! = 0 ) {
DEBUG ( 0 , ( " Could not lock IDMAP_VERSION \n " ) ) ;
return False ;
}
version = tdb_fetch_int32 ( tdb , " IDMAP_VERSION " ) ;
if ( version = = - 1 ) {
/* No key found, must be a new db */
if ( tdb_store_int32 ( tdb , " IDMAP_VERSION " ,
IDMAP_VERSION ) ! = 0 ) {
DEBUG ( 0 , ( " Could not store IDMAP_VERSION \n " ) ) ;
tdb_unlock_bystring ( tdb , " IDMAP_VERSION " ) ;
return False ;
}
version = IDMAP_VERSION ;
}
if ( version ! = IDMAP_VERSION ) {
DEBUG ( 0 , ( " Expected IDMAP_VERSION=%d, found %d. Please "
" start winbind once \n " , IDMAP_VERSION , version ) ) ;
tdb_unlock_bystring ( tdb , " IDMAP_VERSION " ) ;
return False ;
}
tdb_unlock_bystring ( tdb , " IDMAP_VERSION " ) ;
return True ;
}
static BOOL tdbsam_new_rid ( struct pdb_methods * methods , uint32 * prid )
{
TDB_CONTEXT * tdb ;
uint32 rid ;
BOOL ret = False ;
tdb = tdb_open_log ( lock_path ( " winbindd_idmap.tdb " ) , 0 ,
TDB_DEFAULT , O_RDWR | O_CREAT , 0644 ) ;
if ( tdb = = NULL ) {
DEBUG ( 1 , ( " Could not open idmap: %s \n " , strerror ( errno ) ) ) ;
goto done ;
}
if ( ! init_idmap_tdb ( tdb ) ) {
DEBUG ( 1 , ( " Could not init idmap \n " ) ) ;
goto done ;
}
rid = BASE_RID ; /* Default if not set */
if ( ! tdb_change_uint32_atomic ( tdb , " RID_COUNTER " , & rid , 1 ) ) {
DEBUG ( 3 , ( " tdbsam_new_rid: Failed to increase RID_COUNTER \n " ) ) ;
goto done ;
}
* prid = rid ;
ret = True ;
done :
if ( ( tdb ! = NULL ) & & ( tdb_close ( tdb ) ! = 0 ) ) {
smb_panic ( " tdb_close(idmap_tdb) failed \n " ) ;
}
return ret ;
}
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
static void free_private_data ( void * * vp )
2000-10-26 07:31:41 +04:00
{
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
struct tdbsam_privates * * tdb_state = ( struct tdbsam_privates * * ) vp ;
2004-02-12 08:07:44 +03:00
tdbsam_tdbclose ( * tdb_state ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
* tdb_state = NULL ;
/* No need to free any further, as it is talloc()ed */
2000-10-26 07:31:41 +04:00
}
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
2005-01-13 21:20:37 +03:00
/**
* Init tdbsam backend
*
* @ param pdb_context initialised passdb context
* @ param pdb_method backend methods structure to be filled with function pointers
* @ param location the backend tdb file location
*
* @ return nt_status code
* */
2003-06-17 14:48:06 +04:00
static NTSTATUS pdb_init_tdbsam ( PDB_CONTEXT * pdb_context , PDB_METHODS * * pdb_method , const char * location )
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
{
NTSTATUS nt_status ;
struct tdbsam_privates * tdb_state ;
2002-07-15 14:35:28 +04:00
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status = make_pdb_methods ( pdb_context - > mem_ctx , pdb_method ) ) ) {
return nt_status ;
}
2002-01-25 14:44:15 +03:00
( * pdb_method ) - > name = " tdbsam " ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
( * pdb_method ) - > setsampwent = tdbsam_setsampwent ;
( * pdb_method ) - > endsampwent = tdbsam_endsampwent ;
( * pdb_method ) - > getsampwent = tdbsam_getsampwent ;
( * pdb_method ) - > getsampwnam = tdbsam_getsampwnam ;
2002-07-15 14:35:28 +04:00
( * pdb_method ) - > getsampwsid = tdbsam_getsampwsid ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
( * pdb_method ) - > add_sam_account = tdbsam_add_sam_account ;
( * pdb_method ) - > update_sam_account = tdbsam_update_sam_account ;
( * pdb_method ) - > delete_sam_account = tdbsam_delete_sam_account ;
2005-10-12 00:14:04 +04:00
( * pdb_method ) - > rename_sam_account = tdbsam_rename_sam_account ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
2006-02-04 01:19:41 +03:00
( * pdb_method ) - > rid_algorithm = tdbsam_rid_algorithm ;
( * pdb_method ) - > new_rid = tdbsam_new_rid ;
2004-12-07 21:25:53 +03:00
tdb_state = TALLOC_ZERO_P ( pdb_context - > mem_ctx , struct tdbsam_privates ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
if ( ! tdb_state ) {
DEBUG ( 0 , ( " talloc() failed for tdbsam private_data! \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
if ( location ) {
tdb_state - > tdbsam_location = talloc_strdup ( pdb_context - > mem_ctx , location ) ;
} else {
pstring tdbfile ;
get_private_directory ( tdbfile ) ;
2002-02-02 02:20:08 +03:00
pstrcat ( tdbfile , " / " ) ;
pstrcat ( tdbfile , PASSDB_FILE_NAME ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
tdb_state - > tdbsam_location = talloc_strdup ( pdb_context - > mem_ctx , tdbfile ) ;
}
( * pdb_method ) - > private_data = tdb_state ;
( * pdb_method ) - > free_private_data = free_private_data ;
return NT_STATUS_OK ;
}
2003-06-17 14:38:22 +04:00
NTSTATUS pdb_tdbsam_init ( void )
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
{
2003-06-17 14:38:22 +04:00
return smb_register_passdb ( PASSDB_INTERFACE_VERSION , " tdbsam " , pdb_init_tdbsam ) ;
This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem. In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.
This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime. The 'passdb backend' paramater
has been created (and documented!) to support this.
As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.
This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.
While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly). Most of this was
to do with % macro expansion on stored data. It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them. tdbsam needs
to use a similar system to pdb_ldap in this regard.
This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these. I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.
Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.
The non-unix-account support in this patch has been proven! It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!
Other changes:
Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.
pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend). Extra checks have been added in
some places.
Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.
pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.
The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly. This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.
Doco:
I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
(This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b)
2002-01-20 17:30:58 +03:00
}