windows-afslogon-20070406
[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_REALM_PARM           "Realm"
49 #define REG_CLIENT_THESE_CELLS_PARM     "TheseCells"
50 #define REG_CLIENT_LOGOFF_TOKENS_PARM   "LogoffPreserveTokens"
51 #define DEFAULT_RETRY_INTERVAL          60                        /* seconds*/
52 #define DEFAULT_FAIL_SILENTLY           FALSE
53 #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
54 #define DEFAULT_LOGON_OPTION                    1
55
56 #define TRACE_OPTION_EVENT 1
57
58 #define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT)
59
60 #define ISLOGONINTEGRATED(v) ( ((v) & LOGON_OPTION_INTEGRATED)==LOGON_OPTION_INTEGRATED)
61 #define ISHIGHSECURITY(v) ( ((v) & LOGON_OPTION_HIGHSECURITY)==LOGON_OPTION_HIGHSECURITY)
62
63 #define ISREMOTE(v) ( ((v) & LOGON_FLAG_REMOTE)==LOGON_FLAG_REMOTE)
64 #define ISADREALM(v) ( ((v) & LOGON_FLAG_AD_REALM)==LOGON_FLAG_AD_REALM)
65 extern DWORD TraceOption;
66
67 #define LOGON_FLAG_LOCAL        0
68 #define LOGON_FLAG_REMOTE       1
69 #define LOGON_FLAG_AD_REALM 2
70
71 typedef struct LogonOptions_type {
72         DWORD   LogonOption;
73         BOOLEAN failSilently;
74         int     retryInterval;
75         int     sleepInterval;
76         char *  smbName;
77         LPWSTR  logonScript;
78         DWORD   flags; /* LOGON_FLAG_* */
79         char *  theseCells;
80         char *  realm;
81 } LogonOptions_t;
82
83 /* */
84 #define MAX_USERNAME_LENGTH 256
85 #define MAX_PASSWORD_LENGTH 256
86 #define MAX_DOMAIN_LENGTH 256
87
88 BOOLEAN APIENTRY DllEntryPoint(HANDLE dll, DWORD reason, PVOID reserved);
89
90 DWORD APIENTRY NPGetCaps(DWORD index);
91
92 DWORD APIENTRY NPLogonNotify(
93         PLUID lpLogonId,
94         LPCWSTR lpAuthentInfoType,
95         LPVOID lpAuthentInfo,
96         LPCWSTR lpPreviousAuthentInfoType,
97         LPVOID lpPreviousAuthentInfo,
98         LPWSTR lpStationName,
99         LPVOID StationHandle,
100         LPWSTR *lpLogonScript);
101
102 DWORD APIENTRY NPPasswordChangeNotify(
103         LPCWSTR lpAuthentInfoType,
104         LPVOID lpAuthentInfo,
105         LPCWSTR lpPreviousAuthentInfoType,
106         LPVOID lpPreviousAuthentInfo,
107         LPWSTR lpStationName,
108         LPVOID StationHandle,
109         DWORD dwChangeInfo);
110
111 #ifdef __cplusplus
112 extern "C" {
113 #endif
114
115 void DebugEvent0(char *a);
116 void DebugEvent(char *b,...);
117
118 CHAR *GenRandomName(CHAR *pbuf);
119
120 BOOLEAN AFSWillAutoStart(void);
121
122 DWORD MapAuthError(DWORD code);
123
124 BOOL IsServiceRunning (void);
125
126 static BOOL WINAPI UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOutputString, int nOutStringLen);
127
128 void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt );
129 DWORD GetFileCellName(char * path, char * cell, size_t cellLen);
130 DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonOptions_t * opt);
131 DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid, PWSTR domain);
132 BOOL GetLocalShortDomain(PWSTR Domain, DWORD cbDomain);
133
134 #ifdef __cplusplus
135 }
136 #endif