Visual Basic Server

User-Passwort prüfen

GetUserName, WNetVerifyPassword
...leider nur für Windows 9x Win NT/2000/XP siehe: http://support.microsoft.com/kb/279815
Prozedur im Modul
Use the WNetVerifyPassword API function to verify that the user enters the correct password.
Declare Function GetUserName Lib "advapi32.dll" Alias _
 "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function WNetVerifyPassword Lib "mpr.dll" Alias _
 "WNetVerifyPasswordA" (ByVal lpszPassword As String, ByRef pfMatch As Long) As Long
Public Function GetWindowsLoginUserID() As String
Dim buf As String
Dim buf_len As Long
 buf = Space$(400)
 buf_len = Len(buf)
  If GetUserName(buf, buf_len) <> 0 Then
   GetWindowsLoginUserID = Left$(buf, buf_len - 1)
  End If
End Function
Public Function VerifyWindowsLoginUserPassword(ByVal Password As String) As Boolean
Dim rtn As Long, Match As Long
rtn = WNetVerifyPassword(Password, Match)
 If rtn Then
  VerifyWindowsLoginUserPassword = False
 Else
  VerifyWindowsLoginUserPassword = (Match <> 0)
 End If
End Function
Prozedur im Formular
Private Sub cmdClose_Click()
 Unload Me
 End
End Sub
Private Sub cmdVerify_Click()
 MsgBox "Das Passwort ist " & VerifyWindowsLoginUserPassword(txtPassword.Text), 48, "Ergebnis"
End Sub
Private Sub Form_Load()
 txtUsername = GetWindowsLoginUserID
 txtUsername.Enabled = False
End Sub

 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info