mech-ntlm.c revision 88c2db95c4a0f8f7986a63cd57cf4b6850d76543
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen/*
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * NTLM and NTLMv2 authentication mechanism.
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen *
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen *
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * This program is free software; you can redistribute it and/or modify
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * it under the terms of the GNU Lesser General Public License as published
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * by the Free Software Foundation; either version 2 of the License, or
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * (at your option) any later version.
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen */
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "common.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "mech.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "passdb.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "str.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "buffer.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "hex-binary.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "safe-memset.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen#include "ntlm.h"
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenstruct ntlm_auth_request {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct auth_request auth_request;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen pool_t pool;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen /* requested: */
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen int ntlm2_negotiated;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const unsigned char *challenge;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen /* received: */
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct ntlmssp_response *response;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen};
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainenstatic void
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainenlm_credentials_callback(const char *credentials,
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen struct auth_request *auth_request)
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen{
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen struct ntlm_auth_request *auth =
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen (struct ntlm_auth_request *)auth_request;
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen const unsigned char *client_response;
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen unsigned char lm_response[LM_RESPONSE_SIZE];
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen unsigned char hash[LM_HASH_SIZE];
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen buffer_t *hash_buffer;
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen int ret;
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen if (credentials == NULL) {
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen mech_auth_finish(auth_request, NULL, 0, FALSE);
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen return;
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen }
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen hash_buffer = buffer_create_data(auth_request->pool,
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen hash, sizeof(hash));
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen hex_to_binary(credentials, hash_buffer);
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen client_response = ntlmssp_buffer_data(auth->response, lm_response);
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen ntlmssp_v1_response(hash, auth->challenge, lm_response);
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen ret = memcmp(lm_response, client_response, LM_RESPONSE_SIZE) == 0;
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen mech_auth_finish(auth_request, NULL, 0, ret);
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen}
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenstatic void
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenntlm_credentials_callback(const char *credentials,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct auth_request *auth_request)
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen{
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct ntlm_auth_request *auth =
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen (struct ntlm_auth_request *)auth_request;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const unsigned char *client_response;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen unsigned char hash[NTLMSSP_HASH_SIZE];
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen unsigned int response_length;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen buffer_t *hash_buffer;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen int ret;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen if (credentials == NULL && !auth->ntlm2_negotiated) {
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen passdb->lookup_credentials(auth_request,
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen PASSDB_CREDENTIALS_LANMAN,
d43c646d4b84635aa795946555be04a553d5413aTimo Sirainen lm_credentials_callback);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen hash_buffer = buffer_create_data(auth_request->pool,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen hash, sizeof(hash));
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen hex_to_binary(credentials, hash_buffer);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen response_length = ntlmssp_buffer_length(auth->response, ntlm_response);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen client_response = ntlmssp_buffer_data(auth->response, ntlm_response);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (response_length > NTLMSSP_RESPONSE_SIZE) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen unsigned char ntlm_v2_response[NTLMSSP_V2_RESPONSE_SIZE];
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const unsigned char *blob =
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen client_response + NTLMSSP_V2_RESPONSE_SIZE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen /*
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * Authentication target == NULL because we are acting
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen * as a standalone server, not as NT domain member.
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen */
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen ntlmssp_v2_response(auth_request->user, NULL,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen hash, auth->challenge, blob,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen response_length - NTLMSSP_V2_RESPONSE_SIZE,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen ntlm_v2_response);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen ret = memcmp(ntlm_v2_response, client_response,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen NTLMSSP_V2_RESPONSE_SIZE) == 0;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen } else {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen unsigned char ntlm_response[NTLMSSP_RESPONSE_SIZE];
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen const unsigned char *client_lm_response =
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen ntlmssp_buffer_data(auth->response, lm_response);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen if (auth->ntlm2_negotiated)
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen ntlmssp2_response(hash, auth->challenge,
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen client_lm_response,
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen ntlm_response);
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen else
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen ntlmssp_v1_response(hash, auth->challenge,
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen ntlm_response);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen ret = memcmp(ntlm_response, client_response,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen NTLMSSP_RESPONSE_SIZE) == 0;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_auth_finish(auth_request, NULL, 0, ret);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen}
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenstatic int
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenmech_ntlm_auth_continue(struct auth_request *auth_request,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const unsigned char *data, size_t data_size,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_callback_t *callback)
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen{
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct ntlm_auth_request *auth =
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen (struct ntlm_auth_request *)auth_request;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct auth_client_request_reply reply;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const char *error;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth_request->callback = callback;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (!auth->challenge) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const struct ntlmssp_request *request =
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen (struct ntlmssp_request *)data;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const struct ntlmssp_challenge *message;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen size_t message_size;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (!ntlmssp_check_request(request, data_size, &error)) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (verbose) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen i_info("ntlm(%s): invalid NTLM request, %s",
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen get_log_prefix(auth_request),
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen error);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_auth_finish(auth_request, NULL, 0, FALSE);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return TRUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen message = ntlmssp_create_challenge(auth->pool, request,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen &message_size);
88c2db95c4a0f8f7986a63cd57cf4b6850d76543Timo Sirainen auth->ntlm2_negotiated = message->flags & NTLMSSP_NEGOTIATE_NTLM2;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->challenge = message->challenge;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_init_auth_client_reply(&reply);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.id = auth_request->id;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.result = AUTH_CLIENT_RESULT_CONTINUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.reply_idx = 0;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.data_size = message_size;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen callback(&reply, message, auth_request->conn);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen } else {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const struct ntlmssp_response *response =
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen (struct ntlmssp_response *)data;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen char *username;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (!ntlmssp_check_response(response, data_size, &error)) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (verbose) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen i_info("ntlm(%s): invalid NTLM response, %s",
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen get_log_prefix(auth_request),
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen error);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_auth_finish(auth_request, NULL, 0, FALSE);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return TRUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->response = p_malloc(auth->pool, data_size);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen memcpy(auth->response, response, data_size);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen username = p_strdup(auth_request->pool,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen ntlmssp_t_str(auth->response, user));
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
9abfe876fa81576f130f3f82f622ae936c21a716Timo Sirainen if (!mech_fix_username(username, &error)) {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen if (verbose) {
9abfe876fa81576f130f3f82f622ae936c21a716Timo Sirainen i_info("ntlm(%s): %s",
9abfe876fa81576f130f3f82f622ae936c21a716Timo Sirainen get_log_prefix(auth_request), error);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_auth_finish(auth_request, NULL, 0, FALSE);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return TRUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth_request->user = username;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen passdb->lookup_credentials(auth_request,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen PASSDB_CREDENTIALS_NTLM,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen ntlm_credentials_callback);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen }
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return TRUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen}
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenstatic int
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenmech_ntlm_auth_initial(struct auth_request *auth_request,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct auth_client_request_new *request,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen const unsigned char *data __attr_unused__,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_callback_t *callback)
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen{
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct auth_client_request_reply reply;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_init_auth_client_reply(&reply);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.id = request->id;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.result = AUTH_CLIENT_RESULT_CONTINUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.reply_idx = 0;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen reply.data_size = 0;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen callback(&reply, "", auth_request->conn);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return TRUE;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen}
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenstatic void
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenmech_ntlm_auth_free(struct auth_request *auth_request)
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen{
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen pool_unref(auth_request->pool);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen}
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenstatic struct auth_request *mech_ntlm_auth_new(void)
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen{
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen struct ntlm_auth_request *auth;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen pool_t pool;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen pool = pool_alloconly_create("ntlm_auth_request", 256);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth = p_new(pool, struct ntlm_auth_request, 1);
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->pool = pool;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->auth_request.refcount = 1;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->auth_request.pool = pool;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->auth_request.auth_initial = mech_ntlm_auth_initial;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->auth_request.auth_continue = mech_ntlm_auth_continue;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen auth->auth_request.auth_free = mech_ntlm_auth_free;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen return &auth->auth_request;
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen}
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainenconst struct mech_module mech_ntlm = {
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen "NTLM",
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen MEMBER(plaintext) FALSE,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen MEMBER(advertise) TRUE,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen MEMBER(passdb_need_plain) FALSE,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen MEMBER(passdb_need_credentials) TRUE,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen mech_ntlm_auth_new,
c7480644202e5451fbed448508ea29a25cffc99cTimo Sirainen};