mirror of
https://github.com/samba-team/samba.git
synced 2025-12-23 00:23:53 +03:00
setups. - split up the ads structure into logical pieces. This makes it much easier to keep things like the authentication realm and the server realm separate (they can be different). - allow ads callers to specify that no sasl bind should be performed (used by "net ads info" for example) - fix an error with handing ADS_ERROR_SYSTEM() when errno is 0 - completely rewrote the code for finding the LDAP server. Now try DNS methods first, and try all DNS servers returned from the SRV DNS query, sorted by closeness to our interfaces (using the same sort code as we use in replies from WINS servers). This allows us to cope with ADS DCs that are down, and ensures we don't pick one that is on the other side of the country unless absolutely necessary. - recognise dnsRecords as binary when displaying them - cope with the realm not being configured in smb.conf (work it out from the LDAP server) - look at the trustDirection when looking up trusted domains and don't include trusts that trust our domains but we don't trust theirs. - use LDAP to query the alternate (netbios) name for a realm, and make sure that both and long and short forms of the name are accepted by winbindd. Use the short form by default for listing users/groups. - rescan the list of trusted domains every 5 minutes in case new trust relationships are added while winbindd is running - include transient trust relationships (ie. C trusts B, B trusts A, so C trusts A) in winbindd. - don't do a gratuituous node status lookup when finding an ADS DC (we don't need it and it could fail) - remove unused sid_to_distinguished_name function - make sure we find the allternate name of our primary domain when operating with a netbiosless ADS DC (using LDAP to do the lookup) - fixed the rpc trusted domain enumeration to support up to approx 2000 trusted domains (the old limit was 3) - use the IP for the remote_machine (%m) macro when the client doesn't supply us with a name via a netbios session request (eg. port 445) - if the client uses SPNEGO then use the machine name from the SPNEGO auth packet for remote_machine (%m) macro - add new 'net ads workgroup' command to find the netbios workgroup name for a realm
-
126 lines
3.0 KiB
C
126 lines
3.0 KiB
C
/*
|
|
Unix SMB/CIFS implementation.
|
|
kerberos utility library
|
|
Copyright (C) Andrew Tridgell 2001
|
|
Copyright (C) Remus Koos 2001
|
|
|
|
|
|
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 02139, USA.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
|
|
#ifdef HAVE_KRB5
|
|
|
|
/*
|
|
we use a prompter to avoid a crash bug in the kerberos libs when
|
|
dealing with empty passwords
|
|
this prompter is just a string copy ...
|
|
*/
|
|
static krb5_error_code
|
|
kerb_prompter(krb5_context ctx, void *data,
|
|
const char *name,
|
|
const char *banner,
|
|
int num_prompts,
|
|
krb5_prompt prompts[])
|
|
{
|
|
if (num_prompts == 0) return 0;
|
|
|
|
memset(prompts[0].reply->data, 0, prompts[0].reply->length);
|
|
if (prompts[0].reply->length > 0) {
|
|
strncpy(prompts[0].reply->data, data, prompts[0].reply->length-1);
|
|
prompts[0].reply->length = strlen(prompts[0].reply->data);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
simulate a kinit, putting the tgt in the default cache location
|
|
remus@snapserver.com
|
|
*/
|
|
int kerberos_kinit_password(const char *principal, const char *password)
|
|
{
|
|
krb5_context ctx;
|
|
krb5_error_code code = 0;
|
|
krb5_ccache cc;
|
|
krb5_principal me;
|
|
krb5_creds my_creds;
|
|
|
|
if ((code = krb5_init_context(&ctx)))
|
|
return code;
|
|
|
|
if ((code = krb5_cc_default(ctx, &cc))) {
|
|
krb5_free_context(ctx);
|
|
return code;
|
|
}
|
|
|
|
if ((code = krb5_parse_name(ctx, principal, &me))) {
|
|
krb5_free_context(ctx);
|
|
return code;
|
|
}
|
|
|
|
if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, NULL,
|
|
kerb_prompter,
|
|
password, 0, NULL, NULL))) {
|
|
krb5_free_principal(ctx, me);
|
|
krb5_free_context(ctx);
|
|
return code;
|
|
}
|
|
|
|
if ((code = krb5_cc_initialize(ctx, cc, me))) {
|
|
krb5_free_cred_contents(ctx, &my_creds);
|
|
krb5_free_principal(ctx, me);
|
|
krb5_free_context(ctx);
|
|
return code;
|
|
}
|
|
|
|
if ((code = krb5_cc_store_cred(ctx, cc, &my_creds))) {
|
|
krb5_cc_close(ctx, cc);
|
|
krb5_free_cred_contents(ctx, &my_creds);
|
|
krb5_free_principal(ctx, me);
|
|
krb5_free_context(ctx);
|
|
return code;
|
|
}
|
|
|
|
krb5_cc_close(ctx, cc);
|
|
krb5_free_cred_contents(ctx, &my_creds);
|
|
krb5_free_principal(ctx, me);
|
|
krb5_free_context(ctx);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
/* run kinit to setup our ccache */
|
|
int ads_kinit_password(ADS_STRUCT *ads)
|
|
{
|
|
char *s;
|
|
int ret;
|
|
|
|
asprintf(&s, "%s@%s", ads->auth.user_name, ads->auth.realm);
|
|
ret = kerberos_kinit_password(s, ads->auth.password);
|
|
|
|
if (ret) {
|
|
DEBUG(0,("kerberos_kinit_password %s failed: %s\n",
|
|
s, error_message(ret)));
|
|
}
|
|
free(s);
|
|
return ret;
|
|
}
|
|
|
|
|
|
#endif
|