Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verfity a user with active directory
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01589992
Message ID:
01590557
Views:
67
Likes (1)
You can try to create a LogonSession, which requires the password, and if successful then it is validated, they need to trust that your program is not stealing the passwords thou...
#define LOGON32_PROVIDER_DEFAULT	0
#define LOGON32_LOGON_NETWORK		3


? validatepassword(,,InputBox('Enter password'))

function ValidatePassword
lparameters tcDomain, tcUser, tcPassword
local lnToken, llResult, lcUser, lcDomain, lcPassword

lcDomain		= Iif(Vartype(tcDomain) # 'C' or Empty(tcDomain), Getenv('UserDomain'), Alltrim(tcDomain))
lcUser			= Iif(Vartype(tcUser) # 'C' or Empty(tcUser), Getenv('UserName'), Alltrim(tcUser))
lcPassword		= Iif(Vartype(tcPassword) # 'C', '', tcPassword)

declare LogonUser in AdvAPI32 ;
	String	lpszUsername, ;
	String	lpszDomain, ;
	String	lpszPassword, ;
	Integer	dwLogonType, ;
	Integer	dwLogonProvider, ;
	Long	@ phToken ;
	
declare CloseHandle in Kernel32 ;
	integer	hObject

declare SetLastError in win32api ;
	integer	dwErrCode
	
declare integer GetLastError in WIN32API

SetLastError(0)

lnToken			= 0
llResult		= LogonUser(lcUser, lcDomain, lcPassword, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, @lnToken)

if llResult and lnToken # 0
	CloseHandle(lnToken)
	llResult		= .T.
else
	llResult		= .F.
	* Do something with GetLastError()
endif

return llResult
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform