Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: NT Authentication


Message #1 by "Boni Gopalan" <boni@h...> on Thu, 26 Jul 2001 12:16:17 +0530
Here is a sample of a code I use to open a program.  It first shows a
standard login form with the person's name that logged on to the computer
then waits for a password.  If the password is not correct it will not
continue.  It is not designed for deep security but to foil the casual user.
It may give you some ideas to pursue.
RL Taylor

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpbuffer As String, nSize As Long) As Long


Public OK As Boolean
Private Sub Form_Load()
    Dim sBuffer As String
    Dim lSize As Long

    sBuffer = Space$(255)
    lSize = Len(sBuffer)
    Call GetUserName(sBuffer, lSize)
    If lSize > 0 Then
        txtUserName.Text = Left$(sBuffer, lSize)
    Else
        txtUserName.Text = vbNullString
    End If
End Sub

Private Sub cmdCancel_Click()
    OK = False
    Me.Hide
    frmSplash.Show
End Sub

Private Sub cmdOK_Click()
    'ToDo: create test for correct password
    'check for correct password
    If txtPassword.Text = "" Then           'PW is set here
        OK = True
        Me.Hide
        frmSplash.Show

    Else
        MsgBox "Invalid Password, try again!", , "Login"
        txtPassword.SetFocus
        txtPassword.SelStart = 0
        txtPassword.SelLength = Len(txtPassword.Text)
    End If
End Sub


  Return to Index