Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Authentication Challenge - Local / Domainless 1

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,207
0
0
US
I am looking to take a user's username and password and verify it is valid against the local Windows system, a machine not on a domain.

Anyone done such a thing or have a start? I'm looking to avoid doing the same with a table. I don't care about opinions of the merits or alternative designs as this is for a system with more than a decade of developed complexity with a new requirement of authenticated sign-off for each record.
 
here's one way:

Code:
[blue]Option Explicit

Private Declare Function LogonUser Lib "Advapi32" Alias "LogonUserA" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, phToken As Long) As Long
Private Const LOGON32_LOGON_INTERACTIVE = 2
Private Const LOGON32_PROVIDER_DEFAULT = 0

Private Function VerifyLogin(strUserName As String, strPassword As String) As Boolean
    Dim token As Long
    [green]' Change the second parameter to the domain name if you want to verify a domain login[/green]
    LogonUser strUserName, ".", strPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token
    VerifyLogin = token
End Function[/blue]
 
Thanks for the code but I struck out.

Windows Server 2008 Standard - It is a remote hosted system. I tried replacing the dot domain parameter with the computer name and struck out. It is a 64 bit machine.
 
No, LoginUser only works locally, which is what you implied you wanted in your original post
 
To clarify it is a Windows Server 2008 Standard system running access locally accessed via remote desktop... and it did not work.
 
For others, Replacing the period or dot with the Netbios Domain did work on my on site system where there is a domain. On my Windows 7 client, 64bit, this is displayed as the user logged in as DOMAIN\USERNAME when the machine is locked. DOMAIN is the Netbios domain name.

Worth noting is that this company does odd things to Windows so this may vary.

Having said that, the hosted computer where I want it to run locally but remote desktop to (mostly other third parties) is plain Windows.

 
I know. It can't. It is a deliberate limitation of the API call. I think it is pretty easy to understand why Microsoft might not want an easy API call that allows you to remotely test username/password combinations for validity ...
 
It works when I make the domain a zero length string and not a period.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top