2005-09-29 04:02:38 +04:00
/*
Unix SMB / CIFS implementation .
User credentials handling ( as regards on - disk files )
Copyright ( C ) Jelmer Vernooij 2005
Copyright ( C ) Tim Potter 2001
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2005
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
2005-09-29 04:02:38 +04:00
( 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
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-09-29 04:02:38 +04:00
*/
# include "includes.h"
2008-06-14 19:24:17 +04:00
# include "lib/events/events.h"
2011-02-10 06:12:51 +03:00
# include <ldb.h>
2006-03-16 03:23:11 +03:00
# include "librpc/gen_ndr/samr.h" /* for struct samrPassword */
2006-11-06 19:11:52 +03:00
# include "param/secrets.h"
2005-09-29 04:02:38 +04:00
# include "system/filesys.h"
2006-03-14 04:29:56 +03:00
# include "auth/credentials/credentials.h"
2011-03-19 02:44:56 +03:00
# include "auth/credentials/credentials_proto.h"
2006-11-07 03:48:36 +03:00
# include "auth/credentials/credentials_krb5.h"
2010-10-11 06:05:37 +04:00
# include "auth/kerberos/kerberos_util.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2008-04-17 03:03:18 +04:00
# include "lib/events/events.h"
2009-10-28 08:49:30 +03:00
# include "dsdb/samdb/samdb.h"
2012-07-14 16:23:41 +04:00
# include "source3/include/secrets.h"
# include "dbwrap/dbwrap.h"
# include "dbwrap/dbwrap_open.h"
# include "lib/util/util_tdb.h"
2009-10-28 08:49:30 +03:00
2005-09-29 04:02:38 +04:00
/**
* Fill in credentials for the machine trust account , from the secrets database .
*
* @ param cred Credentials structure to fill in
* @ retval NTSTATUS error detailing any failure
*/
2008-04-02 06:53:27 +04:00
_PUBLIC_ NTSTATUS cli_credentials_set_secrets ( struct cli_credentials * cred ,
2010-02-20 03:44:41 +03:00
struct loadparm_context * lp_ctx ,
struct ldb_context * ldb ,
const char * base ,
const char * filter ,
char * * error_string )
2005-09-29 04:02:38 +04:00
{
TALLOC_CTX * mem_ctx ;
int ldb_ret ;
2010-02-20 03:44:41 +03:00
struct ldb_message * msg ;
2005-09-29 04:02:38 +04:00
const char * machine_account ;
const char * password ;
const char * domain ;
const char * realm ;
enum netr_SchannelType sct ;
2005-10-20 14:28:16 +04:00
const char * salt_principal ;
2010-09-23 11:01:44 +04:00
char * keytab ;
2010-05-17 07:41:01 +04:00
const struct ldb_val * whenChanged ;
2005-09-29 04:02:38 +04:00
/* ok, we are going to get it now, don't recurse back here */
2007-10-07 02:16:19 +04:00
cred - > machine_account_pending = false ;
2005-09-29 04:02:38 +04:00
2005-10-31 03:23:38 +03:00
/* some other parts of the system will key off this */
2007-10-07 02:16:19 +04:00
cred - > machine_account = true ;
2005-10-31 03:23:38 +03:00
2005-09-29 04:02:38 +04:00
mem_ctx = talloc_named ( cred , 0 , " cli_credentials fetch machine password " ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
2005-09-29 04:02:38 +04:00
if ( ! ldb ) {
2007-02-04 10:17:03 +03:00
/* Local secrets are stored in secrets.ldb */
2010-10-11 09:43:07 +04:00
ldb = secrets_db_connect ( mem_ctx , lp_ctx ) ;
2007-02-04 10:17:03 +03:00
if ( ! ldb ) {
/* set anonymous as the fallback, if the machine account won't work */
cli_credentials_set_anonymous ( cred ) ;
2010-02-20 03:44:41 +03:00
* error_string = talloc_strdup ( cred , " Could not open secrets.ldb " ) ;
2008-07-15 09:05:41 +04:00
talloc_free ( mem_ctx ) ;
2007-02-04 10:17:03 +03:00
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
}
2005-09-29 04:02:38 +04:00
}
2010-10-12 03:05:32 +04:00
ldb_ret = dsdb_search_one ( ldb , mem_ctx , & msg ,
2010-02-20 03:44:41 +03:00
ldb_dn_new ( mem_ctx , ldb , base ) ,
LDB_SCOPE_SUBTREE ,
2010-07-28 11:30:09 +04:00
NULL , 0 , " %s " , filter ) ;
2010-02-20 03:44:41 +03:00
if ( ldb_ret ! = LDB_SUCCESS ) {
* error_string = talloc_asprintf ( cred , " Could not find entry to match filter: '%s' base: '%s': %s: %s \n " ,
filter , base ? base : " " ,
ldb_strerror ( ldb_ret ) , ldb_errstring ( ldb ) ) ;
2005-12-14 10:22:25 +03:00
/* set anonymous as the fallback, if the machine account won't work */
cli_credentials_set_anonymous ( cred ) ;
2005-09-29 04:02:38 +04:00
talloc_free ( mem_ctx ) ;
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
}
2010-02-20 03:44:41 +03:00
password = ldb_msg_find_attr_as_string ( msg , " secret " , NULL ) ;
machine_account = ldb_msg_find_attr_as_string ( msg , " samAccountName " , NULL ) ;
2005-09-29 04:02:38 +04:00
if ( ! machine_account ) {
2010-02-20 03:44:41 +03:00
machine_account = ldb_msg_find_attr_as_string ( msg , " servicePrincipalName " , NULL ) ;
2007-08-28 08:35:29 +04:00
if ( ! machine_account ) {
2010-02-20 03:44:41 +03:00
const char * ldap_bind_dn = ldb_msg_find_attr_as_string ( msg , " ldapBindDn " , NULL ) ;
2008-07-15 09:05:41 +04:00
if ( ! ldap_bind_dn ) {
2010-02-20 03:44:41 +03:00
* error_string = talloc_asprintf ( cred ,
" Could not find 'samAccountName', "
" 'servicePrincipalName' or "
" 'ldapBindDn' in secrets record: %s " ,
ldb_dn_get_linearized ( msg - > dn ) ) ;
2008-07-15 09:05:41 +04:00
/* set anonymous as the fallback, if the machine account won't work */
cli_credentials_set_anonymous ( cred ) ;
talloc_free ( mem_ctx ) ;
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
2009-10-09 23:30:51 +04:00
} else {
/* store bind dn in credentials */
cli_credentials_set_bind_dn ( cred , ldap_bind_dn ) ;
2008-07-15 09:05:41 +04:00
}
2007-08-28 08:35:29 +04:00
}
2005-09-29 04:02:38 +04:00
}
2005-10-20 14:28:16 +04:00
2010-02-20 03:44:41 +03:00
salt_principal = ldb_msg_find_attr_as_string ( msg , " saltPrincipal " , NULL ) ;
2005-10-20 14:28:16 +04:00
cli_credentials_set_salt_principal ( cred , salt_principal ) ;
2005-09-29 04:02:38 +04:00
2010-02-20 03:44:41 +03:00
sct = ldb_msg_find_attr_as_int ( msg , " secureChannelType " , 0 ) ;
2005-10-20 08:53:42 +04:00
if ( sct ) {
cli_credentials_set_secure_channel_type ( cred , sct ) ;
2005-09-29 04:02:38 +04:00
}
if ( ! password ) {
2010-02-20 03:44:41 +03:00
const struct ldb_val * nt_password_hash = ldb_msg_find_ldb_val ( msg , " unicodePwd " ) ;
2005-09-29 04:02:38 +04:00
struct samr_Password hash ;
ZERO_STRUCT ( hash ) ;
if ( nt_password_hash ) {
memcpy ( hash . hash , nt_password_hash - > data ,
MIN ( nt_password_hash - > length , sizeof ( hash . hash ) ) ) ;
cli_credentials_set_nt_hash ( cred , & hash , CRED_SPECIFIED ) ;
} else {
2006-01-24 08:31:08 +03:00
cli_credentials_set_password ( cred , NULL , CRED_SPECIFIED ) ;
2005-09-29 04:02:38 +04:00
}
2006-01-24 08:31:08 +03:00
} else {
cli_credentials_set_password ( cred , password , CRED_SPECIFIED ) ;
2005-09-29 04:02:38 +04:00
}
2006-01-24 08:31:08 +03:00
2005-09-29 04:02:38 +04:00
2010-02-20 03:44:41 +03:00
domain = ldb_msg_find_attr_as_string ( msg , " flatname " , NULL ) ;
2005-09-29 04:02:38 +04:00
if ( domain ) {
cli_credentials_set_domain ( cred , domain , CRED_SPECIFIED ) ;
}
2010-02-20 03:44:41 +03:00
realm = ldb_msg_find_attr_as_string ( msg , " realm " , NULL ) ;
2005-09-29 04:02:38 +04:00
if ( realm ) {
cli_credentials_set_realm ( cred , realm , CRED_SPECIFIED ) ;
}
2008-07-15 09:05:41 +04:00
if ( machine_account ) {
cli_credentials_set_username ( cred , machine_account , CRED_SPECIFIED ) ;
}
2005-09-29 04:02:38 +04:00
2010-02-20 03:44:41 +03:00
cli_credentials_set_kvno ( cred , ldb_msg_find_attr_as_int ( msg , " msDS-KeyVersionNumber " , 0 ) ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
2010-05-17 07:41:01 +04:00
whenChanged = ldb_msg_find_ldb_val ( msg , " whenChanged " ) ;
if ( whenChanged ) {
time_t lct ;
if ( ldb_val_to_time ( whenChanged , & lct ) = = LDB_SUCCESS ) {
cli_credentials_set_password_last_changed_time ( cred , lct ) ;
}
}
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
/* If there was an external keytab specified by reference in
* the LDB , then use this . Otherwise we will make one up
* ( chewing CPU time ) from the password */
2010-09-23 11:01:44 +04:00
keytab = keytab_name_from_msg ( cred , ldb , msg ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
if ( keytab ) {
2010-10-11 09:53:08 +04:00
cli_credentials_set_keytab_name ( cred , lp_ctx , keytab , CRED_SPECIFIED ) ;
2010-09-23 11:01:44 +04:00
talloc_free ( keytab ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
}
2005-09-29 04:02:38 +04:00
talloc_free ( mem_ctx ) ;
return NT_STATUS_OK ;
}
2005-10-20 07:47:55 +04:00
/**
* Fill in credentials for the machine trust account , from the secrets database .
*
* @ param cred Credentials structure to fill in
* @ retval NTSTATUS error detailing any failure
*/
2008-04-02 06:53:27 +04:00
_PUBLIC_ NTSTATUS cli_credentials_set_machine_account ( struct cli_credentials * cred ,
2008-04-05 14:39:26 +04:00
struct loadparm_context * lp_ctx )
2005-10-20 07:47:55 +04:00
{
2008-07-15 09:05:41 +04:00
NTSTATUS status ;
2005-12-14 10:22:25 +03:00
char * filter ;
2010-02-20 03:44:41 +03:00
char * error_string ;
2012-07-14 16:23:41 +04:00
const char * domain ;
2005-12-14 10:22:25 +03:00
/* Bleh, nasty recursion issues: We are setting a machine
* account here , so we don ' t want the ' pending ' flag around
* any more */
2007-10-07 02:16:19 +04:00
cred - > machine_account_pending = false ;
2012-07-14 16:23:41 +04:00
/* We have to do this, as the fallback in
* cli_credentials_set_secrets is to run as anonymous , so the domain is wiped */
domain = cli_credentials_get_domain ( cred ) ;
2005-12-14 10:22:25 +03:00
filter = talloc_asprintf ( cred , SECRETS_PRIMARY_DOMAIN_FILTER ,
2012-07-14 16:23:41 +04:00
domain ) ;
2010-10-11 09:53:08 +04:00
status = cli_credentials_set_secrets ( cred , lp_ctx , NULL ,
SECRETS_PRIMARY_DOMAIN_DN ,
2010-02-20 03:44:41 +03:00
filter , & error_string ) ;
2012-07-14 16:23:41 +04:00
if ( NT_STATUS_EQUAL ( NT_STATUS_CANT_ACCESS_DOMAIN_INFO , status )
| | NT_STATUS_EQUAL ( NT_STATUS_NOT_FOUND , status ) ) {
TDB_DATA dbuf ;
char * secrets_tdb = lpcfg_private_path ( cred , lp_ctx , " secrets.tdb " ) ;
struct db_context * db_ctx = dbwrap_local_open ( cred , lp_ctx , secrets_tdb , 0 ,
TDB_DEFAULT , O_RDWR , 0600 ,
DBWRAP_LOCK_ORDER_1 ) ;
if ( db_ctx ) {
char * keystr ;
char * keystr_upper ;
keystr = talloc_asprintf ( cred , " %s/%s " ,
SECRETS_MACHINE_PASSWORD ,
domain ) ;
keystr_upper = strupper_talloc ( cred , keystr ) ;
TALLOC_FREE ( keystr ) ;
status = dbwrap_fetch ( db_ctx , cred , string_tdb_data ( keystr_upper ) ,
& dbuf ) ;
if ( NT_STATUS_IS_OK ( status ) ) {
char * machine_account = talloc_asprintf ( cred , " %s$ " , lpcfg_netbios_name ( lp_ctx ) ) ;
cli_credentials_set_password ( cred , ( const char * ) dbuf . dptr , CRED_SPECIFIED ) ;
cli_credentials_set_domain ( cred , domain , CRED_SPECIFIED ) ;
cli_credentials_set_username ( cred , machine_account , CRED_SPECIFIED ) ;
TALLOC_FREE ( machine_account ) ;
TALLOC_FREE ( dbuf . dptr ) ;
} else {
error_string = talloc_asprintf ( cred ,
" Failed to fetch machine account password from "
" secrets.ldb: %s and failed to fetch %s from %s " ,
error_string , keystr_upper , secrets_tdb ) ;
}
TALLOC_FREE ( keystr_upper ) ;
TALLOC_FREE ( secrets_tdb ) ;
}
}
2008-07-15 09:05:41 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2012-07-14 16:23:41 +04:00
DEBUG ( 1 , ( " Could not find machine account in secrets database: %s: %s \n " ,
error_string , nt_errstr ( status ) ) ) ;
2010-02-20 03:44:41 +03:00
talloc_free ( error_string ) ;
2008-07-15 09:05:41 +04:00
}
return status ;
2005-10-20 07:47:55 +04:00
}
/**
* Fill in credentials for the machine trust account , from the secrets database .
*
* @ param cred Credentials structure to fill in
* @ retval NTSTATUS error detailing any failure
*/
2007-12-04 01:33:22 +03:00
NTSTATUS cli_credentials_set_krbtgt ( struct cli_credentials * cred ,
struct loadparm_context * lp_ctx )
2005-10-20 07:47:55 +04:00
{
2008-07-15 09:05:41 +04:00
NTSTATUS status ;
2005-12-14 10:22:25 +03:00
char * filter ;
2010-02-20 03:44:41 +03:00
char * error_string ;
2005-12-14 10:22:25 +03:00
/* Bleh, nasty recursion issues: We are setting a machine
* account here , so we don ' t want the ' pending ' flag around
* any more */
2007-10-07 02:16:19 +04:00
cred - > machine_account_pending = false ;
2005-12-14 10:22:25 +03:00
filter = talloc_asprintf ( cred , SECRETS_KRBTGT_SEARCH ,
2005-10-20 07:47:55 +04:00
cli_credentials_get_realm ( cred ) ,
cli_credentials_get_domain ( cred ) ) ;
2010-10-11 09:53:08 +04:00
status = cli_credentials_set_secrets ( cred , lp_ctx , NULL ,
2010-02-20 03:44:41 +03:00
SECRETS_PRINCIPALS_DN ,
filter , & error_string ) ;
2008-07-15 09:05:41 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2011-10-05 10:07:51 +04:00
DEBUG ( 1 , ( " Could not find krbtgt (master Kerberos) account in secrets database: %s: %s \n " , nt_errstr ( status ) , error_string ) ) ;
2010-02-20 03:44:41 +03:00
talloc_free ( error_string ) ;
2008-07-15 09:05:41 +04:00
}
return status ;
2005-10-20 07:47:55 +04:00
}
/**
2008-07-15 09:05:41 +04:00
* Fill in credentials for a particular prinicpal , from the secrets database .
2005-10-20 07:47:55 +04:00
*
* @ param cred Credentials structure to fill in
* @ retval NTSTATUS error detailing any failure
*/
2008-04-02 06:53:27 +04:00
_PUBLIC_ NTSTATUS cli_credentials_set_stored_principal ( struct cli_credentials * cred ,
2007-12-14 00:46:17 +03:00
struct loadparm_context * lp_ctx ,
2005-10-20 07:47:55 +04:00
const char * serviceprincipal )
{
2008-07-15 09:05:41 +04:00
NTSTATUS status ;
2005-12-14 10:22:25 +03:00
char * filter ;
2010-02-20 03:44:41 +03:00
char * error_string ;
2005-12-14 10:22:25 +03:00
/* Bleh, nasty recursion issues: We are setting a machine
* account here , so we don ' t want the ' pending ' flag around
* any more */
2007-10-07 02:16:19 +04:00
cred - > machine_account_pending = false ;
2005-12-14 10:22:25 +03:00
filter = talloc_asprintf ( cred , SECRETS_PRINCIPAL_SEARCH ,
cli_credentials_get_realm ( cred ) ,
cli_credentials_get_domain ( cred ) ,
serviceprincipal ) ;
2010-10-11 09:53:08 +04:00
status = cli_credentials_set_secrets ( cred , lp_ctx , NULL ,
2010-02-20 03:44:41 +03:00
SECRETS_PRINCIPALS_DN , filter ,
& error_string ) ;
2008-07-15 09:05:41 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2011-10-05 10:07:51 +04:00
DEBUG ( 1 , ( " Could not find %s principal in secrets database: %s: %s \n " , serviceprincipal , nt_errstr ( status ) , error_string ) ) ;
2008-07-15 09:05:41 +04:00
}
return status ;
2005-10-20 07:47:55 +04:00
}
2005-09-29 04:02:38 +04:00
/**
* Ask that when required , the credentials system will be filled with
* machine trust account , from the secrets database .
*
* @ param cred Credentials structure to fill in
* @ note This function is used to call the above function after , rather
* than during , popt processing .
*
*/
2008-04-02 06:53:27 +04:00
_PUBLIC_ void cli_credentials_set_machine_account_pending ( struct cli_credentials * cred ,
2007-12-14 00:46:17 +03:00
struct loadparm_context * lp_ctx )
2005-09-29 04:02:38 +04:00
{
2007-10-07 02:16:19 +04:00
cred - > machine_account_pending = true ;
2007-12-14 00:46:17 +03:00
cred - > machine_account_pending_lp_ctx = lp_ctx ;
2005-09-29 04:02:38 +04:00
}
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00