2009-06-15 9 views
0

C++ Noob ici wonding comment je peux authentifier un utilisateur Windows via servlet Java.JNI Appel pour authentifier l'utilisateur en utilisant LogonUser?

Voici le code que je l'ai mis en place pour prendre un appel JNI de mon servlet java avec le domaine de nom d'utilisateur et mot de passe de l'utilisateur:

#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; 
} 

Je reçois ces erreurs lorsque vous essayez de compiler:

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 

Je suppose que je ne suis pas quelque chose que je dois y compris. Toute aide est grandement appréciée.

Répondre

0

Que votre compilateur n'a pas pu trouver LogonUser suggère que vous manque les en-têtes des fenêtres. Inclure windows.h

De plus, les fenêtres génériques poignée type est orthographié MANCHE, tous en majuscules.

Voir the LogonUser docs pour plus de détails.

Questions connexes