NT Domain Account
am 06.11.2007 14:57:43 von 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
Re: NT Domain Account
am 06.11.2007 21:21:02 von mmcginty
"Dooza" wrote in message
news:efpV4zHIIHA.4688@TK2MSFTNGP06.phx.gbl...
> 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
> Cheers,
>
> Steve
Re: NT Domain Account
am 07.11.2007 10:53:12 von Dooza
Mark J. McGinty wrote:
> 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