VBoxCredential.cpp revision f71804b40936663bf3cba489497c7b779e6f1f0a
2N/A// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 2N/A// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 2N/A// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 2N/A// PARTICULAR PURPOSE. 2N/A// Copyright (c) 2006 Microsoft Corporation. All rights reserved. 2N/A// Modifications (c) 2009-2010 Oracle Corporation 2N/A Log((
"VBoxCredential::VBoxCredential\n"));
2N/A Log((
"VBoxCredential::~VBoxCredential\n"));
2N/A // CoTaskMemFree (below) deals with NULL, but StringCchLength does not. // TODO: Determine how to handle count error here. /** @todo securely clear other fields (user name, domain, ...) as well. */ /* Convert credentials to unicode. */ Log((
"VBoxCredential::Update: user=%ls, pw=%ls, domain=%ls\n",
// Initializes one credential with the field information passed in. // Set the value of the SFI_USERNAME field to pwzUsername. // Optionally takes a password for the SetSerialization case. Log((
"VBoxCredential::Initialize: cpus=%ld, rgcpfd=%p, rgfsp=%p\n",
cpus,
rgcpfd,
rgfsp));
/* Copy the field descriptors for each field. This is useful if you want to vary the * field descriptors based on what Usage scenario the credential was created for. */ /* Fill in the default value to make winlogon happy. */ /* LogonUI calls this in order to give us a callback in case we need to notify it of anything. * Store this callback pointer for later use. */ Log((
"VBoxCredential::Advise\n"));
/* LogonUI calls this to tell us to release the callback. */ Log((
"VBoxCredential::UnAdvise\n"));
// LogonUI calls this function when our tile is selected (zoomed). // If you simply want fields to show/hide based on the selected state, // there's no need to do anything here - you can set that up in the // field definitions. But if you want to do something // more complicated, like change the contents of a field when the tile is // selected, you would do it here. Log((
"VBoxCredential::SetSelected\n"));
/* Don't do auto logon here because it would retry too often with * every credential field (user name, password, domain, ...) which makes * winlogon wait before new login attempts can be made. // Similarly to SetSelected, LogonUI calls this when your tile was selected // and now no longer is. The most common thing to do here (which we do below) // is to clear out the password field. Log((
"VBoxCredential::SetDeselected\n"));
// CoTaskMemFree (below) deals with NULL, but StringCchLength does not. // Gets info for a particular field of a tile. Called by logonUI to get information to // Sets ppwsz to the string value of the field at the index dwFieldID. // Check to make sure dwFieldID is a legitimate index. // Make a copy of the string and return that. The caller // is responsible for freeing it. Log((
"VBoxCredential::GetStringValue: dwFieldID=%ld, pwz=%ls\n",
dwFieldID, *
ppwsz));
// Sets pdwAdjacentTo to the index of the field the submit button should be // adjacent to. We recommend that the submit button is placed next to the last // field which the user is required to enter information in. Optional fields // should be below the submit button. Log((
"VBoxCredential::GetSubmitButtonValue: dwFieldID=%ld\n",
dwFieldID));
// pdwAdjacentTo is a pointer to the fieldID you want the submit button to appear next to. // Sets the value of a field which can accept a string as a value. // This is called on each keystroke when a user types into an edit field. Log((
"VBoxCredential::SetStringValue: dwFieldID=%ld, pwz=%ls\n",
dwFieldID,
pwz));
// The following methods are for logonUI to get the values of various UI elements and then communicate // to the credential about what the user did in that field. However, these methods are not implemented // because our tile doesn't contain these types of UI elements /* Gets the image to show in the user tile */ /* We don't do own bitmaps */ // Collect the username and password into a serialized credential for the correct usage scenario // (logon/unlock is what's demonstrated in this sample). LogonUI then passes these credentials // back to the system to log on. Log((
"VBoxCredential::GetSerialization: pcpgsr=%p, pcpcs=%p, ppwszOptionalStatusText=%p, pcpsiOptionalStatusIcon=%p\n",
/* Is a domain name missing? Then use the name of the local computer. */ /* Fill in the username and password. */ // Allocate copies of, and package, the strings in a binary blob // At this point the credential has created the serialized credential used for logon // By setting this to CPGSR_RETURN_CREDENTIAL_FINISHED we are letting logonUI know // that we have all the information we need and it should attempt to submit the // serialized credential. Log((
"VBoxCredential::GetSerialization: Returned 0x%08x\n",
hr));
// ReportResult is completely optional. Its purpose is to allow a credential to customize the string // and the icon displayed in the case of a logon failure. For example, we have chosen to // customize the error shown in the case of bad username/password and in the case of the account // Look for a match on status and substatus. /* Try to lookup a text message for error code */ Log((
"VBoxCredential::ReportResult: ntsStatus=%ld, ntsSubstatus=%ld, ppwszOptionalStatusText=%p, pcpsiOptionalStatusIcon=%p, dwStatusInfo=%ld, Message=%ls\n",
// Since NULL is a valid value for *ppwszOptionalStatusText and *pcpsiOptionalStatusIcon // this function can't fail.