2010-01-12 19:05:16 +03:00
/*
2003-08-13 05:53:07 +04:00
Unix SMB / CIFS implementation .
Standardised Authentication types
2005-01-09 15:55:25 +03:00
Copyright ( C ) Andrew Bartlett 2001
Copyright ( C ) Stefan Metzmacher 2005
2010-01-12 19:05:16 +03:00
2003-08-13 05:53:07 +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
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +04:00
( at your option ) any later version .
2010-01-12 19:05:16 +03:00
2003-08-13 05:53:07 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-01-12 19:05:16 +03:00
2003-08-13 05:53:07 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
2004-02-03 14:10:56 +03:00
# ifndef _SAMBA_AUTH_H
# define _SAMBA_AUTH_H
2008-08-28 10:28:47 +04:00
# include "librpc/gen_ndr/ndr_krb5pac.h"
2011-02-08 08:39:34 +03:00
# include "librpc/gen_ndr/auth.h"
2010-05-04 10:44:08 +04:00
# include "../auth/common_auth.h"
2008-08-28 10:28:47 +04:00
2009-07-16 11:37:36 +04:00
extern const char * krbtgt_attrs [ ] ;
extern const char * server_attrs [ ] ;
2007-07-27 10:31:12 +04:00
extern const char * user_attrs [ ] ;
2006-11-07 03:48:36 +03:00
union netr_Validation ;
2006-11-07 15:42:51 +03:00
struct netr_SamBaseInfo ;
struct netr_SamInfo3 ;
2007-12-02 18:20:18 +03:00
struct loadparm_context ;
2004-11-02 05:57:18 +03:00
2004-02-03 14:10:56 +03:00
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
* with a comment and maybe update struct auth_critical_sizes .
*/
/* version 1 - version from samba 3.0 - metze */
/* version 2 - initial samba4 version - metze */
2004-05-02 12:45:00 +04:00
/* version 3 - subsequent samba4 version - abartlet */
2005-01-09 15:55:25 +03:00
/* version 4 - subsequent samba4 version - metze */
2006-07-27 15:24:18 +04:00
/* version 0 - till samba4 is stable - metze */
2011-05-07 10:14:06 +04:00
# define AUTH4_INTERFACE_VERSION 0
2003-08-13 05:53:07 +04:00
2005-01-09 15:55:25 +03:00
struct auth_method_context ;
2006-07-27 17:02:27 +04:00
struct auth_check_password_request ;
2011-05-07 10:14:06 +04:00
struct auth4_context ;
2010-04-13 06:00:06 +04:00
struct auth_session_info ;
2010-04-15 05:58:05 +04:00
struct ldb_dn ;
2011-12-28 10:48:45 +04:00
struct smb_krb5_context ;
2003-08-13 05:53:07 +04:00
2005-01-09 15:55:25 +03:00
struct auth_operations {
const char * name ;
2003-12-14 13:45:50 +03:00
2006-07-27 15:24:18 +04:00
/* Given the user supplied info, check if this backend want to handle the password checking */
NTSTATUS ( * want_check ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ) ;
2005-04-27 04:48:39 +04:00
/* Given the user supplied info, check a password */
2005-01-09 15:55:25 +03:00
NTSTATUS ( * check_password ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ,
2011-02-08 08:53:13 +03:00
struct auth_user_info_dc * * interim_info ) ;
/* Lookup a 'session info interim' return based only on the principal or DN */
NTSTATUS ( * get_user_info_dc_principal ) ( TALLOC_CTX * mem_ctx ,
2011-05-07 10:14:06 +04:00
struct auth4_context * auth_context ,
2011-02-08 08:53:13 +03:00
const char * principal ,
struct ldb_dn * user_dn ,
struct auth_user_info_dc * * interim_info ) ;
2014-03-27 03:58:05 +04:00
uint32_t flags ;
2003-08-13 05:53:07 +04:00
} ;
2005-01-09 15:55:25 +03:00
struct auth_method_context {
struct auth_method_context * prev , * next ;
2011-05-07 10:14:06 +04:00
struct auth4_context * auth_ctx ;
2005-01-09 15:55:25 +03:00
const struct auth_operations * ops ;
int depth ;
2003-08-13 05:53:07 +04:00
void * private_data ;
2005-01-09 15:55:25 +03:00
} ;
2003-08-13 05:53:07 +04:00
2004-02-03 14:10:56 +03:00
/* this structure is used by backends to determine the size of some critical types */
struct auth_critical_sizes {
int interface_version ;
int sizeof_auth_operations ;
int sizeof_auth_methods ;
int sizeof_auth_context ;
int sizeof_auth_usersupplied_info ;
2011-02-08 08:53:13 +03:00
int sizeof_auth_user_info_dc ;
2004-02-03 14:10:56 +03:00
} ;
2011-05-07 10:14:06 +04:00
NTSTATUS encrypt_user_info ( TALLOC_CTX * mem_ctx , struct auth4_context * auth_context ,
2005-07-22 08:10:07 +04:00
enum auth_password_state to_state ,
const struct auth_usersupplied_info * user_info_in ,
const struct auth_usersupplied_info * * user_info_encrypted ) ;
2007-11-26 04:25:20 +03:00
# include "auth/session.h"
2011-07-21 11:06:17 +04:00
# include "auth/unix_token_proto.h"
2007-11-26 04:25:20 +03:00
# include "auth/system_session_proto.h"
2011-03-14 18:01:47 +03:00
# include "libcli/security/security.h"
2008-04-02 06:53:27 +04:00
struct ldb_message ;
struct ldb_context ;
2009-02-13 02:24:16 +03:00
struct gensec_security ;
2011-02-10 12:21:11 +03:00
struct cli_credentials ;
2009-02-13 02:24:16 +03:00
2011-05-07 10:14:06 +04:00
NTSTATUS auth_get_challenge ( struct auth4_context * auth_ctx , uint8_t chal [ 8 ] ) ;
2008-04-02 06:53:27 +04:00
NTSTATUS authsam_account_ok ( TALLOC_CTX * mem_ctx ,
struct ldb_context * sam_ctx ,
uint32_t logon_parameters ,
2009-05-26 06:31:39 +04:00
struct ldb_dn * domain_dn ,
2008-04-02 06:53:27 +04:00
struct ldb_message * msg ,
const char * logon_workstation ,
2008-12-04 17:09:21 +03:00
const char * name_for_logs ,
2009-06-18 05:08:46 +04:00
bool allow_domain_trust ,
bool password_change ) ;
2011-05-06 18:49:38 +04:00
2010-04-13 16:11:26 +04:00
struct auth_session_info * system_session ( struct loadparm_context * lp_ctx ) ;
2011-02-08 08:53:13 +03:00
NTSTATUS authsam_make_user_info_dc ( TALLOC_CTX * mem_ctx , struct ldb_context * sam_ctx ,
2008-04-02 06:53:27 +04:00
const char * netbios_name ,
2009-05-26 06:31:39 +04:00
const char * domain_name ,
2016-01-07 16:55:07 +03:00
const char * dns_domain_name ,
2010-01-12 19:05:16 +03:00
struct ldb_dn * domain_dn ,
2008-04-02 06:53:27 +04:00
struct ldb_message * msg ,
DATA_BLOB user_sess_key , DATA_BLOB lm_sess_key ,
2011-02-08 08:53:13 +03:00
struct auth_user_info_dc * * _user_info_dc ) ;
2010-01-12 19:05:16 +03:00
NTSTATUS auth_system_session_info ( TALLOC_CTX * parent_ctx ,
2008-04-02 06:53:27 +04:00
struct loadparm_context * lp_ctx ,
struct auth_session_info * * _session_info ) ;
2014-05-16 06:29:43 +04:00
NTSTATUS auth_context_create_methods ( TALLOC_CTX * mem_ctx , const char * const * methods ,
2008-12-29 22:24:57 +03:00
struct tevent_context * ev ,
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg ,
2008-04-02 06:53:27 +04:00
struct loadparm_context * lp_ctx ,
2010-04-15 05:58:05 +04:00
struct ldb_context * sam_ctx ,
2011-05-07 10:14:06 +04:00
struct auth4_context * * auth_ctx ) ;
2011-01-18 11:13:19 +03:00
const char * * auth_methods_from_lp ( TALLOC_CTX * mem_ctx , struct loadparm_context * lp_ctx ) ;
2008-04-02 06:53:27 +04:00
2010-01-12 19:05:16 +03:00
NTSTATUS auth_context_create ( TALLOC_CTX * mem_ctx ,
2008-12-29 22:24:57 +03:00
struct tevent_context * ev ,
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg ,
2008-04-02 06:53:27 +04:00
struct loadparm_context * lp_ctx ,
2011-05-07 10:14:06 +04:00
struct auth4_context * * auth_ctx ) ;
2008-04-02 06:53:27 +04:00
2012-01-30 04:17:44 +04:00
NTSTATUS auth_check_password_wrapper ( struct auth4_context * auth_ctx ,
TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ,
void * * server_returned_info ,
DATA_BLOB * user_session_key , DATA_BLOB * lm_session_key ) ;
2011-05-07 10:14:06 +04:00
NTSTATUS auth_check_password ( struct auth4_context * auth_ctx ,
2008-04-02 06:53:27 +04:00
TALLOC_CTX * mem_ctx ,
2012-01-30 04:17:44 +04:00
const struct auth_usersupplied_info * user_info ,
2011-02-08 08:53:13 +03:00
struct auth_user_info_dc * * user_info_dc ) ;
2011-02-15 08:30:35 +03:00
NTSTATUS auth4_init ( void ) ;
2008-04-02 06:53:27 +04:00
NTSTATUS auth_register ( const struct auth_operations * ops ) ;
2010-04-16 02:42:12 +04:00
NTSTATUS server_service_auth_init ( void ) ;
2008-04-02 06:53:27 +04:00
NTSTATUS authenticate_username_pw ( TALLOC_CTX * mem_ctx ,
2010-11-05 01:00:13 +03:00
struct tevent_context * ev ,
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg ,
2010-11-05 01:00:13 +03:00
struct loadparm_context * lp_ctx ,
const char * nt4_domain ,
const char * nt4_username ,
const char * password ,
const uint32_t logon_parameters ,
struct auth_session_info * * session_info ) ;
2009-12-23 11:09:37 +03:00
struct tevent_req * auth_check_password_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
2011-05-07 10:14:06 +04:00
struct auth4_context * auth_ctx ,
2009-12-23 11:09:37 +03:00
const struct auth_usersupplied_info * user_info ) ;
NTSTATUS auth_check_password_recv ( struct tevent_req * req ,
2008-04-02 06:53:27 +04:00
TALLOC_CTX * mem_ctx ,
2011-02-08 08:53:13 +03:00
struct auth_user_info_dc * * user_info_dc ) ;
2008-04-02 06:53:27 +04:00
2011-05-07 10:14:06 +04:00
bool auth_challenge_may_be_modified ( struct auth4_context * auth_ctx ) ;
NTSTATUS auth_context_set_challenge ( struct auth4_context * auth_ctx , const uint8_t chal [ 8 ] , const char * set_by ) ;
2005-07-22 08:10:07 +04:00
2011-02-08 08:53:13 +03:00
NTSTATUS auth_get_user_info_dc_principal ( TALLOC_CTX * mem_ctx ,
2011-05-07 10:14:06 +04:00
struct auth4_context * auth_ctx ,
2009-12-29 13:50:46 +03:00
const char * principal ,
2010-04-15 05:58:05 +04:00
struct ldb_dn * user_dn ,
2011-02-08 08:53:13 +03:00
struct auth_user_info_dc * * user_info_dc ) ;
2009-12-29 13:50:46 +03:00
2009-02-13 02:24:16 +03:00
NTSTATUS samba_server_gensec_start ( TALLOC_CTX * mem_ctx ,
struct tevent_context * event_ctx ,
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg_ctx ,
2009-02-13 02:24:16 +03:00
struct loadparm_context * lp_ctx ,
struct cli_credentials * server_credentials ,
const char * target_service ,
struct gensec_security * * gensec_context ) ;
2004-05-02 12:45:00 +04:00
# endif /* _SMBAUTH_H_ */