Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate users with windows logon (advapi)

Status
Not open for further replies.

ishmael33

Programmer
Jul 1, 2003
3
SV
Hey people, I want that my app can takes the winuser logon for to validate the access to the app, but when I compare this data it doesn´t match, heres is my code:

Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Dim sBuffer As String
Dim lSize As Long
Dim clave as String
Public OK As Boolean

Private Sub Form_Load()
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
clave = Left$(sBuffer, lSize)
End Sub

Private Sub aceptar_Click()
If txtuser.Text = clave Then
OK = True
MsgBox "bievenido", vbCritical
'Me.Hide
Else
MsgBox "La contraseña no es válida; vuelva a intentarlo", , "Inicio de sesión"
txtuser.SetFocus
txtuser.SelStart = 0
txtuser.SelLength = Len(txtuser.Text)
End If
End Sub

So txtuser.text=clave doesn´t match, and my logon is "tamayo", and the value of txtuser.text is "tamayo", why it doesn´t match?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top