blob: 22efcc0c4c1ed2f546995fb115de9dff43697e21 [file] [log] [blame]
Adam Tkac69df3762010-11-02 09:16:49 +00001/* Copyright (C) 2005-2006 Martin Koegler
2 * Copyright (C) 2006 OCCAM Financial Technology
3 * Copyright (C) 2010 TigerVNC Team
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */
20
21#include <rfb/WinPasswdValidator.h>
22#include <windows.h>
23#include <tchar.h>
24
25using namespace rfb;
26
27// This method will only work for Windows NT, 2000, and XP (and possibly Vista)
28bool WinPasswdValidator::validateInternal(rfb::SConnection* sc,
29 const char* username,
30 const char* password)
31{
32 TCHAR* user = (TCHAR*) strDup(username);
33 TCHAR* pass = (TCHAR*) strDup(password);
34 TCHAR* domain = (TCHAR*) strDup(".");
35 HANDLE handle;
36
37 BOOL ret = LogonUser(user, domain, pass, LOGON32_LOGON_NETWORK,
38 LOGON32_PROVIDER_DEFAULT, &handle);
39 delete [] user;
40 delete [] pass;
41 delete [] domain;
42
43 if (ret != 0) {
44 CloseHandle(handle);
45 return true;
46 }
47
Adam Tkac69df3762010-11-02 09:16:49 +000048 return false;
49}