Esempio n. 1
0
AUTHSSP_API
int CUPSD(const char * userin, const char *password, const char *machine)
{
	DWORD dwAccessGranted = 0;
	BOOL isAccessOK = FALSE;
	BOOL isAuthenticated = FALSE;
	bool isViewOnly = false;
	bool isInteract = false;
	TCHAR machine2[MAXSTRING];
	TCHAR user2[MAXSTRING];
#if defined(UNICODE) || defined(_UNICODE)
	mbstowcs(machine2, machine, MAXSTRING);
	mbstowcs(user2, userin, MAXSTRING);
#else
	strcpy(machine2, machine);
	strcpy(user2, userin);
#endif

	OSVERSIONINFO VerInfo;
	VerInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
	if (!GetVersionEx (&VerInfo)) {  // If this fails, something has gone wrong
		return FALSE;
	}
	
	if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) { // WinNT 3.51 or better 
		vncAccessControl vncAC;
		isAccessOK = CUPSD2(userin, password, vncAC.GetSD(), &isAuthenticated, &dwAccessGranted);
		// This logging should be moved to LOGLOGONUSER etc.
            time_t current;
			time(&current);
			char* timestr = ctime(&current);
			timestr[24] = '\0'; // remove newline
			LOG(0, "%s - CUPSD2: Access is %u, user %s is %sauthenticated, access granted is 0x%x\n",
				timestr, isAccessOK, userin, isAuthenticated ? "" : "not ", (int) dwAccessGranted);
	} else { // message text to be moved to localization.h
		MessageBox(NULL, _T("New MS-Logon currently not supported on Win9x"), _T("Warning"), MB_OK);
		return FALSE;
	}

	if (isAccessOK) {
		if (dwAccessGranted & ViewOnly) isViewOnly = true;
		if (dwAccessGranted & Interact) isInteract = true;
	}
	
	//LookupAccountName(NULL, user2, Sid, cbSid, DomainName, cbDomainName, peUse);

	if (isInteract)	{
		LOG(0x00640001L, _T("Connection received from %s using %s account\n"), machine2, user2);
	} else if (isViewOnly) {
		LOG(0x00640001L, _T("Connection received from %s using %s account\n"), machine2, user2);
		isAccessOK = 2;
	} else {
		LOG(0x00640002L, _T("Invalid attempt (not %s) from client %s using %s account\n"), 
			isAuthenticated ? _T("authorized") : _T("authenticated"), machine2, user2);
	}
	return isAccessOK;
}
Esempio n. 2
0
int CheckUserGroupPasswordUni(char * userin,char *password,const char *machine)
{
	TCHAR user2[MAXSTRING];
#if defined(UNICODE) || defined(_UNICODE)
	mbstowcs(user2, userin, MAXSTRING);
#else
	strcpy(user2, userin);
#endif

	return CUPSD2(user2, password);
}
Esempio n. 3
0
bool LogonAuthentication::authenticateUser( const AuthenticationCredentials &cred )
{
	qDebug() << "Authenticating user" << cred.logonUsername();

	bool result = false;
#ifdef ITALC_BUILD_WIN32
#ifdef UNICODE
	return CUPSD2( (const char *) cred.logonUsername().unicode(), (const char *) cred.logonPassword().unicode() );
#else
	return CUPSD2( cred.logonUsername().toLocal8Bit().constData(), cred.logonPassword().toLocal8Bit().constData() );
#endif
#endif

#ifdef ITALC_BUILD_LINUX
	QProcess p;
	p.start( "italc-auth-helper" );
	p.waitForStarted();

	QDataStream ds( &p );
	ds << cred.logonUsername();
	ds << cred.logonPassword();

	p.closeWriteChannel();
	p.waitForFinished();

	if( p.exitCode() == 0 )
	{
		result = true;
		qDebug() << "User authenticated successfully";
	}
	else
	{
		qCritical() << "ItalcAuthHelper failed:" << p.readAll().trimmed();
	}
#endif

	return result;
}