diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2010-01-15 14:02:04 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2010-01-15 14:02:04 +0000 |
commit | a97938b614a5e69a4ed1cd7a0e53c74e3b706fbc (patch) | |
tree | 81ecc15384db996aaf9de84c6a72680db824cf1a | |
parent | 11bc4cfef58cffbd8a056bd45c57281ad62d9211 (diff) | |
download | VirtualBox-svn-a97938b614a5e69a4ed1cd7a0e53c74e3b706fbc.tar.gz |
VBoxGINA: Made UI handling more modular, added new handling also to timer-based credential polling, wipe credentials on logout.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@25864 cfe28804-0f27-0410-a406-dd0f0b0b656f
-rw-r--r-- | src/VBox/Additions/WINNT/VBoxGINA/Dialog.cpp | 118 | ||||
-rw-r--r-- | src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp | 1 |
2 files changed, 62 insertions, 57 deletions
diff --git a/src/VBox/Additions/WINNT/VBoxGINA/Dialog.cpp b/src/VBox/Additions/WINNT/VBoxGINA/Dialog.cpp index dc8d0921408..eefaa72c055 100644 --- a/src/VBox/Additions/WINNT/VBoxGINA/Dialog.cpp +++ b/src/VBox/Additions/WINNT/VBoxGINA/Dialog.cpp @@ -109,6 +109,62 @@ void hookDialogBoxes(PVOID pWinlogonFunctions, DWORD dwWlxVersion) #define CREDPOLL_TIMERID 0x1243 +BOOL credentialsToUI(HWND hwndUserId, HWND hwndPassword, HWND hwndDomain) +{ + BOOL bIsFQDN = FALSE; + wchar_t szUserFQDN[512]; /* VMMDEV_CREDENTIALS_STRLEN + 255 bytes max. for FQDN */ + if (hwndDomain) + { + /* search the domain combo box for our required domain and select it */ + Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Trying to find domain entry in combo box ...\n")); + DWORD dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRING, + 0, (LPARAM)g_Domain); + if (dwIndex != CB_ERR) + { + Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Found domain at combo box pos %ld\n", dwIndex)); + SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0); + EnableWindow(hwndDomain, FALSE); + } + else + { + Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain not found in combo box ...\n")); + + /* If the domain value has a dot (.) in it, it is a FQDN (Fully Qualified Domain Name) + * which will not work with the combo box selection because Windows only keeps the + * NETBIOS names to the left most part of the domain name there. Of course a FQDN + * then will not be found by the search in the block above. + * + * To solve this problem the FQDN domain value will be appended at the user name value + * (Kerberos style) using an "@", e.g. "<user-name>@full.qualified.domain". + * + */ + size_t l = wcslen(g_Domain); + if (l > 255) + Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Warning! FQDN is too long (max 255 bytes), will be truncated!\n")); + + if ( l > 0 + && wcslen(g_Username) > 0 + && wcsstr(g_Domain, L".") != NULL) /* if we found a dot (.) in the domain name, this has to be a FQDN */ + { + Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain seems to be a FQDN!\n")); + swprintf(szUserFQDN, sizeof(szUserFQDN) / sizeof(wchar_t), L"%s@%s", g_Username, g_Domain); + bIsFQDN = TRUE; + } + } + } + if (hwndUserId) + { + if (!bIsFQDN) + SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)g_Username); + else + SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)szUserFQDN); + } + if (hwndPassword) + SendMessage(hwndPassword, WM_SETTEXT, 0, (LPARAM)g_Password); + + return TRUE; +} + INT_PTR CALLBACK MyWlxLoggedOutSASDlgProc(HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter @@ -156,60 +212,12 @@ INT_PTR CALLBACK MyWlxLoggedOutSASDlgProc(HWND hwndDlg, // handle to dialog b /* query the credentials from VBox */ if (credentialsRetrieve()) { - BOOL bIsFQDN = FALSE; - wchar_t szUserFQDN[512]; /* VMMDEV_CREDENTIALS_STRLEN + 255 bytes max. for FQDN */ - if (hwndDomain) - { - /* search the domain combo box for our required domain and select it */ - Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Trying to find domain entry in combo box ...\n")); - DWORD dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRING, - 0, (LPARAM)g_Domain); - if (dwIndex != CB_ERR) - { - Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Found domain at combo box pos %ld\n", dwIndex)); - SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0); - EnableWindow(hwndDomain, FALSE); - } - else - { - Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain not found in combo box ...\n")); - - /* If the domain value has a dot (.) in it, it is a FQDN (Fully Qualified Domain Name) - * which will not work with the combo box selection because Windows only keeps the - * NETBIOS names to the left most part of the domain name there. Of course a FQDN - * then will not be found by the search in the block above. - * - * To solve this problem the FQDN domain value will be appended at the user name value - * (Kerberos style) using an "@", e.g. "<user-name>@full.qualified.domain". - * - */ - size_t l = wcslen(g_Domain); - if (l > 255) - Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Warning! FQDN is too long (max 255 bytes), will be truncated!\n")); - - if ( l > 0 - && wcslen(g_Username) > 0 - && wcsstr(g_Domain, L".") != NULL) /* if we found a dot (.) in the domain name, this has to be a FQDN */ - { - Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain seems to be a FQDN!\n")); - swprintf(szUserFQDN, sizeof(szUserFQDN) / sizeof(wchar_t), L"%s@%s", g_Username, g_Domain); - bIsFQDN = TRUE; - } - } - } - if (hwndUserId) - { - if (!bIsFQDN) - SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)g_Username); - else - SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)szUserFQDN); - } - if (hwndPassword) - SendMessage(hwndPassword, WM_SETTEXT, 0, (LPARAM)g_Password); + /* fill in credentials to appropriate UI elements */ + credentialsToUI(hwndUserId, hwndPassword, hwndDomain); /* we got the credentials, null them out */ credentialsReset(); - + /* confirm the logon dialog, simulating the user pressing "OK" */ WPARAM wParam = MAKEWPARAM(IDOK, BN_CLICKED); PostMessage(hwndDlg, WM_COMMAND, wParam, 0); @@ -240,12 +248,8 @@ INT_PTR CALLBACK MyWlxLoggedOutSASDlgProc(HWND hwndDlg, // handle to dialog b { if (credentialsRetrieve()) { - if (hwndUserId) - SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)g_Username); - if (hwndPassword) - SendMessage(hwndPassword, WM_SETTEXT, 0, (LPARAM)g_Password); - if (hwndDomain) - SendMessage(hwndDomain, WM_SETTEXT, 0, (LPARAM)g_Domain); + /* fill in credentials to appropriate UI elements */ + credentialsToUI(hwndUserId, hwndPassword, hwndDomain); /* we got the credentials, null them out */ credentialsReset(); diff --git a/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp b/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp index a75b07c214d..6a6aae2dc3c 100644 --- a/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp +++ b/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp @@ -409,6 +409,7 @@ BOOL WINAPI WlxIsLogoffOk(PVOID pWlxContext) // if it's ok to logoff, finish with the stored credentials // and scrub the buffers // + credentialsReset(); } return bSuccess; |