VBoxAuthSimple.cpp revision 6754e49069315bd28137abb0f9241e3aeb99a97e
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * VBox Remote Desktop Protocol:
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync * External Authentication Library:
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync * Simple Authentication.
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync * Copyright (C) 2006-2010 Oracle Corporation
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * available from http://www.virtualbox.org. This file is free software;
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsyncusing namespace com;
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync/* If defined, debug messages will be written to the specified file. */
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync//#define VRDPAUTH_DEBUG_FILE_NAME "/tmp/VRDPAuth.log"
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsyncDECLEXPORT(VRDPAuthResult) VRDPAUTHCALL VRDPAuth2(PVRDPAUTHUUID pUuid,
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync const char *szUser,
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync const char *szDomain,
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync /* default is failed */
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync /* only interested in logon */
282f5fe327c5d622addc8b943407a35d8b192a19vboxsync /* return value ignored */
282f5fe327c5d622addc8b943407a35d8b192a19vboxsync RTUuidToStr((PCRTUUID)pUuid, (char*)uuid, RTUUID_STR_LENGTH);
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync /* the user might contain a domain name, split it */
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync dprintf("VBoxAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user, szPassword);
6cf438776892898b86c5c34c92e32fc446b057d2vboxsync rc = virtualBox.createLocalObject(CLSID_VirtualBox);
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync Bstr key = BstrFmt("VBoxAuthSimple/users/%s", user);
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync /* lookup in VM's extra data? */
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync virtualBox->GetMachine(Bstr(uuid).raw(), machine.asOutParam());
6cf438776892898b86c5c34c92e32fc446b057d2vboxsync machine->GetExtraData(key.raw(), password.asOutParam());
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync /* lookup global extra data */
1319c68f8bf1c1195c93ecf9acccf19354d91ba8vboxsync virtualBox->GetExtraData(key.raw(), password.asOutParam());
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync /* calculate hash */
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync RTSha256(szPassword, strlen(szPassword), abDigest);
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest));
5a8ae0443b7be3b1a5501bd101b1533daa844c23vboxsync/* Verify the function prototype. */