Path: blob/main/crypto/krb5/src/windows/kfwlogon/kfwlogon.h
34914 views
/*12Copyright 2005,2006 by the Massachusetts Institute of Technology3Copyright 2007 by Secure Endpoints Inc.45All rights reserved.67Permission to use, copy, modify, and distribute this software and its8documentation for any purpose and without fee is hereby granted,9provided that the above copyright notice appear in all copies and that10both that copyright notice and this permission notice appear in11supporting documentation, and that the name of the Massachusetts12Institute of Technology (M.I.T.) not be used in advertising or publicity13pertaining to distribution of the software without specific, written14prior permission.1516M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING17ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL18M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR19ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,20WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS22SOFTWARE.2324*/2526/* We only support VC 1200 and above anyway */27#pragma once2829/* _WIN32_WINNT must be 0x0501 or greater to pull in definition of30* all required LSA data types when the Vista SDK NtSecAPI.h is used.31*/32#ifndef _WIN32_WINNT33#define _WIN32_WINNT 0x050134#else35#if _WIN32_WINNT < 0x050136#undef _WIN32_WINNT37#define _WIN32_WINNT 0x050138#endif39#endif4041#include <windows.h>42#include <npapi.h>43#define SECURITY_WIN3244#include <security.h>45#include <ntsecapi.h>46#include <tchar.h>47#include <strsafe.h>4849typedef int errcode_t;5051#include <loadfuncs-lsa.h>52#include <krb5.h>53#include <loadfuncs-com_err.h>54#include <loadfuncs-krb5.h>55#include <loadfuncs-profile.h>56#include <loadfuncs-leash.h>5758// service definitions59#define SERVICE_DLL "advapi32.dll"60typedef SC_HANDLE (WINAPI *FP_OpenSCManagerA)(char *, char *, DWORD);61typedef SC_HANDLE (WINAPI *FP_OpenServiceA)(SC_HANDLE, char *, DWORD);62typedef BOOL (WINAPI *FP_QueryServiceStatus)(SC_HANDLE, LPSERVICE_STATUS);63typedef BOOL (WINAPI *FP_CloseServiceHandle)(SC_HANDLE);6465/* In order to avoid including the private CCAPI headers */66typedef int cc_int32;6768#define CC_API_VER_1 169#define CC_API_VER_2 27071#define CCACHE_API cc_int327273/*74** The Official Error Codes75*/76#define CC_NOERROR 077#define CC_BADNAME 178#define CC_NOTFOUND 279#define CC_END 380#define CC_IO 481#define CC_WRITE 582#define CC_NOMEM 683#define CC_FORMAT 784#define CC_LOCKED 885#define CC_BAD_API_VERSION 986#define CC_NO_EXIST 1087#define CC_NOT_SUPP 1188#define CC_BAD_PARM 1289#define CC_ERR_CACHE_ATTACH 1390#define CC_ERR_CACHE_RELEASE 1491#define CC_ERR_CACHE_FULL 1592#define CC_ERR_CRED_VERSION 169394enum {95CC_CRED_VUNKNOWN = 0, // For validation96/* CC_CRED_V4 = 1, */97CC_CRED_V5 = 2,98CC_CRED_VMAX = 3 // For validation99};100101typedef struct opaque_dll_control_block_type* apiCB;102typedef struct _infoNC {103char* name;104char* principal;105cc_int32 vers;106} infoNC;107108TYPEDEF_FUNC(109CCACHE_API,110CALLCONV_C,111cc_initialize,112(113apiCB** cc_ctx, // < DLL's primary control structure.114// returned here, passed everywhere else115cc_int32 api_version, // > ver supported by caller (use CC_API_VER_1)116cc_int32* api_supported, // < if ~NULL, max ver supported by DLL117const char** vendor // < if ~NULL, vendor name in read only C string118)119);120121TYPEDEF_FUNC(122CCACHE_API,123CALLCONV_C,124cc_shutdown,125(126apiCB** cc_ctx // <> DLL's primary control structure. NULL after127)128);129130TYPEDEF_FUNC(131CCACHE_API,132CALLCONV_C,133cc_get_NC_info,134(135apiCB* cc_ctx, // > DLL's primary control structure136struct _infoNC*** ppNCi // < (NULL before call) null terminated,137// list of a structs (free via cc_free_infoNC())138)139);140141TYPEDEF_FUNC(142CCACHE_API,143CALLCONV_C,144cc_free_NC_info,145(146apiCB* cc_ctx,147struct _infoNC*** ppNCi // < free list of structs returned by148// cc_get_cache_names(). set to NULL on return149)150);151/* End private ccapiv2 headers */152153#ifdef _WIN64154#define CCAPI_DLL "krbcc64.dll"155#else156#define CCAPI_DLL "krbcc32.dll"157#endif158159160/* */161#define MAX_USERNAME_LENGTH 256162#define MAX_PASSWORD_LENGTH 256163#define MAX_DOMAIN_LENGTH 256164165#define KFW_LOGON_EVENT_NAME TEXT("MIT Kerberos")166167BOOLEAN WINAPI DllMain(HANDLE dll, DWORD reason, PVOID reserved);168169DWORD APIENTRY NPGetCaps(DWORD index);170171DWORD APIENTRY NPLogonNotify(172PLUID lpLogonId,173LPCWSTR lpAuthentInfoType,174LPVOID lpAuthentInfo,175LPCWSTR lpPreviousAuthentInfoType,176LPVOID lpPreviousAuthentInfo,177LPWSTR lpStationName,178LPVOID StationHandle,179LPWSTR *lpLogonScript);180181DWORD APIENTRY NPPasswordChangeNotify(182LPCWSTR lpAuthentInfoType,183LPVOID lpAuthentInfo,184LPCWSTR lpPreviousAuthentInfoType,185LPVOID lpPreviousAuthentInfo,186LPWSTR lpStationName,187LPVOID StationHandle,188DWORD dwChangeInfo);189190#ifdef __cplusplus191extern "C" {192#endif193194void DebugEvent0(char *a);195void DebugEvent(char *b,...);196197DWORD MapAuthError(DWORD code);198199static BOOL WINAPI UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOutputString, int nOutStringLen);200201int KFW_is_available(void);202int KFW_get_cred( char * username, char * password, int lifetime, char ** reasonP );203void KFW_copy_cache_to_system_file(const char * user, const char * filename);204int KFW_destroy_tickets_for_principal(char * user);205int KFW_set_ccache_dacl(char *filename, HANDLE hUserToken);206int KFW_set_ccache_dacl_with_user_sid(char *filename, PSID pUserSID);207int KFW_obtain_user_temp_directory(HANDLE hUserToken, char *newfilename, int size);208void KFW_cleanup_orphaned_caches(void);209210void CALLBACK LogonEventHandlerA(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);211212#ifdef __cplusplus213}214#endif215216217