4 #include <winpr/sspi.h>
5 #include <winpr/winpr.h>
7 static const char* test_User =
"User";
8 static const char* test_Domain =
"Domain";
9 static const char* test_Password =
"Password";
11 int TestAcquireCredentialsHandle(
int argc,
char* argv[])
14 SECURITY_STATUS status = 0;
17 SEC_WINNT_AUTH_IDENTITY identity;
18 SecurityFunctionTable* table = NULL;
19 SecPkgCredentials_Names credential_names;
25 table = InitSecurityInterfaceEx(0);
26 identity.User = (UINT16*)_strdup(test_User);
27 identity.Domain = (UINT16*)_strdup(test_Domain);
28 identity.Password = (UINT16*)_strdup(test_Password);
30 if (!identity.User || !identity.Domain || !identity.Password)
33 identity.UserLength = strlen(test_User);
34 identity.DomainLength = strlen(test_Domain);
35 identity.PasswordLength = strlen(test_Password);
36 identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
37 status = table->AcquireCredentialsHandle(NULL, NTLM_SSP_NAME, SECPKG_CRED_OUTBOUND, NULL,
38 &identity, NULL, NULL, &credentials, &expiration);
40 if (status != SEC_E_OK)
44 table->QueryCredentialsAttributes(&credentials, SECPKG_CRED_ATTR_NAMES, &credential_names);
46 if (status != SEC_E_OK)
52 if (SecIsValidHandle(&credentials))
53 table->FreeCredentialsHandle(&credentials);
56 free(identity.Domain);
57 free(identity.Password);