windows-vista-sdk-ntsecapi-compat-20070403
[openafs.git] / src / WINNT / afsd / afslogon.h
1 /*
2
3 Copyright 2004 by the Massachusetts Institute of Technology
4
5 All rights reserved.
6
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose and without fee is hereby granted,
9 provided that the above copyright notice appear in all copies and that
10 both that copyright notice and this permission notice appear in
11 supporting documentation, and that the name of the Massachusetts
12 Institute of Technology (M.I.T.) not be used in advertising or publicity
13 pertaining to distribution of the software without specific, written
14 prior permission.
15
16 M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
17 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
18 M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
19 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22 SOFTWARE.
23
24 */
25
26 /* We only support VC 1200 and above anyway */
27 #pragma once
28
29 #include <windows.h>
30 #include <objbase.h>
31 #include <npapi.h>
32 #if (_WIN32_WINNT < 0x0501)
33 #undef _WIN32_WINNT
34 #define _WIN32_WINNT 0x0501
35 #endif
36 #include <ntsecapi.h>
37 #include <tchar.h>
38 #include <strsafe.h>
39
40
41 #define REG_CLIENT_DOMAINS_SUBKEY       "Domain"
42 #define REG_CLIENT_RETRY_INTERVAL_PARM  "LoginRetryInterval"
43 #define REG_CLIENT_SLEEP_INTERVAL_PARM  "LoginSleepInterval"
44 #define REG_CLIENT_FAIL_SILENTLY_PARM   "FailLoginsSilently"
45 #define REG_CLIENT_TRACE_OPTION_PARM    "TraceOption"
46 #define REG_CLIENT_LOGON_OPTION_PARM    "LogonOptions"
47 #define REG_CLIENT_LOGON_SCRIPT_PARMW   L"LogonScript"
48 #define REG_CLIENT_THESE_CELLS_PARM     "TheseCells"
49 #define REG_CLIENT_LOGOFF_TOKENS_PARM   "LogoffPreserveTokens"
50 #define DEFAULT_RETRY_INTERVAL          60                        /* seconds*/
51 #define DEFAULT_FAIL_SILENTLY           FALSE
52 #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
53 #define DEFAULT_LOGON_OPTION                    1
54
55 #define TRACE_OPTION_EVENT 1
56
57 #define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
58
59 #define ISLOGONINTEGRATED(v) ( ((v) & LOGON_OPTION_INTEGRATED)==LOGON_OPTION_INTEGRATED)
60 #define ISHIGHSECURITY(v) ( ((v) & LOGON_OPTION_HIGHSECURITY)==LOGON_OPTION_HIGHSECURITY)
61
62 #define ISREMOTE(v) ( ((v) & LOGON_FLAG_REMOTE)==LOGON_FLAG_REMOTE)
63 #define ISADREALM(v) ( ((v) & LOGON_FLAG_AD_REALM)==LOGON_FLAG_AD_REALM)
64 extern DWORD TraceOption;
65
66 #define LOGON_FLAG_LOCAL        0
67 #define LOGON_FLAG_REMOTE       1
68 #define LOGON_FLAG_AD_REALM 2
69
70 typedef struct LogonOptions_type {
71         DWORD   LogonOption;
72         BOOLEAN failSilently;
73         int     retryInterval;
74         int     sleepInterval;
75         char *  smbName;
76         LPWSTR  logonScript;
77         DWORD   flags; /* LOGON_FLAG_* */
78         char *  theseCells;
79 } LogonOptions_t;
80
81 /* */
82 #define MAX_USERNAME_LENGTH 256
83 #define MAX_PASSWORD_LENGTH 256
84 #define MAX_DOMAIN_LENGTH 256
85
86 BOOLEAN APIENTRY DllEntryPoint(HANDLE dll, DWORD reason, PVOID reserved);
87
88 DWORD APIENTRY NPGetCaps(DWORD index);
89
90 DWORD APIENTRY NPLogonNotify(
91         PLUID lpLogonId,
92         LPCWSTR lpAuthentInfoType,
93         LPVOID lpAuthentInfo,
94         LPCWSTR lpPreviousAuthentInfoType,
95         LPVOID lpPreviousAuthentInfo,
96         LPWSTR lpStationName,
97         LPVOID StationHandle,
98         LPWSTR *lpLogonScript);
99
100 DWORD APIENTRY NPPasswordChangeNotify(
101         LPCWSTR lpAuthentInfoType,
102         LPVOID lpAuthentInfo,
103         LPCWSTR lpPreviousAuthentInfoType,
104         LPVOID lpPreviousAuthentInfo,
105         LPWSTR lpStationName,
106         LPVOID StationHandle,
107         DWORD dwChangeInfo);
108
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112
113 void DebugEvent0(char *a);
114 void DebugEvent(char *b,...);
115
116 CHAR *GenRandomName(CHAR *pbuf);
117
118 BOOLEAN AFSWillAutoStart(void);
119
120 DWORD MapAuthError(DWORD code);
121
122 BOOL IsServiceRunning (void);
123
124 static BOOL WINAPI UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOutputString, int nOutStringLen);
125
126 void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt );
127 DWORD GetFileCellName(char * path, char * cell, size_t cellLen);
128 DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonOptions_t * opt);
129 DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid, PWSTR domain);
130 BOOL GetLocalShortDomain(PWSTR Domain, DWORD cbDomain);
131
132 #ifdef __cplusplus
133 }
134 #endif