|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
NT Domain Account
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 "Dooza" <steveNO@SPAM.dooza.tv> wrote in message You will need to create a COM object to do this, it can't be done in script. 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? 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 Show quote > Cheers, > > Steve Mark J. McGinty wrote:
> You will need to create a COM object to do this, it can't be done in script. Hi Mark,> 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: 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
Other interesting topics
|
|||||||||||||||||||||||