diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-12-19 06:56:45 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:30 -0500 |
commit | 6bd8be867130686946e687512d7a4a68934217e1 (patch) | |
tree | 706672e72e96e9b2f676933273b448d0c49b5167 /source4/auth | |
parent | a30726581e594013ae9b61a42dab813051999548 (diff) | |
download | samba-6bd8be867130686946e687512d7a4a68934217e1.tar.gz samba-6bd8be867130686946e687512d7a4a68934217e1.tar.bz2 samba-6bd8be867130686946e687512d7a4a68934217e1.zip |
r12360: Add simple bind support into our LDAP server.
Needs changes to our client code for automated testing.
Andrew Bartlett
(This used to be commit e751d814149d847ff1699542a4fa81eb8ca129ec)
Diffstat (limited to 'source4/auth')
-rw-r--r-- | source4/auth/auth_simple.c | 90 | ||||
-rw-r--r-- | source4/auth/config.mk | 3 |
2 files changed, 92 insertions, 1 deletions
diff --git a/source4/auth/auth_simple.c b/source4/auth/auth_simple.c new file mode 100644 index 0000000000..7976560bf1 --- /dev/null +++ b/source4/auth/auth_simple.c @@ -0,0 +1,90 @@ +/* + Unix SMB/CIFS implementation. + + auth functions + + Copyright (C) Simo Sorce 2005 + Copyright (C) Andrew Tridgell 2005 + Copyright (C) Andrew Bartlett 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 + 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" +#include "auth/auth.h" +#include "lib/events/events.h" + +NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx, + const char *nt4_domain, + const char *nt4_username, + const char *password, + struct auth_session_info **session_info) +{ + struct auth_context *auth_context; + struct auth_usersupplied_info *user_info; + struct auth_serversupplied_info *server_info; + NTSTATUS nt_status; + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + + if (!tmp_ctx) { + return NT_STATUS_NO_MEMORY; + } + + nt_status = auth_context_create(tmp_ctx, lp_auth_methods(), &auth_context, + event_context_find(mem_ctx)); + if (!NT_STATUS_IS_OK(nt_status)) { + talloc_free(tmp_ctx); + return nt_status; + } + + user_info = talloc(tmp_ctx, struct auth_usersupplied_info); + if (!user_info) { + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } + + user_info->mapped_state = True; + user_info->client.account_name = nt4_username; + user_info->mapped.account_name = nt4_username; + user_info->client.domain_name = nt4_domain; + user_info->mapped.domain_name = nt4_domain; + + user_info->workstation_name = NULL; + + user_info->remote_host = NULL; + + user_info->password_state = AUTH_PASSWORD_PLAIN; + user_info->password.plaintext = talloc_strdup(user_info, password); + + user_info->flags = USER_INFO_CASE_INSENSITIVE_USERNAME | + USER_INFO_DONT_CHECK_UNIX_ACCOUNT; + + user_info->logon_parameters = 0; + + nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); + if (!NT_STATUS_IS_OK(nt_status)) { + talloc_free(tmp_ctx); + return nt_status; + } + + nt_status = auth_generate_session_info(tmp_ctx, server_info, session_info); + + if (NT_STATUS_IS_OK(nt_status)) { + talloc_steal(mem_ctx, *session_info); + } + + return nt_status; +} + diff --git a/source4/auth/config.mk b/source4/auth/config.mk index 876d43a6ef..d572c5e89a 100644 --- a/source4/auth/config.mk +++ b/source4/auth/config.mk @@ -72,6 +72,7 @@ INIT_OBJ_FILES = \ ADD_OBJ_FILES = \ auth_util.o \ auth_sam_reply.o \ - ntlm_check.o + ntlm_check.o \ + auth_simple.o # End SUBSYSTEM AUTH ####################### |