VirtualBox

source: vbox/trunk/src/VBox/HostServices/auth/winlogon/winlogon.cpp@ 34906

最後變更 在這個檔案從34906是 34563,由 vboxsync 提交於 14 年 前

VRDPAuth -> VBoxAuth.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 2.9 KB
 
1/** @file
2 *
3 * VBox Remote Desktop Protocol:
4 * External Authentication Library:
5 * Windows Logon Authentication.
6 */
7
8/*
9 * Copyright (C) 2006-2010 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.alldomusa.eu.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20/* If defined, debug messages will be written to the specified file. */
21// #define AUTH_DEBUG_FILE_NAME "\\VBoxAuth.log"
22
23#include <stdio.h>
24#include <string.h>
25
26#include <Windows.h>
27
28#include <VBox/VBoxAuth.h>
29
30static void dprintf(const char *fmt, ...)
31{
32#ifdef AUTH_DEBUG_FILE_NAME
33 va_list va;
34
35 va_start(va, fmt);
36
37 char buffer[1024];
38
39 _vsnprintf (buffer, sizeof (buffer), fmt, va);
40
41 OutputDebugStringA(buffer);
42
43 FILE *f = fopen (AUTH_DEBUG_FILE_NAME, "ab");
44 if (f)
45 {
46 fprintf (f, "%s", buffer);
47 fclose (f);
48 }
49
50 va_end (va);
51#endif
52}
53
54extern "C"
55#if defined(_MSC_VER)
56__declspec(dllexport)
57#endif
58AuthResult AUTHCALL AuthEntry (const char *szCaller,
59 PAUTHUUID pUuid,
60 AuthGuestJudgement guestJudgement,
61 const char *szUser,
62 const char *szPassword,
63 const char *szDomain,
64 int fLogon,
65 unsigned clientId)
66{
67 AuthResult result = AuthResultAccessDenied;
68
69 LPTSTR lpszUsername = (char *)szUser;
70 LPTSTR lpszDomain = (char *)szDomain;
71 LPTSTR lpszPassword = (char *)szPassword;
72
73 /* LOGON32_LOGON_INTERACTIVE is intended for users who will be interactively using the computer,
74 * such as a user being logged on by a terminal server, remote shell, or similar process.
75 */
76 DWORD dwLogonType = LOGON32_LOGON_INTERACTIVE;
77 DWORD dwLogonProvider = LOGON32_PROVIDER_DEFAULT;
78
79 HANDLE hToken;
80
81 dprintf("u[%s], d[%s], p[%s]\n", lpszUsername, lpszDomain, lpszPassword);
82
83 BOOL fSuccess = LogonUser(lpszUsername,
84 lpszDomain,
85 lpszPassword,
86 dwLogonType,
87 dwLogonProvider,
88 &hToken);
89
90 if (fSuccess)
91 {
92 dprintf("LogonUser success. hToken = %p\n", hToken);
93
94 result = AuthResultAccessGranted;
95
96 CloseHandle (hToken);
97 }
98 else
99 {
100 dprintf("LogonUser failed %08X\n", GetLastError ());
101 }
102
103 return result;
104}
105
106/* Verify the function prototype. */
107static PAUTHENTRY3 gpfnAuthEntry = AuthEntry;
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette