NT Domain Account

Discussion in 'ASP General' started by Dooza, Nov 6, 2007.

  1. Dooza

    Dooza Guest

    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, Nov 6, 2007
    #1
    1. Advertising

  2. "Dooza" <> wrote in message
    news:...
    > 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
    Mark J. McGinty, Nov 6, 2007
    #2
    1. Advertising

  3. Dooza

    Dooza Guest

    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
    Dooza, Nov 7, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Fox
    Replies:
    0
    Views:
    737
    Paul Fox
    Mar 5, 2004
  2. Michael Maes
    Replies:
    1
    Views:
    330
    Steven Cheng[MSFT]
    Apr 5, 2004
  3. Richard Chandler

    ASPNET account and Domain Controller

    Richard Chandler, May 5, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,220
  4. nilapenn
    Replies:
    3
    Views:
    603
    Joe Kaplan \(MVP - ADSI\)
    Feb 14, 2005
  5. Replies:
    4
    Views:
    621
    Paul Clement
    Sep 15, 2005
Loading...

Share This Page