Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Username and Password
Message
De
20/01/2007 00:34:04
 
 
À
19/01/2007 21:13:33
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01187287
Message ID:
01187305
Vues:
19
>Take a look message Nt Authenticate Message#912478
>
>>Hello All!
>>
>>I would like to use the user name and password from the network in my programs. Is this possible? anybody has code for this?
>>
>>Highly appreciate the help.
>>
>>TIA,
>>Ryan
#define LOGON32_PROVIDER_DEFAULT	0
#define LOGON32_LOGON_NETWORK		3

if not ValidatePassword('ASDFDOMAIN', 'Ryan', 'ASDF123')
     quit
endif


function ValidatePassword(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.
     messagebox("Correct Password")
else
	llResult		= .F.
	* Do something with GetLastError()\
      messagebox("Wrong Passowrd")
endif

return llResult
i tried this but it does'nt work! Did I miss anything.

regards,
ryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform