VirtualBox

Ignore:
Timestamp:
Mar 29, 2011 8:01:56 AM (14 years ago)
Author:
vboxsync
Message:

VBoxCredProv: Implemented support for handling/ignoring remote (desktop) sessions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredProv.cpp

    r32431 r36453  
    77// Copyright (c) 2006 Microsoft Corporation. All rights reserved.
    88//
    9 // Modifications (c) 2009-2010 Oracle Corporation
     9// Modifications (c) 2009-2011 Oracle Corporation
    1010//
    1111
     
    2525    m_pCred(NULL),
    2626    m_pCredProvEvents(NULL),
    27     m_fGotCredentials(false)
     27    m_fGotCredentials(false),
     28    m_fHandleRemoteSessions(false)
    2829{
    2930    LONG l = DllAddRef();
     
    6970
    7071
     72/**
     73 * Loads the global configuration from registry.
     74 *
     75 * @return  DWORD       Windows error code.
     76 */
     77DWORD VBoxCredProv::LoadConfiguration(void)
     78{
     79    HKEY hKey;
     80    /** @todo Add some registry wrapper function(s) as soon as we got more values to retrieve. */
     81    DWORD dwRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Oracle\\VirtualBox Guest Additions\\AutoLogon",
     82                               0L, KEY_QUERY_VALUE, &hKey);
     83    if (dwRet == ERROR_SUCCESS)
     84    {
     85        DWORD dwValue;
     86        DWORD dwType = REG_DWORD;
     87        DWORD dwSize = sizeof(DWORD);
     88
     89        dwRet = RegQueryValueEx(hKey, L"HandleRemoteSessions", NULL, &dwType, (LPBYTE)&dwValue, &dwSize);
     90        if (   dwRet  == ERROR_SUCCESS
     91            && dwType == REG_DWORD
     92            && dwSize == sizeof(DWORD))
     93        {
     94            m_fHandleRemoteSessions = true;
     95        }
     96        RegCloseKey(hKey);
     97    }
     98    /* Do not report back an error here yet. */
     99    return ERROR_SUCCESS;
     100}
     101
     102
     103/**
     104 * Determines whether we should handle the current session or not.
     105 *
     106 * @return  bool        true if we should handle this session, false if not.
     107 */
     108bool VBoxCredProv::HandleCurrentSession(void)
     109{
     110    bool fHandle = false;
     111    if (isRemoteSession())
     112    {
     113        if (m_fHandleRemoteSessions) /* Force remote session handling. */
     114            fHandle = true;
     115    }
     116    else /* No remote session. */
     117        fHandle = true;
     118    return fHandle;
     119}
     120
     121
    71122/*
    72123 * SetUsageScenario is the provider's cue that it's going to be asked for tiles
     
    79130    UNREFERENCED_PARAMETER(dwFlags);
    80131    HRESULT hr;
     132    DWORD dwErr;
    81133
    82134    m_cpUsageScenario = cpUsageScenario;
     
    88140        case CPUS_LOGON:
    89141        case CPUS_UNLOCK_WORKSTATION:
     142
     143            dwErr = LoadConfiguration();
     144            if (dwErr != ERROR_SUCCESS)
     145                LogRel(("VBoxCredProv: Error while loading configuration, error=%ld\n", dwErr));
     146            /* Do not stop running on a misconfigured system. */
     147
     148            /*
     149             * If we're told to not handle the current session just bail out and let the
     150             * user know.
     151             */
     152            if (!HandleCurrentSession())
     153            {
     154                LogRel(("VBoxCredProv: Handling of remote desktop sessions is disabled.\n"));
     155                break;
     156            }
    90157
    91158            if (m_pPoller == NULL)
Note: See TracChangeset for help on using the changeset viewer.

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