NT Domain Account

D

Dooza

Hi there,
Using classic ASP I want to check if a username and password are correct
before passing the details on to an object (stocktake module) that uses
them to authenticate the object. The object defaults to a preset user if
the authentication fails and doesn't warn the user, so I wanted to do
the check manually before passing it to the object.

Does anyone have any resources?

Cheers,

Steve
 
M

Mark J. McGinty

Dooza said:
Hi there,
Using classic ASP I want to check if a username and password are correct
before passing the details on to an object (stocktake module) that uses
them to authenticate the object. The object defaults to a preset user if
the authentication fails and doesn't warn the user, so I wanted to do the
check manually before passing it to the object.

Does anyone have any resources?

You will need to create a COM object to do this, it can't be done in script.
On the bright side, the code to accomplish this is fairly trivial, all you
need to do is call the LogonUser API. (Note that if it succeeds you should
close the token handle it returns.)

If you wanted to do it in VB6, it would look something like this:


Public Declare Function LogonUser Lib "kernel32" 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

Public Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle"
(ByVal hObject As Long) As Long

Public Const LOGON32_LOGON_NETWORK = 3
Public Const LOGON32_PROVIDER_DEFAULT = 0


Function ValidateCredentials( _
UserName As String, _
Password As String, _
Domain As String _
) As Boolean
Dim hToken As Long

If (LogonUser(UserName, Domain, Password, n, n, hToken) <> 0) Then
CloseHandle hToken
ValidateCredentials = True
End If

End Function



-Mark
 
D

Dooza

Mark said:
You will need to create a COM object to do this, it can't be done in script.
On the bright side, the code to accomplish this is fairly trivial, all you
need to do is call the LogonUser API. (Note that if it succeeds you should
close the token handle it returns.)

If you wanted to do it in VB6, it would look something like this:

Hi Mark,
Thank for the code, I wish I knew how to make a COM object, but will see
if a friend can do something with this for me.

Thank you!

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top