Mensaje enviado por "Ten, Felipe" <Ften@tecnasa.com>
El código siguiente verifica el password de dominio y funciona solamente para winnt y win2000
Private Declare Function LogonUser Lib "Advapi32" 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
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _
Long
Const LOGON32_PROVIDER_DEFAULT = 0&
Const LOGON32_LOGON_NETWORK = 3&
' Check whether a username/password pair is correct
'
' if DOMAIN is omitted, it uses the local account database
' and then asks trusted domains to search their account databases
' until it finds the account or the search is exhausted
' use DOMAIN="." to search only the local account database
'
' IMPORTANT: works only under Windows NT and 2000
Public Function CheckWindowsUser(ByVal UserName As String, _
ByVal Password As String, Optional ByVal Domain As String) As Boolean
On Error GoTo errorhandler
Dim hToken As Long, ret As Long
' provide a default for the Domain name
If Len(Domain) = 0 Then Domain = vbNullString
' check the username/password pair
' using LOGON32_LOGON_NETWORK delivers the best performance
ret = LogonUser(UserName, Domain, Password, LOGON32_LOGON_NETWORK, _
LOGON32_PROVIDER_DEFAULT, hToken)
' a non-zero value means success
If ret Then
CheckWindowsUser = True
CloseHandle hToken
End If
Exit Function
errorhandler:
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
End Function
Mensaje enviado por "Sánchez Serrano, Antonio Jesús" <ajsanchez@aena.es>
Hola compañeros, buscando en la msdn he encontrado un modulo para realizar esto que necesitaba, lo adjunto por si os viene bien a alguno. Perdón por el adjunto a aquellos que no le interese.
Saludos,
Antonio J. Sánchez Serrano Aena - Aeropuerto de Málaga
Div. Apoyo Técnico
Sistemas Informáticos
Tlf. 95 20 48 793
e-mail: ajsanchez@aena.es