We have an older VB6 application that used to run under various user’s accounts. We had to move it to a ‘public’ machine where multiple users use the same account, which is logged in automatically.
Is there a way to pop-up the official windows authentication form, have the users enter their credentials and pass me back a status weather or not authentication occurred or failed?
I could have the users enter in their username/password into a form created by myself and use the attached code to validate authentication. The problem is that this just looks sketchy to begin with, and I’d rather not have potential access to users passwords.
Here is the code I can use to authenticate a user:
on error resume next
strUserName = "username"
strPassword = "password"
strADsPath = "WinNT://domainname"
iFlags = "0"
' bind to the ADSI object and authenticate Username and password
Set oADsObject = GetObject(strADsPath)
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
set oADsNamespace = GetObject(strADsNamespace)
Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, "domainname\" & strUserName, strPassword, 0)
If not (Err.number = 0) Then
MsgBox(strUserName + " Failed.")
Else
MsgBox(strUserName + " Authenticated.")
End If
I am hoping for something like thus:
if (AuthenticateUser() <> true)
MsgBox(strUserName + " Failed.")
Else
MsgBox(strUserName + " Authenticated.")
End If
You could try a small stub executable that just runs the main one with
ShellExecute()and the"runas"verb/operation. This should cause windows to prompt for the username/password to run as. This may limit the access they have interact with other applications though.