Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Username and Password
Message
From
20/01/2007 09:33:16
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
 
 
To
20/01/2007 00:34:04
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01187287
Message ID:
01187331
Views:
20
It worked for me. The only difference I can see is we are still using 2000 server for our domain controller. After reading your question again, I am not sure this will help. You still have to supply a user and password. If you are trying to login into Sql Server using Windows authentication, you will need to setup your connection string to use trusted accounts. Sql Serger will have to be setup to accept trusted accounts as well.

>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform