Hey Folks,
C++ noob here wonding how i can authenticate a Windows User via Java servlet.
Here is the code i have put together to take in a JNI call from my java servlet with the user's username domain and password:
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include "Validate.h"
JNIEXPORT jstring JNICALL Java_Validate_takeInfo(JNIEnv *env, jobject obj, jstring domain, jstring id, jstring idca, jstring password)
{
const char *nt_domain;
const char *nt_id;
const char *nt_idca;
const char *nt_password;
nt_domain = env->GetStringUTFChars(domain, NULL);
nt_id = env->GetStringUTFChars(id, NULL);
nt_idca= env->GetStringUTFChars(idca, NULL);
nt_password = env->GetStringUTFChars(password, NULL);
handle hToken = 0;
char *otherString;
otherString = LogonUser(nt_id, nt_domain, nt_password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hToken );
jstring newString = env->NewStringUTF((const char*)otherString);
return newString;
}
I get these errors when trying to compile:
D:\JNI\Validate.cpp(21) : error C2065: 'handle' : undeclared identifier
D:\JNI\Validate.cpp(21) : error C2146: syntax error : missing ';' before
ier 'hToken'
D:\JNI\Validate.cpp(21) : error C2065: 'hToken' : undeclared identifier
D:\JNI\Validate.cpp(24) : error C2065: 'LOGON32_LOGON_NETWORK' : undeclar
tifier
D:\JNI\Validate.cpp(24) : error C2065: 'LOGON32_PROVIDER_DEFAULT' : undec
dentifier
D:\JNI\Validate.cpp(24) : error C3861: 'LogonUser': identifier not found
I am assuming i am not including something i need. Any help is greatly appreciated.