gpt4 book ai didi

c - AcquireCredentialsHandle 失败

转载 作者:太空宇宙 更新时间:2023-11-04 04:07:36 24 4
gpt4 key购买 nike

我有一段代码试图为我无法工作的远程计算机上的用户获取凭据。目前这会在运行时产生访问冲突错误 (0xc0000005):


SEC_WINNT_AUTH_IDENTITY_W identity;
ZeroMemory(&identity, sizeof(identity));

identity.Domain = (unsigned short *)_T("DOMAIN");
identity.DomainLength = lstrlenW(_T("DOMAIN"));
identity.User = (unsigned short *)_T("USER");
identity.UserLength = lstrlenW(_T("USER"));
identity.Password = (unsigned short *)_T("PASS");
identity.PasswordLength = lstrlenW(_T("PASS"));
identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

PCredHandle credentials = NULL;
PTimeStamp credentialsExpiry = NULL;

SECURITY_STATUS result = AcquireCredentialsHandleW(_T("USER"), _T("NTLM"), SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, credentials, credentialsExpiry);

我不知道为什么。非常欢迎任何帮助。

最佳答案

您需要将最后一段代码更改为如下所示:

CredHandle credentials;
TimeStamp credentialsExpiry;

SECURITY_STATUS result = AcquireCredentialsHandleW(_T("USER"), _T("NTLM"),
SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL,
&credentials, &credentialsExpiry);

根据 MSDN docs ,最后 2 个参数中的指针在您的调用中不是可选的:

phCredential [out]

A pointer to aCredHandle structure to receive thecredential handle.

ptsExpiry [out]

A pointer to aTimeStamp structure that receives thetime at which the returned credentialsexpire. The value returned in thisTimeStamp structure depends on thesecurity package. The security packagemust return this value in local time.

This parameter is set to a constantmaximum time. There is no expirationtime for Digest security contexts orcredentials or when using the DigestSSP.

When using the Schannel SSP, thisparameter is optional. When thecredential to be used forauthentication is a certificate, thisparameter receives the expiration timefor that certificate. If nocertificate was supplied, then amaximum time value is returned.

关于c - AcquireCredentialsHandle 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3956775/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com