我可以创建一个与提交按钮一样工作的 CommandLink 吗?
请理解我缺乏写作技巧.
Please understand my lack of writing skills.
我正在测试以制作自定义凭据提供程序.我想创建一个 CommandLink
与提交按钮做同样的事情.我想通过 CommandLink
与提交按钮分开登录.目前,只有自定义凭据提供程序通过 providerFilter::Filter(CREDENTIAL_PROVIDER_USAGE_SCENARIO cpu, DWORD dwFlags, GUID* rgclsidProviders, BOOL* rgbAllow, DWORD cProviders)
公开.点击【anathor longon button】登录.
I am testing to make a custom credential provider.
I want to create a CommandLink
that does the same thing with the submit button.
I want to log on through the CommandLink
separately from the Submit button.
Currently, only the custom credential provider is exposed through the providerFilter::Filter(CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus, DWORD dwFlags, GUID* rgclsidProviders, BOOL* rgbAllow, DWORD cProviders)
.
Click [anathor longon button] to log on.
这是我的示例代码:
HRESULT CSampleCredential::CommandLinkClicked(DWORD dwFieldID)
{
HRESULT hr = S_OK;
DWORD dwResult = 0;
if (dwFieldID < ARRAYSIZE(_rgCredProvFieldDescriptors) &&
(CPFT_COMMAND_LINK == _rgCredProvFieldDescriptors[dwFieldID].cpft))
{
HWND hwndOwner = nullptr;
switch (dwFieldID)
{
case SFI_ANATHOR_SUBMIT_LINK:
dwResult = function_foo();
if(dwResult == 1) {
Call GetSerialization()...?
Run the logon.
}
break;
// ...
}
}
}
因为您正在编写凭证提供程序,所以您已经在实现 ICredentialProvider
接口及其 Advise
方法:
Because you are writing credential provider, than you are already implementing ICredentialProvider
interface and its Advise
method:
virtual HRESULT STDMETHODCALLTYPE Advise(
/* [annotation][in] */
_In_ ICredentialProviderEvents *pcpe,
/* [annotation][in] */
_In_ UINT_PTR upAdviseContext) = 0;
第一个参数是指向事件接口 ICredentialProviderEvents
的指针,它只有一个方法:CredentialsChanged
.您的任务是从用户(登录名/密码)那里获取凭据,将它们存储在您的内部并调用此方法.在下一个回合,您的提供者将被称为此方法:
The first argument is pointer to events interface ICredentialProviderEvents
which have only one method: CredentialsChanged
.
Your task is to grab credentials from user (login/password) store them inside your internals and call this method.
On the next turn your provider will be called this method:
virtual HRESULT STDMETHODCALLTYPE GetCredentialCount(
/* [annotation][out] */
_Out_ DWORD *pdwCount,
/* [annotation][out] */
_Out_ DWORD *pdwDefault,
/* [annotation][out] */
_Out_ BOOL *pbAutoLogonWithDefault) = 0;
您的任务是在 pdwDefault
和 pbAutoLogonWithDefault
参数中返回正确的值(我的建议是 0
和 TRUE
).比实现 ICredentialProviderCredential
接口的类将立即为 GetSerialization
方法调用.
Your task is to return the correct values in pdwDefault
and pbAutoLogonWithDefault
parameters (my suggest is 0
and TRUE
).
Than your class that implementing ICredentialProviderCredential
interface will be immediately called for GetSerialization
method.
您可以在此处返回已存储的凭据.
Here you can return already stored credentials.