ドメインに参加していないコンピュータでユーザーのWindows資格情報を検証しようとしています。これはSSPI APIの使用が可能になるはずですが、動作させることができませんでした。異なるドメインのWindowsユーザー資格情報の検証
私が試していたコードが含まれています(簡潔さのためにリソースのクリーンアップが省略されています)。 「 beesly
(I:
ドメイン control.dundermifflin.com: DUNDERMIFFLIN
ユーザー: jim_halpert
パス
ドメインコントローラ:これらは、重要な情報です実際のdundermifflin.comとのDNS競合はありません。
私が得るエラーはSEC_E_LOGON_DENIEDです。私はそのユーザーと他のアプリケーションでログオンできるので、ユーザー名とパスワードが正しいと確信しています。誰かが私を正しい方向に向けることができますか?
#include <Windows.h>
#define SECURITY_WIN32
#include <Security.h>
#include <crtdbg.h>
#pragma comment(lib, "Secur32.lib")
int main()
{
SEC_CHAR* principal = "HOST/control.dundermifflin.com";
SEC_CHAR* spn = NULL;
SEC_CHAR* domain = "DUNDERMIFFLIN";
SEC_CHAR* user = "jim_halpert";
SEC_CHAR* pass = "beesly";
/////////////////////////////////////////////
// Fill out the authentication information //
/////////////////////////////////////////////
SEC_WINNT_AUTH_IDENTITY auth;
auth.Domain = reinterpret_cast<unsigned char*>(domain);
auth.DomainLength = strlen(domain);
auth.User = reinterpret_cast<unsigned char*>(user);
auth.UserLength = strlen(user);
auth.Password = reinterpret_cast<unsigned char*>(pass);
auth.PasswordLength = strlen(pass);
auth.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
////////////////////////////////////////////
// Allocate the client and server buffers //
////////////////////////////////////////////
char clientOutBufferData[8192];
char serverOutBufferData[8192];
SecBuffer clientOutBuffer;
SecBufferDesc clientOutBufferDesc;
SecBuffer serverOutBuffer;
SecBufferDesc serverOutBufferDesc;
///////////////////////////////////////////
// Get the client and server credentials //
///////////////////////////////////////////
CredHandle clientCredentials;
CredHandle serverCredentials;
SECURITY_STATUS status;
status = ::AcquireCredentialsHandle(principal,
"Negotiate",
SECPKG_CRED_OUTBOUND,
NULL,
&auth,
NULL,
NULL,
&clientCredentials,
NULL);
_ASSERT(status == SEC_E_OK);
status = ::AcquireCredentialsHandle(principal,
"Negotiate",
SECPKG_CRED_INBOUND,
NULL,
NULL,
NULL,
NULL,
&serverCredentials,
NULL);
_ASSERT(status == SEC_E_OK);
//////////////////////////////////////
// Initialize the security contexts //
//////////////////////////////////////
CtxtHandle clientContext = {};
unsigned long clientContextAttr = 0;
CtxtHandle serverContext = {};
unsigned long serverContextAttr = 0;
/////////////////////////////
// Clear the client buffer //
/////////////////////////////
clientOutBuffer.BufferType = SECBUFFER_TOKEN;
clientOutBuffer.cbBuffer = sizeof clientOutBufferData;
clientOutBuffer.pvBuffer = clientOutBufferData;
clientOutBufferDesc.cBuffers = 1;
clientOutBufferDesc.pBuffers = &clientOutBuffer;
clientOutBufferDesc.ulVersion = SECBUFFER_VERSION;
///////////////////////////////////
// Initialize the client context //
///////////////////////////////////
status = InitializeSecurityContext(&clientCredentials,
NULL,
spn,
0,
0,
SECURITY_NATIVE_DREP,
NULL,
0,
&clientContext,
&clientOutBufferDesc,
&clientContextAttr,
NULL);
_ASSERT(status == SEC_I_CONTINUE_NEEDED);
/////////////////////////////
// Clear the server buffer //
/////////////////////////////
serverOutBuffer.BufferType = SECBUFFER_TOKEN;
serverOutBuffer.cbBuffer = sizeof serverOutBufferData;
serverOutBuffer.pvBuffer = serverOutBufferData;
serverOutBufferDesc.cBuffers = 1;
serverOutBufferDesc.pBuffers = &serverOutBuffer;
serverOutBufferDesc.ulVersion = SECBUFFER_VERSION;
//////////////////////////////////////////////////////
// Accept the client security context on the server //
//////////////////////////////////////////////////////
status = AcceptSecurityContext(&serverCredentials,
NULL,
&clientOutBufferDesc,
0,
SECURITY_NATIVE_DREP,
&serverContext,
&serverOutBufferDesc,
&serverContextAttr,
NULL);
_ASSERT(status == SEC_I_CONTINUE_NEEDED);
/////////////////////////////
// Clear the client buffer //
/////////////////////////////
clientOutBuffer.BufferType = SECBUFFER_TOKEN;
clientOutBuffer.cbBuffer = sizeof clientOutBufferData;
clientOutBuffer.pvBuffer = clientOutBufferData;
clientOutBufferDesc.cBuffers = 1;
clientOutBufferDesc.pBuffers = &clientOutBuffer;
clientOutBufferDesc.ulVersion = SECBUFFER_VERSION;
///////////////////////////////////////
// Give the client the server buffer //
///////////////////////////////////////
status = InitializeSecurityContext(&clientCredentials,
&clientContext,
spn,
0,
0,
SECURITY_NATIVE_DREP,
&serverOutBufferDesc,
0,
&clientContext,
&clientOutBufferDesc,
&clientContextAttr,
NULL);
_ASSERT(status == SEC_E_OK);
//////////////////////////////////////////////////////
// Accept the client security context on the server //
//////////////////////////////////////////////////////
status = AcceptSecurityContext(&serverCredentials,
&serverContext,
&clientOutBufferDesc,
0,
SECURITY_NATIVE_DREP,
&serverContext,
&serverOutBufferDesc,
&serverContextAttr,
NULL);
_ASSERT(status == SEC_E_LOGON_DENIED);
}
セキュリティホールのユーザ名パス...ビットを編集したい場合があります; –