0

I've been trying to create a program to efficiently validate user credentials locally, without the client and server handling LogonUser() provides. I've ran into trouble getting the InitializeSecurityContext() function from both the security.dll and secur32.dll , and have been getting the error message mentioned in the title. I've tried to look at different documentation to see if it is no longer a supported function, but I couldn't find anything that said it was. I'm performing the operation much the same as the Microsoft example here.

How I load the function :

#ifdef UNICODE
    security.AcquireCredentialsHandle = ( ACQUIRE_CREDENTIALS_HANDLE_FN )GetProcAddress( hdll, "AcquireCredentialsHandleW" );
    security.InitializeSecurityContext = ( INITIALIZE_SECURITY_CONTEXT_FN )GetProcAddress( hdll, "InitializeSecurityContextW" );
    security.QuerySecurityPackageInfo = ( QUERY_SECURITY_PACKAGE_INFO_FN )GetProcAddress( hdll, "QuerySecurityPackageInfoW" );
#else
    security.AcquireCredentialsHandle = ( ACQUIRE_CREDENTIALS_HANDLE_FN )GetProcAddress( hdll, "AcquireCredentialsHandleA" );
    security.QuerySecurityPackageInfo = ( QUERY_SECURITY_PACKAGE_INFO_FN )GetProcAddress( hdll, "QuerySecurityPackageInfoA" );
    security.InitializeSecurityContext = ( INITIALIZE_SECURITY_CONTEXT_FN )GetProcAddress( hdll, "InitializeSecurityContextA" );
#endif

My check for errors :

if ( !security.InitializeSecurityContext )
       return LoadingError( showError, exit );

All the other functions load without problems.

As a bonus, it would be nice if someone could point out what exactly I need to call to simply authenticate a local username and password. The Microsoft example is a little overwhelming to look through, and I'm not sure what applies to my situation yet. If you guys think that it would be better for me to figure that out on my own, that's fine.

user3476738
  • 176
  • 2
  • 11

1 Answers1

0

according to the documentation InitializeSecurityContext() is defined in Security.h and Secur32.lib so you really don't need GetProcAddress() to get it. just #include this header and like to this lib.

same goes for QuerySecurityPackageInfo() and AcquireCredentialsHandle()

shoosh
  • 70,450
  • 50
  • 199
  • 310
  • I was worried about not having the extra support. I need support for Windows XP and later. Otherwise I would statically link to the library. Unless secur32.dll is available for use in Windows XP too? – user3476738 Apr 11 '14 at 23:59
  • the docs of each function says since when it is supported. All of these functions are documented to be available in XP. At any rate, If they weren't, `GetProcAddress()` would not have been able to find functions that are not there. Also, XP is EOL. – shoosh Apr 12 '14 at 00:07
  • I suppose I'll try just statically linking it. I realize that XP is no longer supported by Microsoft, but I still have one at home and haven't bought a new computer yet. The reason I thought I might need to dynamically link the DLL was because the example's comments mentioned some of the old operating systems only had security.dll. I'm not using Windows XP right now, I'm using Windows 7( visiting someone ). – user3476738 Apr 12 '14 at 00:17