I have a piece of code that attempts to acquire the credentials for a user on a remote computer which I cant get working. currently this produces an access violation error (0xc0000005) when run:
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);
and i have no idea why. any assistance would be very welcome.
You need to change the last section of code to look like this:
Per MSDN docs, the pointers in the last 2 parameters are not optional on your call: