Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

637 lines
13 KiB

  1. /*++
  2. Copyright (c) 1987-1996 Microsoft Corporation
  3. Module Name:
  4. logonsrv.h
  5. Abstract:
  6. Netlogon service internal constants and definitions.
  7. Author:
  8. Ported from Lan Man 2.0
  9. Revision History:
  10. 21-May-1991 (cliffv)
  11. Ported to NT. Converted to NT style.
  12. --*/
  13. //
  14. // Define _DC_NETLOGON if _WKSTA_NETLOGON is not defined.
  15. //
  16. #ifndef _WKSTA_NETLOGON
  17. #define _DC_NETLOGON
  18. #endif // _WKSTA_NETLOGON
  19. ////////////////////////////////////////////////////////////////////////////
  20. //
  21. // Common include files needed by ALL netlogon server files
  22. //
  23. ////////////////////////////////////////////////////////////////////////////
  24. #if ( _MSC_VER >= 800 )
  25. #pragma warning ( 3 : 4100 ) // enable "Unreferenced formal parameter"
  26. #pragma warning ( 3 : 4219 ) // enable "trailing ',' used for variable argument list"
  27. #endif
  28. #include <nt.h> // LARGE_INTEGER definition
  29. #include <ntrtl.h> // LARGE_INTEGER definition
  30. #include <nturtl.h> // LARGE_INTEGER definition
  31. #include <ntlsa.h> // Needed by lsrvdata.h
  32. #define NOMINMAX // Avoid redefinition of min and max in stdlib.h
  33. #include <rpc.h> // Needed by logon_s.h
  34. #define INCL_WINSOCK_API_PROTOTYPES 1
  35. #include <winsock2.h> // Winsock support
  36. #include <logon_s.h> // includes lmcons.h, lmaccess.h, netlogon.h, ssi.h, windef.h
  37. #include <windows.h>
  38. #include <alertmsg.h> // ALERT_* defines
  39. #include <align.h> // ROUND_UP_COUNT ...
  40. #include <config.h> // net config helpers.
  41. #include <confname.h> // SECTION_ equates, NETLOGON_KEYWORD_ equates.
  42. #include <debugfmt.h> // FORMAT_*
  43. //#define SDK_DNS_RECORD 1 // Needed for dnsapi.h
  44. #include <windns.h> // DNS API
  45. #include <dnsapi.h> // Dns API
  46. #include <icanon.h> // NAMETYPE_* defines
  47. #include <lmapibuf.h> // NetApiBufferFree
  48. #include <lmerr.h> // NERR_ equates.
  49. #include <lmerrlog.h> // NELOG_*
  50. #include <lmserver.h> // Server API defines and prototypes
  51. #include <lmshare.h> // share API functions and prototypes
  52. #include <lmsname.h> // Needed for NETLOGON service name
  53. #include <lmsvc.h> // SERVICE_UIC codes are defined here
  54. #include <logonp.h> // NetpLogon routines
  55. #include <lsarpc.h> // Needed by lsrvdata.h and logonsrv.h
  56. #include <lsaisrv.h> // LsaI routines
  57. #include <wincrypt.h> // CryptoAPI
  58. #ifndef NETSETUP_JOIN
  59. #define SECURITY_KERBEROS
  60. #include <security.h> // Interface to LSA/Kerberos
  61. #include <secint.h> // needed to get Kerberos interfaces.
  62. #include <sspi.h> // Needed by ssiinit.h
  63. // #include <secext.h> // Needed by secpkg.h
  64. #include <secpkg.h> // Needed by sphelp.h
  65. #endif
  66. #include <names.h> // NetpIsUserNameValid
  67. #include <netlib.h> // NetpCopy...
  68. #include <netlibnt.h> // NetpNtStatusToApiStatus
  69. #include "nlp.h" // Nlp routine
  70. #include <ntddbrow.h> // Interface to browser driver
  71. #include <ntrpcp.h> // Rpcp routines
  72. #include <samrpc.h> // Needed by lsrvdata.h and logonsrv.h
  73. #include <samisrv.h> // SamIFree routines
  74. #include <secobj.h> // NetpAccessCheck
  75. #include <stddef.h> // offsetof()
  76. #include <stdlib.h> // C library functions (rand, etc)
  77. #include <tstring.h> // Transitional string routines.
  78. #include <lmjoin.h> // Needed by netsetup.h
  79. #include <netsetup.h> // NetpSetDnsComputerNameAsRequired
  80. #include <wmistr.h> // WMI trace
  81. #include <evntrace.h> // TRACEHANDLE
  82. #ifndef NETSETUP_JOIN
  83. #include <cryptdll.h>
  84. #include <ntdsa.h>
  85. #include <ntdsapi.h>
  86. #include <ntdsapip.h>
  87. #endif
  88. //
  89. // Netlogon specific header files.
  90. //
  91. #include <nlrepl.h> // I_Net*
  92. #include <dsgetdc.h> // DsGetDcName()
  93. #include <dsgetdcp.h> // DsGetDcOpen()
  94. #include "worker.h" // Worker routines
  95. #include "nlbind.h" // Netlogon RPC binding cache routines
  96. #include "nlcommon.h" // Routines shared with logonsrv\common
  97. #include "domain.h" // Hosted domain definitions
  98. #include "nldns.h" // DNS name registration
  99. #include "changelg.h" // Change Log support
  100. #include "chutil.h" // Change Log utilities
  101. #include "iniparm.h" // DEFAULT_, MIN_, and MAX_ equates.
  102. #include "ssiinit.h" // Misc global definitions
  103. #include "replutil.h"
  104. #include "nldebug.h" // Netlogon debugging
  105. #include "nlsecure.h" // Security Descriptor for APIs
  106. #include "ismapi.h"
  107. #include "nlsite.h"
  108. #include "lsrvdata.h" // Globals
  109. #ifdef _DC_NETLOGON
  110. #define NETLOGON_SCRIPTS_SHARE L"NETLOGON"
  111. #define NETLOGON_SYSVOL_SHARE L"SYSVOL"
  112. #endif // _DC_NETLOGON
  113. #define MAX_LOGONREQ_COUNT 3
  114. #define NETLOGON_INSTALL_WAIT 60000 // 60 secs
  115. //
  116. // Exit codes for NlExit
  117. //
  118. typedef enum {
  119. DontLogError,
  120. LogError,
  121. LogErrorAndNtStatus,
  122. LogErrorAndNetStatus
  123. } NL_EXIT_CODE;
  124. ////////////////////////////////////////////////////////////////////////
  125. //
  126. // Procedure Forwards
  127. //
  128. ////////////////////////////////////////////////////////////////////////
  129. //
  130. // error.c
  131. //
  132. NET_API_STATUS
  133. NlCleanup(
  134. VOID
  135. );
  136. VOID
  137. NlExit(
  138. IN DWORD ServiceError,
  139. IN DWORD Data,
  140. IN NL_EXIT_CODE ExitCode,
  141. IN LPWSTR ErrorString
  142. );
  143. BOOL
  144. GiveInstallHints(
  145. IN BOOL Started
  146. );
  147. #ifdef _DC_NETLOGON
  148. VOID
  149. NlControlHandler(
  150. IN DWORD opcode
  151. );
  152. #endif // _DC_NETLOGON
  153. VOID
  154. RaiseAlert(
  155. IN DWORD alert_no,
  156. IN LPWSTR *string_array
  157. );
  158. //
  159. // Nlparse.c
  160. //
  161. BOOL
  162. Nlparse(
  163. IN PNETLOGON_PARAMETERS NlParameters,
  164. IN PNETLOGON_PARAMETERS DefaultParameters OPTIONAL,
  165. IN BOOLEAN IsChangeNotify
  166. );
  167. VOID
  168. NlParseFree(
  169. IN PNETLOGON_PARAMETERS NlParameters
  170. );
  171. VOID
  172. NlReparse(
  173. VOID
  174. );
  175. BOOL
  176. NlparseAllSections(
  177. IN PNETLOGON_PARAMETERS NlParameters,
  178. IN BOOLEAN IsChangeNotify
  179. );
  180. //
  181. // announce.c
  182. //
  183. VOID
  184. NlRemovePendingBdc(
  185. IN PSERVER_SESSION ServerSession
  186. );
  187. VOID
  188. NlPrimaryAnnouncementFinish(
  189. IN PSERVER_SESSION ServerSession,
  190. IN DWORD DatabaseId,
  191. IN PLARGE_INTEGER SerialNumber
  192. );
  193. VOID
  194. NlPrimaryAnnouncementTimeout(
  195. VOID
  196. );
  197. VOID
  198. NlPrimaryAnnouncement(
  199. IN DWORD AnnounceFlags
  200. );
  201. #define ANNOUNCE_FORCE 0x01
  202. #define ANNOUNCE_CONTINUE 0x02
  203. #define ANNOUNCE_IMMEDIATE 0x04
  204. //
  205. // lsrvutil.c
  206. //
  207. NTSTATUS
  208. NlGetOutgoingPassword(
  209. IN PCLIENT_SESSION ClientSession,
  210. OUT PUNICODE_STRING *CurrentValue,
  211. OUT PUNICODE_STRING *OldValue,
  212. OUT PDWORD CurrentVersionNumber,
  213. OUT PLARGE_INTEGER LastSetTime OPTIONAL
  214. );
  215. NTSTATUS
  216. NlSessionSetup(
  217. IN OUT PCLIENT_SESSION ClientSession
  218. );
  219. NTSTATUS
  220. NlEnsureSessionAuthenticated(
  221. IN PCLIENT_SESSION ClientSession,
  222. IN DWORD DesiredFlags
  223. );
  224. BOOLEAN
  225. NlTimeHasElapsedEx(
  226. IN PLARGE_INTEGER StartTime,
  227. IN PLARGE_INTEGER Period,
  228. OUT PULONG RemainingTime OPTIONAL
  229. );
  230. BOOLEAN
  231. NlTimeToReauthenticate(
  232. IN PCLIENT_SESSION ClientSession
  233. );
  234. BOOLEAN
  235. NlTimeToRediscover(
  236. IN PCLIENT_SESSION ClientSession,
  237. BOOLEAN WithAccount
  238. );
  239. NTSTATUS
  240. NlUpdateDomainInfo(
  241. IN PCLIENT_SESSION ClientSession
  242. );
  243. NET_API_STATUS
  244. NlCreateShare(
  245. LPWSTR SharePath,
  246. LPWSTR ShareName,
  247. BOOLEAN AllowAuthenticatedUsers
  248. );
  249. NET_API_STATUS
  250. NlCacheJoinDomainControllerInfo(
  251. VOID
  252. );
  253. NTSTATUS
  254. NlSamOpenNamedUser(
  255. IN PDOMAIN_INFO DomainInfo,
  256. IN LPCWSTR UserName,
  257. OUT SAMPR_HANDLE *UserHandle OPTIONAL,
  258. OUT PULONG UserId OPTIONAL,
  259. PSAMPR_USER_INFO_BUFFER *UserAllInfo OPTIONAL
  260. );
  261. NTSTATUS
  262. NlSamChangePasswordNamedUser(
  263. IN PDOMAIN_INFO DomainInfo,
  264. IN LPCWSTR UserName,
  265. IN PUNICODE_STRING ClearTextPassword OPTIONAL,
  266. IN PNT_OWF_PASSWORD OwfPassword OPTIONAL
  267. );
  268. NTSTATUS
  269. NlGetIncomingPassword(
  270. IN PDOMAIN_INFO DomainInfo,
  271. IN LPCWSTR AccountName,
  272. IN NETLOGON_SECURE_CHANNEL_TYPE SecureChannelType,
  273. IN ULONG AllowableAccountControlBits,
  274. IN BOOL CheckAccountDisabled,
  275. OUT PNT_OWF_PASSWORD OwfPassword OPTIONAL,
  276. OUT PNT_OWF_PASSWORD OwfPreviousPassword OPTIONAL,
  277. OUT PULONG AccountRid OPTIONAL,
  278. OUT PULONG TrustAttributes OPTIONAL,
  279. OUT PBOOL IsDnsDomainTrustAccount OPTIONAL
  280. );
  281. NTSTATUS
  282. NlSetIncomingPassword(
  283. IN PDOMAIN_INFO DomainInfo,
  284. IN LPWSTR AccountName,
  285. IN NETLOGON_SECURE_CHANNEL_TYPE SecureChannelType,
  286. IN PUNICODE_STRING ClearTextPassword OPTIONAL,
  287. IN DWORD ClearPasswordVersionNumber,
  288. IN PNT_OWF_PASSWORD OwfPassword OPTIONAL
  289. );
  290. NTSTATUS
  291. NlChangePassword(
  292. IN PCLIENT_SESSION ClientSession,
  293. IN BOOLEAN ForcePasswordChange,
  294. OUT PULONG RetCallAgainPeriod OPTIONAL
  295. );
  296. NTSTATUS
  297. NlChangePasswordHigher(
  298. IN PCLIENT_SESSION ClientSession,
  299. IN LPWSTR AccountName,
  300. IN NETLOGON_SECURE_CHANNEL_TYPE AccountType,
  301. IN PLM_OWF_PASSWORD NewOwfPassword OPTIONAL,
  302. IN PUNICODE_STRING NewClearPassword OPTIONAL,
  303. IN PDWORD ClearPasswordVersionNumber OPTIONAL
  304. );
  305. NTSTATUS
  306. NlGetUserPriv(
  307. IN PDOMAIN_INFO DomainInfo,
  308. IN ULONG GroupCount,
  309. IN PGROUP_MEMBERSHIP Groups,
  310. IN ULONG UserRelativeId,
  311. OUT LPDWORD Priv,
  312. OUT LPDWORD AuthFlags
  313. );
  314. BOOLEAN
  315. NlGenerateRandomBits(
  316. PUCHAR pBuffer,
  317. ULONG cbBuffer
  318. );
  319. //
  320. // netlogon.c
  321. //
  322. #ifdef _DC_NETLOGON
  323. BOOL
  324. TimerExpired(
  325. IN PTIMER Timer,
  326. IN PLARGE_INTEGER TimeNow,
  327. IN OUT LPDWORD Timeout
  328. );
  329. ULONG
  330. NlGetDomainFlags(
  331. IN PDOMAIN_INFO DomainInfo
  332. );
  333. NTSTATUS
  334. NlWaitForService(
  335. LPWSTR ServiceName,
  336. ULONG Timeout,
  337. BOOLEAN RequireAutoStart
  338. );
  339. int
  340. NlNetlogonMain(
  341. IN DWORD argc,
  342. IN LPWSTR *argv
  343. );
  344. NTSTATUS
  345. NlInitLsaDBInfo(
  346. PDOMAIN_INFO DomainInfo,
  347. DWORD DBIndex
  348. );
  349. NTSTATUS
  350. NlInitSamDBInfo(
  351. PDOMAIN_INFO DomainInfo,
  352. DWORD DBIndex
  353. );
  354. BOOL
  355. NlCreateSysvolShares(
  356. VOID
  357. );
  358. #endif // _DC_NETLOGON
  359. //
  360. // mailslot.c
  361. //
  362. NTSTATUS
  363. NlpWriteMailslot(
  364. IN LPWSTR MailslotName,
  365. IN LPVOID Buffer,
  366. IN DWORD BufferSize
  367. );
  368. #ifdef _DC_NETLOGON
  369. HANDLE
  370. NlBrowserCreateEvent(
  371. VOID
  372. );
  373. VOID
  374. NlBrowserCloseEvent(
  375. IN HANDLE EventHandle
  376. );
  377. BOOL
  378. NlBrowserOpen(
  379. VOID
  380. );
  381. VOID
  382. NlBrowserClose(
  383. VOID
  384. );
  385. NTSTATUS
  386. NlBrowserSendDatagramA(
  387. IN PDOMAIN_INFO DomainInfo,
  388. IN ULONG IpAddress,
  389. IN LPSTR OemServerName,
  390. IN DGRECEIVER_NAME_TYPE NameType,
  391. IN LPWSTR TransportName,
  392. IN LPSTR OemMailslotName,
  393. IN PVOID Buffer,
  394. IN ULONG BufferSize
  395. );
  396. NET_API_STATUS
  397. NlBrowserFixAllNames(
  398. IN PDOMAIN_INFO DomainInfo,
  399. IN PVOID Context
  400. );
  401. VOID
  402. NlBrowserAddName(
  403. IN PDOMAIN_INFO DomainInfo
  404. );
  405. VOID
  406. NlBrowserDelName(
  407. IN PDOMAIN_INFO DomainInfo
  408. );
  409. VOID
  410. NlBrowserUpdate(
  411. IN PDOMAIN_INFO DomainInfo,
  412. IN DWORD Role
  413. );
  414. NTSTATUS
  415. NlBrowserRenameDomain(
  416. IN LPWSTR OldDomainName OPTIONAL,
  417. IN LPWSTR NewDomainName
  418. );
  419. NET_API_STATUS
  420. NlBrowserGetTransportList(
  421. OUT PLMDR_TRANSPORT_LIST *TransportList
  422. );
  423. VOID
  424. NlBrowserSyncHostedDomains(
  425. VOID
  426. );
  427. VOID
  428. NlMailslotPostRead(
  429. IN BOOLEAN IgnoreDuplicatesOfPreviousMessage
  430. );
  431. BOOL
  432. NlMailslotOverlappedResult(
  433. OUT LPBYTE *Message,
  434. OUT PULONG BytesRead,
  435. OUT LPWSTR *TransportName,
  436. OUT PNL_TRANSPORT *Transport,
  437. OUT PSOCKADDR *ClientSockAddr,
  438. OUT LPWSTR *DestinationName,
  439. OUT PBOOLEAN IgnoreDuplicatesOfPreviousMessage,
  440. OUT PNETLOGON_PNP_OPCODE NlPnpOpcode
  441. );
  442. NET_API_STATUS
  443. NlServerComputerNameAdd(
  444. IN LPWSTR HostedDomainName,
  445. IN LPWSTR HostedServerName
  446. );
  447. //
  448. // oldstub.c
  449. //
  450. void _fgs__NETLOGON_DELTA_ENUM (NETLOGON_DELTA_ENUM * _source);
  451. // Use this to free all memory allocated by SAM.
  452. #define SamLsaFreeMemory( _X ) MIDL_user_free(_X)
  453. //
  454. // ds.c
  455. //
  456. NET_API_STATUS
  457. NlGetRoleInformation(
  458. PDOMAIN_INFO DomainInfo,
  459. PBOOLEAN IsPdc,
  460. PBOOLEAN Nt4MixedDomain
  461. );
  462. //
  463. // rgroups.c
  464. //
  465. NTSTATUS
  466. NlpExpandResourceGroupMembership(
  467. IN NETLOGON_VALIDATION_INFO_CLASS ValidationLevel,
  468. IN OUT PNETLOGON_VALIDATION_SAM_INFO4 * UserInfo,
  469. IN PDOMAIN_INFO DomainInfo
  470. );
  471. NTSTATUS
  472. NlpAddResourceGroupsToSamInfo (
  473. IN NETLOGON_VALIDATION_INFO_CLASS ValidationLevel,
  474. IN OUT PNETLOGON_VALIDATION_SAM_INFO4 *ValidationInformation,
  475. IN PSAMPR_PSID_ARRAY ResourceGroups
  476. );
  477. #endif // _DC_NETLOGON
  478. //
  479. // nltrace.c
  480. //
  481. ULONG
  482. _stdcall
  483. NlpInitializeTrace(PVOID Param);
  484. VOID
  485. NlpTraceEvent(
  486. IN ULONG WmiEventType,
  487. IN ULONG TraceGuid );
  488. VOID
  489. NlpTraceServerAuthEvent(
  490. IN ULONG WmiEventType,
  491. IN LPWSTR ComputerName,
  492. IN LPWSTR AccountName,
  493. IN NETLOGON_SECURE_CHANNEL_TYPE SecureChannelType,
  494. IN PULONG NegotiatedFlags,
  495. IN NTSTATUS Status
  496. );
  497. //
  498. // The following "typedef enum" actually is the index of LPGUID in
  499. // the table of NlpTraceGuids[] (defined in nltrace.c). We should
  500. // always change NlpTraceGuids[] if we add any other entry
  501. // in the following enum type.
  502. //
  503. typedef enum _NLPTRACE_GUID {
  504. NlpGuidServerAuth,
  505. NlpGuidSecureChannelSetup
  506. } NLPTRACE_GUID;
  507. //
  508. // parse.c
  509. //
  510. NET_API_STATUS
  511. NlParseOne(
  512. IN LPNET_CONFIG_HANDLE SectionHandle,
  513. IN BOOL GpSection,
  514. IN LPWSTR Keyword,
  515. IN ULONG DefaultValue,
  516. IN ULONG MinimumValue,
  517. IN ULONG MaximumValue,
  518. OUT PULONG Value
  519. );