views:

106

answers:

1

Hi!

I'm using Windows XP Pro SP3. I want to use SSPI functions in my code. I compiled my code, no error.

I set the security package to be used to Negotiate, which is recommended.

When I start my program, Negotiate cannot be used because it can't be found. So, I tried "Kerberos" instead, and same error: the security package cannot be found.

I had a look at the registry, and according to that key: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/Security Packages, the security packages available are: kerberos, msv1_0, schannel, wdigest. Negotiate and NTLM are missing.

I don't understand why my program can't find any security package. The returned error code is 0x80090305 and I couldn't find any hint about a way to fix it.

So, if you master the SSPI, please I need your help! Do I have something to modify in the registry? Or maybe I need to register some DLLs?

Thanks for any hint Bye!

+1  A: 

SSPI is a cow to debug without code :)

Try this code, see if it works, if it does, re-try it and replace NTLM with Negotiate. Actually, rather than using the word, "Negotiate" #include "security.h" and use NEGOSSP_NAME.

Also, try this, and see if Negotiate is in the list:

int main(int argc, _TCHAR* argv[]) { ULONG cPackages = 0; PSecPkgInfo pInfo = NULL; SECURITY_STATUS stat = EnumerateSecurityPackages(&cPackages, &pInfo); if (stat == SEC_E_OK) { for (ULONG i = 0; i < cPackages; i++) { wprintf(L"%s\t%s\n",pInfo[i].Name, pInfo[i].Comment); } FreeContextBuffer(pInfo); } return 0; }

make sure you define SECURITY_WIN32 in your header, and link with secur32.

Michael Howard-MSFT
one other thought - you know SSPI works in Unicode, right?? Always Unicode! Never ASCII :)If you passed in an ASCII string to an SSPI function, it would look like Unicode goo! So make sure that if you *DO* use a string constant, prepend an 'L' to the string:Don't use: char *szName = "Negotiate";Use: wchar_t *wszName = L"Negotiate";lemme know :)
Michael Howard-MSFT
Thank you very much for your help!The result is: Negotiate is in the list, as well as Keberos, NTLM, Schannel, WDigest, ...Now I've got to adapt my code to unicode and see if it works :)
Doo Dee
Thank you very much Michael, now my server works like a charm! :)
Doo Dee