Changeset 25864 in vbox for trunk/src/VBox
- Timestamp:
- Jan 15, 2010 2:02:04 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxGINA
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxGINA/Dialog.cpp
r25850 r25864 110 110 #define CREDPOLL_TIMERID 0x1243 111 111 112 BOOL credentialsToUI(HWND hwndUserId, HWND hwndPassword, HWND hwndDomain) 113 { 114 BOOL bIsFQDN = FALSE; 115 wchar_t szUserFQDN[512]; /* VMMDEV_CREDENTIALS_STRLEN + 255 bytes max. for FQDN */ 116 if (hwndDomain) 117 { 118 /* search the domain combo box for our required domain and select it */ 119 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Trying to find domain entry in combo box ...\n")); 120 DWORD dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRING, 121 0, (LPARAM)g_Domain); 122 if (dwIndex != CB_ERR) 123 { 124 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Found domain at combo box pos %ld\n", dwIndex)); 125 SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0); 126 EnableWindow(hwndDomain, FALSE); 127 } 128 else 129 { 130 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain not found in combo box ...\n")); 131 132 /* If the domain value has a dot (.) in it, it is a FQDN (Fully Qualified Domain Name) 133 * which will not work with the combo box selection because Windows only keeps the 134 * NETBIOS names to the left most part of the domain name there. Of course a FQDN 135 * then will not be found by the search in the block above. 136 * 137 * To solve this problem the FQDN domain value will be appended at the user name value 138 * (Kerberos style) using an "@", e.g. "<user-name>@full.qualified.domain". 139 * 140 */ 141 size_t l = wcslen(g_Domain); 142 if (l > 255) 143 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Warning! FQDN is too long (max 255 bytes), will be truncated!\n")); 144 145 if ( l > 0 146 && wcslen(g_Username) > 0 147 && wcsstr(g_Domain, L".") != NULL) /* if we found a dot (.) in the domain name, this has to be a FQDN */ 148 { 149 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain seems to be a FQDN!\n")); 150 swprintf(szUserFQDN, sizeof(szUserFQDN) / sizeof(wchar_t), L"%s@%s", g_Username, g_Domain); 151 bIsFQDN = TRUE; 152 } 153 } 154 } 155 if (hwndUserId) 156 { 157 if (!bIsFQDN) 158 SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)g_Username); 159 else 160 SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)szUserFQDN); 161 } 162 if (hwndPassword) 163 SendMessage(hwndPassword, WM_SETTEXT, 0, (LPARAM)g_Password); 164 165 return TRUE; 166 } 167 112 168 INT_PTR CALLBACK MyWlxLoggedOutSASDlgProc(HWND hwndDlg, // handle to dialog box 113 169 UINT uMsg, // message … … 157 213 if (credentialsRetrieve()) 158 214 { 159 BOOL bIsFQDN = FALSE; 160 wchar_t szUserFQDN[512]; /* VMMDEV_CREDENTIALS_STRLEN + 255 bytes max. for FQDN */ 161 if (hwndDomain) 162 { 163 /* search the domain combo box for our required domain and select it */ 164 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Trying to find domain entry in combo box ...\n")); 165 DWORD dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRING, 166 0, (LPARAM)g_Domain); 167 if (dwIndex != CB_ERR) 168 { 169 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Found domain at combo box pos %ld\n", dwIndex)); 170 SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0); 171 EnableWindow(hwndDomain, FALSE); 172 } 173 else 174 { 175 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain not found in combo box ...\n")); 176 177 /* If the domain value has a dot (.) in it, it is a FQDN (Fully Qualified Domain Name) 178 * which will not work with the combo box selection because Windows only keeps the 179 * NETBIOS names to the left most part of the domain name there. Of course a FQDN 180 * then will not be found by the search in the block above. 181 * 182 * To solve this problem the FQDN domain value will be appended at the user name value 183 * (Kerberos style) using an "@", e.g. "<user-name>@full.qualified.domain". 184 * 185 */ 186 size_t l = wcslen(g_Domain); 187 if (l > 255) 188 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Warning! FQDN is too long (max 255 bytes), will be truncated!\n")); 189 190 if ( l > 0 191 && wcslen(g_Username) > 0 192 && wcsstr(g_Domain, L".") != NULL) /* if we found a dot (.) in the domain name, this has to be a FQDN */ 193 { 194 Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain seems to be a FQDN!\n")); 195 swprintf(szUserFQDN, sizeof(szUserFQDN) / sizeof(wchar_t), L"%s@%s", g_Username, g_Domain); 196 bIsFQDN = TRUE; 197 } 198 } 199 } 200 if (hwndUserId) 201 { 202 if (!bIsFQDN) 203 SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)g_Username); 204 else 205 SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)szUserFQDN); 206 } 207 if (hwndPassword) 208 SendMessage(hwndPassword, WM_SETTEXT, 0, (LPARAM)g_Password); 215 /* fill in credentials to appropriate UI elements */ 216 credentialsToUI(hwndUserId, hwndPassword, hwndDomain); 209 217 210 218 /* we got the credentials, null them out */ 211 219 credentialsReset(); 212 220 213 221 /* confirm the logon dialog, simulating the user pressing "OK" */ 214 222 WPARAM wParam = MAKEWPARAM(IDOK, BN_CLICKED); … … 241 249 if (credentialsRetrieve()) 242 250 { 243 if (hwndUserId) 244 SendMessage(hwndUserId, WM_SETTEXT, 0, (LPARAM)g_Username); 245 if (hwndPassword) 246 SendMessage(hwndPassword, WM_SETTEXT, 0, (LPARAM)g_Password); 247 if (hwndDomain) 248 SendMessage(hwndDomain, WM_SETTEXT, 0, (LPARAM)g_Domain); 251 /* fill in credentials to appropriate UI elements */ 252 credentialsToUI(hwndUserId, hwndPassword, hwndDomain); 249 253 250 254 /* we got the credentials, null them out */ -
trunk/src/VBox/Additions/WINNT/VBoxGINA/VBoxGINA.cpp
r21228 r25864 410 410 // and scrub the buffers 411 411 // 412 credentialsReset(); 412 413 413 414 }
Note:
See TracChangeset
for help on using the changeset viewer.